一、环境:CentOS7虚拟机,挂载了一块2G硬盘
二、配置过程:
1、给硬盘分区:
创建三个分区,前两个512M,最后一个默认大小,1G多一些,最后一个默认指定大小,具体操作根据自己环境而定。把分区都改成Linux LVM格式就好了。
Command (m for help): p //查看分区表
Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xbe89015f
Device Boot Start End Blocks Id System
Command (m for help): n //创建分区
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p //主分区
Partition number (1-4, default 1): 1
First sector (2048-4194303, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-4194303, default 4194303): +512M //指定大小
Partition 1 of type Linux and of size 512 MiB is set
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
Partition number (2-4, default 2): 2
First sector (1050624-4194303, default 1050624):
Using default value 1050624
Last sector, +sectors or +size{K,M,G} (1050624-4194303, default 4194303): +512M
Partition 2 of type Linux and of size 512 MiB is set
Command (m for help): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
Partition number (3,4, default 3):
First sector (2099200-4194303, default 2099200):
Using default value 2099200
Last sector, +sectors or +size{K,M,G} (2099200-4194303, default 4194303): //默认剩下全部大小
Using default value 4194303
Partition 3 of type Linux and of size 1023 MiB is set
Command (m for help): w //保存退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xbe89015f
Device Boot Start End Blocks Id System
/dev/sdb1 2048 1050623 524288 83 Linux
/dev/sdb2 1050624 2099199 524288 83 Linux
/dev/sdb3 2099200 4194303 1047552 83 Linux
Command (m for help): t //修改分区类型
Partition number (1-3, default 3): 1 //选择分区
Hex code (type L to list all codes): 8e //更变为Linux LVM类型分区,8e为分区代码,l可以查看
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): t
Partition number (1-3, default 3): 2
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): t
Partition number (1-3, default 3): 3
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): p
Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xbe89015f
Device Boot Start End Blocks Id System
/dev/sdb1 2048 1050623 524288 8e Linux LVM
/dev/sdb2 1050624 2099199 524288 8e Linux LVM
/dev/sdb3 2099200 4194303 1047552 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
2、创建物理卷:
命令:pv系列命令