【正文】
ted by w(rite) Command (m for help): n //創(chuàng)建新分區(qū) Command action e extended p primary partition (14) p //選擇創(chuàng)建主分區(qū) Partition number (14): 1 //創(chuàng)建主分區(qū)號(hào) 1 First cylinder (1652, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1652, default 652): +3G //主分區(qū)大小 Command (m for help): n //創(chuàng)建新分區(qū) Command action e extended p primary partition (14) e //選擇創(chuàng)建擴(kuò)展分區(qū) Partition number (14): 2 //創(chuàng)建擴(kuò)展分區(qū)號(hào) 2 First cylinder (367652, default 367): Using default value 367 Last cylinder or +size or +sizeM or +sizeK (367652, default 652): //使用全部剩余空間 Using default value 652 Command (m for help): n //創(chuàng)建新分區(qū) Command action l logical (5 or over) p primary partition (14) l //選擇創(chuàng)建邏輯分區(qū) First cylinder (367652, default 367): Using default value 367 Last cylinder or +size or +sizeM or +sizeK (367652, default 652): //使用全部剩余空間 Using default value 652 2)創(chuàng)建 LVM 類型的分區(qū) 以上創(chuàng)建了一個(gè)主分區(qū),大小為3G,和一個(gè)基于擴(kuò)展分區(qū)的邏輯分區(qū)并使用了所有磁盤(pán)剩余空間作為其大?。?2G),當(dāng)然,在實(shí)際環(huán)境中每個(gè)分區(qū)建議使用 40G 左右的大小。另外,磁盤(pán)劃分為主分區(qū)還是邏輯分區(qū)對(duì) LVM 來(lái)說(shuō)無(wú)關(guān)緊要。 Command (m for help): p //查看結(jié)果 Disk /dev/sdb: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0xf451066f Device Boot Start End Blocks Id System /dev/sdb1 1 366 2939863+ 83 Linux /dev/sdb2 367 652 2297295 5 Extended /dev/sdb5 367 652 2297263+ 83 Linux Command (m for help): t //以下更改主分區(qū)類型 Partition number (15): 1 Hex code (type L to list codes): 8e Changed system type of partition 1 to 8e (Linux LVM) Command (m for help): t //更改邏輯分區(qū)類型 Partition number (15): 5 Hex code (type L to list codes): 8e Changed system type of partition 5 to 8e (Linux LVM) Command (m for help): p //查看結(jié)果 Disk /dev/sdb: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0xf451066f Device Boot Start End Blocks Id System /dev/sdb1 1 366 2939863+ 8e Linux LVM /dev/sdb2 367 652 2297295 5 Extended /dev/sdb5 367 652 2297263+ 8e Linux LVM Command (m for help): w //保存 The partition table has been altered! Calling ioctl() to reread partition table. Syncing disks. 3.創(chuàng)建物理卷 使用 pvcraeate命令將分區(qū)分配給物理卷。 1)在剛剛創(chuàng)建的兩個(gè) LVM 分區(qū)上創(chuàng)建物理卷。 pvcreate命令也可以一次對(duì)多個(gè)分區(qū)創(chuàng)建物理卷。 student@ubuntu:~$ sudo pvcreate /dev/sdb1 Physical volume /dev/sdb1 successfully created student@ubuntu:~$ sudo pvcreate /dev/sdb5 Physical volume /dev/sdb5 successfully created 2)創(chuàng)建的物理卷之后可以使用 pvscan命令查看物理卷對(duì)應(yīng)的設(shè)備名稱。 pvscan命令將掃描系統(tǒng)存在的物理卷,并顯示器設(shè)備名、容量。 student@ubuntu:~$ sudo pvscan PV /dev/sdb1 lvm2 [ GB] PV /dev/sdb5 lvm2 [ GB] Total: 2 [ GB] / in use: 0 [0 ] / in no VG: 2 [ GB] 3)使用 pvdisplay命令查看新創(chuàng)建的物理卷更詳細(xì)信息。 Pvdisplay命令將顯示物理卷的狀態(tài)和大小,包括物理卷名、所屬的卷組名、 PE值、容量等。 student@ubuntu:~$ sudo pvdisplay NEW Physical volume PV Name /dev/sdb1 VG