创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小 为16MB, 而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录
第一步:查看块设备信息
第二步:创建PV
[root@centos7 ~]# pvcreate /dev/sdc /dev/sdd #创建物理卷 Physical volume "/dev/sdc" successfully created. Physical volume "/dev/sdd" successfully created. [root@centos7 ~]# pvs #显示pv PV VG Fmt Attr PSize PFree /dev/sdc lvm2 --- 20.00g 20.00g /dev/sdd lvm2 --- 20.00g 20.00g
第三步:创建VG
[root@centos7 ~]# vgcreate testvg /dev/sdc /dev/sdd -s 16 #为卷组分配物理卷,并指定pe大小为16M Volume group "testvg" successfully created [root@centos7 ~]# vgdisplay #显示vg信息 --- Volume group --- VG Name testvg System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 2 Act PV 2 VG Size <39.97 GiB PE Size 16.00 MiB Total PE 2558 Alloc PE / Size 0 / 0 Free PE / Size 2558 / <39.97 GiB VG UUID QReJnx-d31n-Lsla-G2S9-0fyp-QTIr-D7DPj1
第四步:创建LV
[root@centos7 ~]# lvcreate -n testlv -L 5G /dev/testvg #在卷组testvg中创建名为testlv,大小为5G Logical volume "testlv" created. [root@centos7 ~]# lvdisplay #显示testlv信息 --- Logical volume --- LV Path /dev/testvg/testlv LV Name testlv VG Name testvg LV UUID TFqNMf-gTpA-o3Ot-FB7g-VyqE-gJ5I-JwEZOx LV Write Access read/write LV Creation host, time centos7.lanfeng, 2020-07-28 10:06:36 +0800 LV Status available # open 0 LV Size 5.00 GiB Current LE 320 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0
第五步:格式化lv
[root@centos7 ~]# mke2fs -t ext4 /dev/testvg/testlv 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 327680 inodes, 1310720 blocks 65536 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=1342177280 40 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 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
第六步:挂载
[root@centos7 ~]# mkdir /users #创建/users文件夹 [root@centos7 ~]# mount /dev/testvg/testlv /users/ #挂载 [root@centos7 ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda2 104806400 4864812 99941588 5% / devtmpfs 998216 0 998216 0% /dev tmpfs 1014056 0 1014056 0% /dev/shm tmpfs 1014056 10460 1003596 2% /run tmpfs 1014056 0 1014056 0% /sys/fs/cgroup /dev/sda3 52403200 104908 52298292 1% /data /dev/sdb1 1998538 9236 1960140 1% /mnt/sdb1 /dev/sda1 1038336 167032 871304 17% /boot tmpfs 202812 12 202800 1% /run/user/42 tmpfs 202812 0 202812 0% /run/user/0 /dev/mapper/testvg-testlv 5029504 20472 4730504 1% /users
如果想永久挂载可以将挂载信息写入到/etc/fstab中