LVM 這個東西指令很繁索, 沒有寫成 SOP 日後造成的困擾一定很多,目標實作二顆新硬碟/dev/hdb, /dev/hdd, 建立成 PV
- pvcreate :將實體 partition 建立成為 PV
- pvremove :相對於 pvcreate 將 PV 屬性移除,讓該 partition 不具有 PV 屬性。
- pvscan :搜尋目前系統裡面任何具有 PV 的磁碟;
- pvdisplay :顯示出目前系統上面的 PV 狀態;
- partprobe :這個指令可以讓核心立刻讀入最新的 partition table 而不必 reboot。
把磁碟設定ID為 8e
# fdisk /dev/hdb
he number of cylinders for this disk is set to 8322.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-8322, default 1): Enter
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): Enter
Using default value 8322
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/hdb: 4294 MB, 4294967296 bytes
16 heads, 63 sectors/track, 8322 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 8322 4194256+ 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
# fdisk /dev/hdd (同上步驟作法)
不用重開機,讓 kernel 更新目前的 partition
# partprobe
[root@test ~]# pvscan
No matching physical volumes found
建立磁碟為 PV 格式
[root@test ~]# pvcreate /dev/hdb1
Physical volume “/dev/hdb1” successfully created
[root@test ~]# pvcreate /dev/hdd1
Physical volume “/dev/hdd1” successfully created
查看 PV
[root@test ~]# pvscan
PV /dev/hdb1 lvm2 [4.00 GB]
PV /dev/hdd1 lvm2 [4.00 GB]
Total: 2 [8.00 GB] / in use: 0 [0 ] / in no VG: 2 [8.00 GB]
詳細查看 PV
[root@test ~]# pvdisplay
— NEW Physical volume —
PV Name /dev/hdb1
VG Name
PV Size 4.00 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID ODLISG-VQtA-qMNb-EJrV-TtLp-El1n-1hUxbr
— NEW Physical volume —
PV Name /dev/hdd1
VG Name
PV Size 4.00 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 5JUJOn-1dpp-wlid-yHdS-6G7p-B0JN-1BBYil