先上一张鸟哥LVM的图.感觉这张最清楚了。
#以下以Xshell的日志记录系统直接记录.上面添加了一些个人理解的注释
[BEGIN] 2016/9/13 9:22:24
#先查看下硬盘的情况.
[root@linuxidc ~]# fdisk -l
Disk /dev/vda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00078f9c
Device Boot Start End Blocks Id System
/dev/vda1 * 1 7833 62912512 83 Linux
Disk /dev/vdb: 536.9 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x3a7be7cb
Device Boot Start End Blocks Id System
/dev/vdb1 1 65270 524281243+ 8e Linux LVM
#上面这里显示已经有LVM.但是为了方便演示. 下面先将这个删除掉了
[root@linuxidc ~]# fdisk /dev/vdb
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p
Disk /dev/vdb: 536.9 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x3a7be7cb
Device Boot Start End Blocks Id System
/dev/vdb1 1 65270 524281243+ 8e Linux LVM
Command (m for help): d
Selected partition 1
Command (m for help): p
Disk /dev/vdb: 536.9 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x3a7be7cb
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-65270, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-65270, default 65270):
Using default value 65270
Command (m for help): p
Disk /dev/vdb: 536.9 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x3a7be7cb
Device Boot Start End Blocks Id System
/dev/vdb1 1 65270 524281243+ 83 Linux
#此处使用t来修改格式.由于是需要LVM.所以需要改为8e的格式.
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/vdb: 536.9 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x3a7be7cb
Device Boot Start End Blocks Id System
/dev/vdb1 1 65270 524281243+ 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@linuxidc ~]# partprobe
Warning: WARNING: the kernel failed to re-read the partition table on /dev/vda (Device or resource busy).
As a result, it may not reflect all of your changes until after reboot.
[root@linuxidc ~]# fdisk -l
Disk /dev/vda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00078f9c