创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小 为16MB, 而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录

环境:/dev/sdb盘还有不到8G空间(暂按8G计算),再从/dev/sdc盘中划分出12G,合计20G空间制作物理卷

[root@centos7 ~]#echo '- - -' >/sys/class/scsi_host/host2/scan 
[root@centos7 ~]#lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   10G  0 disk 
├─sda1   8:1    0  200M  0 part /boot
├─sda2   8:2    0    4G  0 part [SWAP]
├─sda3   8:3    0    2G  0 part /
├─sda4   8:4    0    1K  0 part 
└─sda5   8:5    0    2G  0 part /data
sdb      8:16   0   10G  0 disk 
└─sdb1   8:17   0    2G  0 part /test
sdc      8:32   0   16G  0 disk 
sr0     11:0    1  4.3G  0 rom 

分区

[root@centos7 ~]#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): 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 (4196352-20971519, default 4196352): 
Using default value 4196352
Last sector, +sectors or +size{K,M,G} (4196352-20971519, default 20971519): 
Using default value 20971519
Partition 2 of type Linux and of size 8 GiB is set

Command (m for help): t
Partition number (1,2, default 2): 2
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: 10.7 GB, 10737418240 bytes, 20971520 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: 0x8be52446

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     4196351     2097152   83  Linux
/dev/sdb2         4196352    20971519     8387584   8e  Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

[root@centos7 ~]#fdisk /dev/sdc
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.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x81bb6c08.

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-33554431, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-33554431, default 33554431): +12G
Partition 1 of type Linux and of size 12 GiB is set

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): p

Disk /dev/sdc: 17.2 GB, 17179869184 bytes, 33554432 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: 0x81bb6c08

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048    25167871    12582912   8e  Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@centos7 ~]#partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.
[root@centos7 ~]#lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   10G  0 disk 
├─sda1   8:1    0  200M  0 part /boot
├─sda2   8:2    0    4G  0 part [SWAP]
├─sda3   8:3    0    2G  0 part /
├─sda4   8:4    0    1K  0 part 
└─sda5   8:5    0    2G  0 part /data
sdb      8:16   0   10G  0 disk 
├─sdb1   8:17   0    2G  0 part /test
└─sdb2   8:18   0    8G  0 part 
sdc      8:32   0   16G  0 disk 
└─sdc1   8:33   0   12G  0 part 
sr0     11:0    1  4.3G  0 rom

创建物理卷

[root@centos7 ~]#pvcreate /dev/sdb2
  Physical volume "/dev/sdb2" successfully created.
[root@centos7 ~]#pvs
  PV         VG Fmt  Attr PSize  PFree 
  /dev/sdb2     lvm2 ---  <8.00g <8.00g
[root@centos7 ~]#pvcreate /dev/sdc1
  Physical volume "/dev/sdc1" successfully created.
[root@centos7 ~]#pvs
  PV         VG Fmt  Attr PSize  PFree 
  /dev/sdb2     lvm2 ---  <8.00g <8.00g
  /dev/sdc1     lvm2 ---  12.00g 12.00g
[root@centos7 ~]#pvdisplay
  "/dev/sdb2" is a new physical volume of "<8.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb2
  VG Name               
  PV Size               <8.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               vjsQVU-6ihn-v5kD-82nY-O68O-42Iv-7lvEyA

  "/dev/sdc1" is a new physical volume of "12.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdc1
  VG Name               
  PV Size               12.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               TAYOcw-uI9D-OmBI-kl2P-gBfD-GNXA-nor1vD

创建物理卷组,-s指定块大小为16M

[root@centos7 ~]#vgcreate -s 16M testvg /dev/sdb2 /dev/sdc1
  Volume group "testvg" successfully created
[root@centos7 ~]#vgs
  VG     #PV #LV #SN Attr   VSize   VFree  
  testvg   2   0   0 wz--n- <19.97g <19.97g
[root@centos7 ~]#vgdisplay
  --- 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               <19.97 GiB
  PE Size               16.00 MiB
  Total PE              1278
  Alloc PE / Size       0 / 0   
  Free  PE / Size       1278 / <19.97 GiB
  VG UUID               vrXxL9-gewG-0Bo9-VNii-1vrJ-8AFs-xL5r0O

创建逻辑卷,大小为5G

[root@centos7 ~]#lvcreate -n testvg -L 5G testvg
  Logical volume "testvg" created.
[root@centos7 ~]#lvs
  LV     VG     Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  testvg testvg -wi-a----- 5.00g                                                    
[root@centos7 ~]#lvdisplay 
  --- Logical volume ---
  LV Path                /dev/testvg/testvg
  LV Name                testvg
  VG Name                testvg
  LV UUID                cfkOjV-PcjM-uc9C-vrdZ-U6vZ-JGRW-9LYj0q
  LV Write Access        read/write
  LV Creation host, time centos7, 2020-03-25 15:33:25 +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     8192
  Block device           253:0

写入/etc/fstab

[root@centos7 ~]#blkid /dev/testvg/testvg
/dev/testvg/testvg: UUID="c048c0e0-378f-4659-a622-b7b4b78c0a30" TYPE="xfs" 
[root@centos7 ~]#echo "UUID=c048c0e0-378f-4659-a622-b7b4b78c0a30 /users  xfs defaults 0 0" >> /etc/fstab
[root@centos7 ~]#tail -1 /etc/fstab
UUID=c048c0e0-378f-4659-a622-b7b4b78c0a30 /users  xfs defaults 0 0

挂载

[root@centos7 ~]#mkdir /users
[root@centos7 ~]#mount -a
[root@centos7 ~]#lsblk
NAME              MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                 8:0    0   10G  0 disk 
├─sda1              8:1    0  200M  0 part /boot
├─sda2              8:2    0    4G  0 part [SWAP]
├─sda3              8:3    0    2G  0 part /
├─sda4              8:4    0    1K  0 part 
└─sda5              8:5    0    2G  0 part /data
sdb                 8:16   0   10G  0 disk 
├─sdb1              8:17   0    2G  0 part /test
└─sdb2              8:18   0    8G  0 part 
  └─testvg-testvg 253:0    0    5G  0 lvm  /users
sdc                 8:32   0   16G  0 disk 
└─sdc1              8:33   0   12G  0 part 
sr0                11:0    1  4.3G  0 rom  /mnt/cdrom
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值