Manage Disk Volume in Linux

The following commands are commonly used in managing physical and logical volumes in Linux.

1. Create a file system
a) create a disk partition
# fdisk 'device_name'
Add a new partition by command 'n' and then write table to disk and exit by command 'w'
# fdisk -l 'device_name'
b) initialize the disk partition to create a new physical volumn
# pvcreate 'disk_partition'
c) create a file system
# mkfs -t 'mount_type' 'physical_volume'
# mkdir 'mount_directory'
# mount -t 'mount_type' 'physical_volume' 'mount_directory'
# chmod 755 'mount_directory'
# blkid 'physical_volume'
Edit the /etc/fstab to mount the directory on boot:
"UUID=uuid" 'mount_directory' 'mount_type' 'mount_option' 'fs_freq' 'fs_passno'

2. Display volume information:
a) display file system volumes
# df
b) display logical volumes
# lvdisplay
c) display physical volumes
# pvdisplay
d) display volume groups
# vgdisplay

3. Create a new volume group:
a) initialize each disk partition
# pvcreate 'disk_partition'
b) create the volume group
# vgcreate 'volume_group' 'physical_volumes'
c) activate the volume group
# vgscan

4. Extend a physical volume to a volume group:
# vgextend 'volume_group' 'physical_volume'

5. Remove missing phyiscal volumes from the volume group:
# vgreduce --force --removemissing 'volume_group'

6. Display hard drive information:
# hdparm -i /dev/sd*

7. Display file storage information:
# df -lh 'directory'

8. Display disk information:
# du -h 'directory'