EXAMPLES
Setting up LVM on three SCSI disks (/dev/sda, /dev/sdb, and /dev/sdc) with striping
-
Preparing the disks
# pvcreate /dev/sda # pvcreate /dev/sdb # pvcreate /dev/sdc -
Setup a VG
-
Create a VG
# vgcreate my_VG /dev/sda /dev/sdb /dev/sdc -
Run
# vgdisplayto verify volume group
-
-
Creating the LV (1GB) with 3 PVs and strip size of 4 KB on the VG:
# lvcreate -i3 -I4 -L1G -nmy_LV my_VG -
Creating an ext4 file system on the LV
# mke4fs /dev/my_VG/my_LV -
Mount and Test the File System
# mount /dev/my_VG/my_LV /mnt # df
Snapshot
-
Creating a snapshot of an entire LV:
# lvdisplay my_LV | grep "LV Size" LV Size 50.00 GiB # lvcreate -L50G -s -nmy_LV_backup /dev/my_VG/my_LV -
Mount the snapshot volume:
# mkdir /mnt/my_LV_backup # mount /dev/my_VG/my_LV_backup /mnt/my_LV_backup -
Remove the snapshot:
# umount /mnt/my_LV_backup # lvremove /dev/my_VG/my_LV_backup
Removing an Old Disk (/dev/sdb)
-
Distributing Old Extents to Existing Disks in VG
# pvmove /dev/sdb -
Remove the unused disk
# vgreduce my_VG /dev/sdb -
The drive can now be removed when the machine is powered down
Replace an old disc (/dev/sdb) with a new one (/dev/sdf)
-
Preparing the new disk
# pvcreate /dev/sdf -
Add it to the VG my_VG
# vgextend my_VG /dev/sdf -
Moving the data
# pvmove /dev/sdb /dev/sdf -
Removing the unused disk
# vgreduce my_VG /dev/sdb -
The drive can now be removed when the machine is powered down