查看分区信息

[root@master ~]# fdisk -l

Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 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: 0x00003b2a

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 411647 204800 83 Linux
/dev/sda2 411648 63342591 31465472 8e Linux LVM

创建分区/dev/sda2/ 并将分区类型设置为 8e Linux LVM
[root@master ~]# fdisk /dev/sda
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/sda: 107.4 GB, 107374182400 bytes, 209715200 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: 0x00003b2a

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 411647 204800 83 Linux
/dev/sda2 411648 63342591 31465472 8e Linux LVM
/dev/sda3 63342592 168200191 52428800 8e Linux LVM

让内核重启读取分区信息

[root@master ~]# partprobe /dev/sda

查看物理卷
[root@master ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 30.00g 4.00m
创建物理卷
[root@master ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created.
检查结果
[root@master ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 30.00g 4.00m
/dev/sda3 lvm2 --- 50.00g 50.00g

创建卷组
[root@master ~]# vgcreate test /dev/sda3
Volume group "test" successfully created
[root@master ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 30.00g 4.00m
/dev/sda3 test lvm2 a-- <50.00g <50.00g

创建逻辑卷
[root@master ~]# lvcreate -L 10G -n u01 test
Logical volume "u01" created.

查看结果
[root@master ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 20.00g
swap centos -wi-ao---- 10.00g
u01 test -wi-a----- 10.00g

格式化 /dev/test/u01
root@master ~]# mkfs.ext4 /dev/test/u01
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2621440 blocks
131072 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2151677952
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

创建文件/u01
[root@master ~]# mkfs /u01

挂载分区
[root@master ~]# mount /dev/test/u01 /u01
[root@master ~]# ls /u01
lost+found