Difference between revisions of "LVM"

From braindump
Jump to navigation Jump to search
Line 53: Line 53:
/dev/loop4 lpic lvm2 a- 96.00M 96.00M
/dev/loop4 lpic lvm2 a- 96.00M 96.00M
/dev/loop5 lpic lvm2 a- 96.00M 96.00M
/dev/loop5 lpic lvm2 a- 96.00M 96.00M
# vgs
# vgs
VG #PV #LV #SN Attr VSize VFree
VG #PV #LV #SN Attr VSize VFree
lpic 5 0 0 wz--n- 480.00M 480.00M
lpic 5 0 0 wz--n- 480.00M 480.00M

Revision as of 03:10, 11 February 2011

Notes on LVM

  1. PV commands => working on physical disk
  2. VG commands => virtual groups
  3. LV commands => logical volumes

Create a bunch of small (100MB) virtual disks for use with LVM.

DISK_DIR=/var/tmp/disks
mkdir -p ${DISK_DIR} &&
for i in 1 2 3 4 5; do
    dd if=/dev/zero of=${DISK_DIR}/disk${i} bs=100M count=1 &&
    losetup /dev/loop${i} ${DISK_DIR}/disk${i} &&
    pvcreate /dev/loop${i}
done

Output should look like this

1+0 records in
1+0 records out
104857600 bytes (105 MB) copied, 0.50751 s, 207 MB/s
  Physical volume "/dev/loop1" successfully created
1+0 records in
1+0 records out
104857600 bytes (105 MB) copied, 1.94502 s, 53.9 MB/s
  Physical volume "/dev/loop2" successfully created
1+0 records in
1+0 records out
104857600 bytes (105 MB) copied, 4.12227 s, 25.4 MB/s
  Physical volume "/dev/loop3" successfully created
1+0 records in
1+0 records out
104857600 bytes (105 MB) copied, 1.51487 s, 69.2 MB/s
  Physical volume "/dev/loop4" successfully created
1+0 records in
1+0 records out
104857600 bytes (105 MB) copied, 3.88262 s, 27.0 MB/s
  Physical volume "/dev/loop5" successfully created

Confirm the output

# pvs
 PV         VG         Fmt  Attr PSize   PFree
 /dev/loop1            lvm2 --   100.00M 100.00M
 /dev/loop2            lvm2 --   100.00M 100.00M
 /dev/loop3            lvm2 --   100.00M 100.00M
 /dev/loop4            lvm2 --   100.00M 100.00M
 /dev/loop5            lvm2 --   100.00M 100.00M

Create Virtual Group

# vgcreate lpic /dev/loop{1,2,3,4,5}
 Volume group "lpic" successfully created
# pvs
 PV         VG         Fmt  Attr PSize  PFree
 /dev/loop1 lpic       lvm2 a-   96.00M 96.00M
 /dev/loop2 lpic       lvm2 a-   96.00M 96.00M
 /dev/loop3 lpic       lvm2 a-   96.00M 96.00M
 /dev/loop4 lpic       lvm2 a-   96.00M 96.00M
 /dev/loop5 lpic       lvm2 a-   96.00M 96.00M
# vgs
 VG         #PV #LV #SN Attr   VSize   VFree
 lpic         5   0   0 wz--n- 480.00M 480.00M