New partition
- Use
lsblkto ID the disk. - Create LVM physical disk
sudo pvcreate /dev/$device - Create LVM volume group
sudo vgcreate $vg_name /dev/$device- Create LVM logical volume
sudo lvcreate -l 100%FREE -n $lv_name $vg_name- Format volume
sudo mkfs.ext4 /dev/$vg_name/$lv_name- Create mountpoint
sudo mkdir /$mountpoint- Find LVM device UUID (
LVM-<something>)
dmsetup info -c --noheadings -o uuid /dev/$vg_name/$lv_name - Insert LVM device UUID into fstab, prefixed with
/dev/disk/by-id/dm-uuid-:
sudo vi /etc/fstab[...]
/dev/disk/by-id/dm-uuid-LVM-<something> /$mountpoint ext4 defaults 0 2
- Reload fstab
sudo systemctl daemon-reload- Mount all disks
sudo mount -aExtend partition
- Scan for new disk devices
ls /sys/class/scsi_host/ | while read host; do echo "- - -" > /sys/class/scsi_host/$host/scan; doneor
Scan for resized disk (at /dev/sdb)
echo 1 > /sys/block/sdb/device/rescan- Use
fdisk/cfdisk/partedto create new partition orgrowpart -v /dev/sdb 1to automatically expand the first partition of/dev/sdbto fill the disk - Refresh partition table (if
fdisk -l)
partx -v -a /dev/sdb- Resize LVM stuff
vgextend $vg_name /dev/sdbX
lvextend -l +100%FREE -r /dev/$vg_name/$lv_nameThe -r flag will automatically resize the file system too.
See also: