Disk /dev/hda: 255 heads, 63 sectors, 623 cylinders Units = cylinders of 16065 * 512 bytes
Device Boot Start End Blocks Id System /dev/hda1 1 2 16033 83 Linux /dev/hda2 3 600 4803435 83 Linux /dev/hda3 601 607 56227 83 Linux /dev/hda4 608 614 56227 83 Linux
Command (m for help): t Partition number (1-4): 3 Hex code (type L to list codes): 8e
Command (m for help): p
Disk /dev/hda: 255 heads, 63 sectors, 623 cylinders Units = cylinders of 16065 * 512 bytes
Device Boot Start End Blocks Id System /dev/hda1 1 2 16033 83 Linux /dev/hda2 3 600 4803435 83 Linux /dev/hda3 601 607 56227 8e Unknown /dev/hda4 608 614 56227 83 Linux
Command (m for help): w
我們對/dev/hdb2做同樣的操作,這是需要的,以至LVM能重建你應該丟失的配置.
通常,不需要重啟,但有些計算機卻要求.因此如果下面的例子不工作,試試重啟.
接著我們創建物理卷(PV),如下:
# pvcreate /dev/hda3 pvcreate -- physical volume "/dev/hda3" successfully created # pvcreate /dev/hdb2 pvcreate -- physical volume "/dev/hdb2" successfully created
我們再將這兩個物理卷(PV)加到一個叫做「test」的卷組(VG)中:
# vgcreate test /dev/hdb2 /dev/hda3 vgcreate -- INFO: using default physical extent size 4 MB vgcreate -- INFO: maximum logical volume size is 255.99 Gigabyte vgcreate -- doing automatic backup of volume group "test" vgcreate -- volume group "test" successfully created and activated
現在我們有一個空的卷組(VG),讓我們來檢查一下:
# vgdisplay -v test --- Volume group --- VG Name test VG Access read/write VG Status available/resizable VG # 0 MAX LV 256 Cur LV 0 Open LV 0 MAX LV Size 255.99 GB Max PV 256 Cur PV 2 Act PV 2 VG Size 184 MB PE Size 4 MB Total PE 46 Alloc PE / Size 0 / 0 Free PE / Size 46 / 184 MB
--- No logical volumes defined in test ---
--- Physical volumes --- PV Name (#) /dev/hda3 (2) PV Status available / allocatable Total PE / Free PE 13 / 13
PV Name (#) /dev/hdb2 (1) PV Status available / allocatable Total PE / Free PE 33 / 33
# lvcreate -L 50M -n HOWTO test lvcreate -- rounding up size to physical extent boundary "52 MB" lvcreate -- doing automatic backup of "test" lvcreate -- logical volume "/dev/test/HOWTO" successfully created
Ok,到這裡,我們創建一個文件系統:
# mkfs.ext3 /dev/test/HOWTO mke2fs 1.18, 11-Nov-1999 for EXT2 FS 0.5b, 95/08/09 Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) 13328 inodes, 53248 blocks 2662 blocks (5.00%) reserved for the super user First data block=1 7 block groups 8192 blocks per group, 8192 fragments per group 1904 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961
Writing inode tables: done Writing superblocks and filesystem accounting information: done # mount /dev/test/HOWTO /mnt # ls /mnt lost found
我們做完了!讓我們回顧我們的卷組(VG),它現在充滿了一些東西:
# vgdisplay test -v --- Volume group --- VG Name test VG Access read/write VG Status available/resizable VG # 0 MAX LV 256 Cur LV 1 Open LV 1 MAX LV Size 255.99 GB Max PV 256 Cur PV 2 Act PV 2 VG Size 184 MB PE Size 4 MB Total PE 46 Alloc PE / Size 13 / 52 MB Free PE / Size 33 / 132 MB
--- Logical volume --- LV Name /dev/test/HOWTO VG Name test LV Write Access read/write LV Status available LV # 1 # open 1 LV Size 52 MB Current LE 13 Allocated LE 13 Allocation next free Read ahead sectors 120 Block device 58:0
--- Physical volumes --- PV Name (#) /dev/hda3 (2) PV Status available / allocatable Total PE / Free PE 13 / 13
PV Name (#) /dev/hdb2 (1) PV Status available / allocatable Total PE / Free PE 33 / 20 /dev/hda3完全沒用,而/dev/hdb2有13個物理分區(PE)在用.
如果在你的卷組中有剩餘空間,那麼只需要一行:
# lvextend -L 12M /dev/test/HOWTO lvextend -- rounding size to physical extent boundary lvextend -- extending logical volume "/dev/test/HOWTO" to 116 MB lvextend -- doing automatic backup of volume group "test" lvextend -- logical volume "/dev/test/HOWTO" successfully extended