Source: doc Ubuntu-fr - LVM
In this example we will create a LVM placed on 2 partitions: sda10 and sdb1
All the command are done with root permissions ⇒ su
or sudo
pvcreate /dev/sda10 pvcreate /dev/sdb1
pvdisplay
or pvscan
to get info.
vgcreate vgBackupPC /dev/sda10 /dev/sdb1
vgdisplay
to get info.
lvcreate -n lvBackupPC -l 100%FREE vgBackupPC
lvdisplay
to get info.
-n
is to give the name and -l
to deal with the storage space ⇒ see the man for more details.
mkfs -t ext4 /dev/vgBackupPC/lvBackupPC
mount -t ext4 /dev/vgBackupPC/lvBackupPC /mount/point
lvdisplay
! $ blkid /dev/sda1: UUID=.... /dev/sda2: UUID=.... /dev/sda3: UUID=.... .... /dev/mapper/vgBackupPC-lvBackupPC: UUID="521489ca-ba67-49e9-a3c6-fa62b0eeeb2f" TYPE="ext4"
mount -t ext4 UUID=521489ca-ba67-49e9-a3c6-fa62b0eeeb2f /mount/point
In this example we want to remove the disk (= the physical volume more exactly) dev/sdb1
from the LVM.
# pvs -o+pv_used PV VG Fmt Attr PSize PFree Used /dev/sda8 vgBackupPC lvm2 a-- 363,51g 0 363,51g /dev/sdb1 vgBackupPC lvm2 a-- 931,51g 0 931,51g
# df -h /mnt/dd_affa/ Sys. de fichiers Taille Utilisé Dispo Uti% Monté sur /dev/mapper/vgBackupPC-lvBackupPC 1,3T 287M 1,2T 1% /mnt/dd_affa
So only 287MB are used, so the volume /dev/sda8 can contain all the data.
# umount /mnt/dd_affa
# lvresize --resizefs --size -1,1T /dev/mapper/vgBackupPC-lvBackupPC
# pvmove /dev/sdb1
# vgreduce vgBackupPC /dev/sdb1
# pvremove /dev/sdb1
# resize2fs /dev/mapper/vgBackupPC-lvBackupPC