作业--磁盘

本文详细指导如何在Linux中创建一个包含两个物理卷的20GB VG,设置每个PE为16MB,并在其中创建5GB的逻辑卷,最后挂载至/users目录。涉及步骤包括查看磁盘、分区、创建PV、VG、LV,以及格式化和挂载。
摘要由CSDN通过智能技术生成

题目:

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

答案:

1:先查看

[root@node2 ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   50G  0 disk
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   49G  0 part
  ├─centos-root 253:0    0   47G  0 lvm  /
  └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sr0              11:0    1 1024M  0 rom

2:创建硬盘

3:查看硬盘是否创建成功

[root@node2 ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   50G  0 disk
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   49G  0 part
  ├─centos-root 253:0    0   47G  0 lvm  /
  └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sdb               8:16   0   20G  0 disk
sr0              11:0    1 1024M  0 rom

 4:分区

[root@node2 ~]# 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.

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

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

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p):
Using default response p
Partition number (2-4, default 2):
First sector (20973568-41943039, default 20973568):
Using default value 20973568
Last sector, +sectors or +size{K,M,G} (20973568-41943039, default 41943039): +10G
Value out of range.
Last sector, +sectors or +size{K,M,G} (20973568-41943039, default 41943039):
Using default value 41943039
Partition 2 of type Linux and of size 10 GiB is set

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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: 0x5a642b9b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    20973567    10485760   83  Linux
/dev/sdb2        20973568    41943039    10484736   83  Linux

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

Calling ioctl() to re-read partition table.
Syncing disks.

5:创建物理卷

[root@node2 ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   50G  0 disk
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   49G  0 part
  ├─centos-root 253:0    0   47G  0 lvm  /
  └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sdb               8:16   0   20G  0 disk
├─sdb1            8:17   0   10G  0 part
└─sdb2            8:18   0   10G  0 part
sr0              11:0    1 1024M  0 rom
[root@node2 ~]#
[root@node2 ~]#
[root@node2 ~]# pvcreate /dev/sdb{1,2}
  Physical volume "/dev/sdb1" successfully created.
  Physical volume "/dev/sdb2" successfully created.
[root@node2 ~]#
[root@node2 ~]# pvs
  PV         VG     Fmt  Attr PSize   PFree
  /dev/sda2  centos lvm2 a--  <49.00g   4.00m
  /dev/sdb1         lvm2 ---   10.00g  10.00g
  /dev/sdb2         lvm2 ---  <10.00g <10.00g

6:创建卷组

[root@node2 ~]# vgcreate -s 16M testvg /dev/sdb{1,2}
  Volume group "testvg" successfully created
[root@node2 ~]# vgs
  VG     #PV #LV #SN Attr   VSize   VFree
  centos   1   2   0 wz--n- <49.00g   4.00m
  testvg   2   0   0 wz--n- <19.97g <19.97g

7:创建逻辑卷

[root@node2 ~]# lvcreate -L 5G -n testlv testvg
  Logical volume "testlv" created.
[root@node2 ~]# lvs
  LV     VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root   centos -wi-ao---- 46.99g
  swap   centos -wi-ao----  2.00g
  testlv testvg -wi-a-----  5.00g

8:格式化

[root@node2 ~]# mkfs.xfs /dev/testvg/testlv
meta-data=/dev/testvg/testlv     isize=512    agcount=4, agsize=327680 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=1310720, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

9:挂载

[root@node2 ~]# mkdir /users
[root@node2 ~]# mount /dev/testvg/testlv /users/
[root@node2 ~]# df
Filesystem                1K-blocks    Used Available Use% Mounted on
devtmpfs                    1001888       0   1001888   0% /dev
tmpfs                       1013948       0   1013948   0% /dev/shm
tmpfs                       1013948    9764   1004184   1% /run
tmpfs                       1013948       0   1013948   0% /sys/fs/cgroup
/dev/mapper/centos-root    49250820 1637760  47613060   4% /
/dev/sda1                   1038336  140420    897916  14% /boot
tmpfs                        202792       0    202792   0% /run/user/0
/dev/mapper/testvg-testlv   5232640   32992   5199648   1% /users

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值