Initialize a physical volume
Prepare a partition or whole device for LVM use.
sudo pvcreate /dev/sdb1Prepare a partition or whole device for LVM use.
LVM volume management, mdadm RAID, and LUKS encryption workflows.
Create and inspect physical volumes, volume groups, and logical volumes.
Prepare a partition or whole device for LVM use.
sudo pvcreate /dev/sdb1Prepare a partition or whole device for LVM use.
sudo pvsCompact overview of LVM physical volumes.
Verbose physical volume information including UUID and extents.
sudo pvdisplayVerbose physical volume information including UUID and extents.
sudo vgcreate vgdata /dev/sdb1Create a VG from one or more initialized PVs.
sudo vgsCompact view of VGs, free extents, and sizes.
Verbose VG information including free space and metadata.
sudo vgdisplay vgdataVerbose VG information including free space and metadata.
Allocate a fixed-size LV from a volume group.
sudo lvcreate -L 100G -n lvdata vgdataAllocate a fixed-size LV from a volume group.
Use all remaining free extents in the VG.
sudo lvcreate -l 100%FREE -n lvdata vgdataUse all remaining free extents in the VG.
Preferred compact overview of logical volumes and attributes.
sudo lvsPreferred compact overview of logical volumes and attributes.
Verbose LV information including path and size.
sudo lvdisplay /dev/vgdata/lvdataVerbose LV information including path and size.
sudo mkfs.ext4 /dev/vgdata/lvdataFormat a new logical volume for use.
sudo mount /dev/vgdata/lvdata /mnt/dataMount an LV like any other block device.
Extend, reduce, snapshot, and move LVM storage.
sudo vgextend vgdata /dev/sdc1Increase free capacity in a volume group.
sudo lvextend -L +50G /dev/vgdata/lvdataGrow the logical volume size.
Grow both the LV and the contained filesystem when supported.
sudo lvextend -r -L +50G /dev/vgdata/lvdataGrow both the LV and the contained filesystem when supported.
Expand an ext filesystem to fill the larger LV.
sudo resize2fs /dev/vgdata/lvdataExpand an ext filesystem to fill the larger LV.
sudo xfs_growfs /mnt/dataExpand an XFS filesystem using the mounted path.
Dangerous if done without shrinking the filesystem first.
sudo lvreduce -L 50G /dev/vgdata/lvdataDangerous if done without shrinking the filesystem first.
For ext filesystems, shrink the filesystem before shrinking the LV.
sudo resize2fs /dev/vgdata/lvdata 45GFor ext filesystems, shrink the filesystem before shrinking the LV.
Create a snapshot LV for backup or rollback workflows.
sudo lvcreate -L 10G -s -n lvdata_snap /dev/vgdata/lvdataCreate a snapshot LV for backup or rollback workflows.
sudo lvremove /dev/vgdata/lvdata_snapDelete an unneeded LVM snapshot.
sudo pvmove /dev/sdb1Relocate data to other PVs before removing a disk.
sudo vgreduce vgdata /dev/sdb1Detach an empty or evacuated PV from a VG.
sudo lvremove /dev/vgdata/lvdataRemove an LV and return space to the VG.
Software RAID and common encrypted volume workflows.
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1Create a mirrored software RAID device.
sudo mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1Create a RAID5 array with striping and parity.
cat /proc/mdstatQuick view of RAID sync, rebuild, and degraded state.
sudo mdadm --detail /dev/md0Inspect RAID level, members, and rebuild progress.
Inspect md superblock metadata directly on a member device.
sudo mdadm --examine /dev/sdb1Inspect md superblock metadata directly on a member device.
sudo mdadm --stop /dev/md0Stop a software RAID device before disassembly or recovery work.
Discover and assemble arrays based on metadata or config.
sudo mdadm --assemble --scanDiscover and assemble arrays based on metadata or config.
Persist discovered arrays into mdadm configuration.
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.confPersist discovered arrays into mdadm configuration.
sudo cryptsetup luksFormat /dev/sdb1Create a LUKS-encrypted block device.
sudo cryptsetup open /dev/sdb1 cryptdataMap an encrypted device to /dev/mapper/cryptdata.
sudo cryptsetup close cryptdataLock and remove the decrypted device mapping.
Verify decrypted mapper devices and mountpoints.
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTSVerify decrypted mapper devices and mountpoints.