Show disks, partitions, filesystems and mount points
lsblk -fCreate, mount, grow and remove physical volumes, volume groups and logical volumes, with XFS and ext4 grow differences.
Show disks, partitions, filesystems and mount points
lsblk -fList physical volumes in brief
pvsList volume groups and free space
vgsList logical volumes in brief
lvsShow detailed information for PV / VG / LV
pvdisplay / vgdisplay / lvdisplayInitialize a whole disk as a PV (wipes existing partition info)
sudo pvcreate /dev/sdbAlternatively initialize a single partition as a PV
sudo pvcreate /dev/sdb1Verify PV size and free space
pvs -o pv_name,pv_size,pv_freeCreate a volume group named data_vg
sudo vgcreate data_vg /dev/sdbCreate a 20G logical volume in the VG
sudo lvcreate -L 20G -n data_lv data_vgUse all remaining VG space for the LV
sudo lvcreate -l 100%FREE -n data_lv data_vgCreate a mirrored LV (requires at least two PVs)
sudo lvcreate -L 10G -n log_lv -m 1 data_vgConfirm LV names and sizes
lvs -o lv_name,lv_size,pool_lvFormat as XFS; use mkfs.ext4 for ext4
sudo mkfs.xfs /dev/data_vg/data_lvCreate a mount point and mount it
sudo mkdir -p /data && sudo mount /dev/data_vg/data_lv /dataGet the UUID; prefer UUID entries in fstab
sudo blkid /dev/data_vg/data_lvAppend this line to /etc/fstab for mounting at boot
UUID=xxxx-xxxx /data xfs defaults 0 0Run mount -a after editing fstab to avoid boot failures
Add 10G to the logical volume
sudo lvextend -L +10G /dev/data_vg/data_lvExtend the LV by all remaining VG space
sudo lvextend -l +100%FREE /dev/data_vg/data_lvGrow an XFS filesystem; argument is the mount point
sudo xfs_growfs /dataGrow an ext4 filesystem; argument is the device path
sudo resize2fs /dev/data_vg/data_lvAdd a new disk to the VG to expand capacity
sudo vgextend data_vg /dev/sdcRefresh PV size after the underlying disk was enlarged
sudo pvresize /dev/sdbext4 shrink flow: unmount, check then resize; XFS cannot shrink
sudo umount /data && sudo e2fsck -f /dev/data_vg/data_lv && sudo resize2fs /dev/data_vg/data_lv 5GShrink an LV; shrink the filesystem first or data will corrupt
sudo lvreduce -L -5G /dev/data_vg/data_lvRemove a logical volume; data cannot be recovered
sudo lvremove /dev/data_vg/data_lvRemove a volume group
sudo vgremove data_vgRemove the PV label
sudo pvremove /dev/sdbThis website uses cookies to ensure you get the best experience on our website. Privacy Policy.