4.使用VMware软件和提供的CentOS-7-x86_64-DVD-1511.iso创建虚拟机,自行配置好网络并多添加一块大小为20G的硬盘,使用fdisk命令对该硬盘进形分区,要求分出三个大小为5G的分区。使用这三个分区,创建名xcloudvg的卷组。然后创建名xcloudlv的逻辑卷,大小为12G,最后用xfs文件系统对逻辑卷进行格式化并挂载到/mnt目录下。将上述所有操作命令和返回结果以文本形式提交到答题框。

前期准备

搭建一个虚拟机,镜像为CentOS-7-x86_64-DVD-1511配置好网络,关机,新添加一个硬盘,大小为20G

对该硬盘分区

1、进入该硬盘

[root@localhost ~]# fdisk /dev/sdc

2、给这个硬盘分3个区,每个硬盘5G空间大小

[root@localhost ~]# 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 0x9953e222.

Command (m for help): #n
Partition type: #直接回车
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): #直接回车
Using default response 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): #+5G
Partition 1 of type Linux and of size 5 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 (10487808-41943039, default 10487808): #直接回车
Using default value 10487808
Last sector, +sectors or +size{K,M,G} (10487808-41943039, default 41943039): #+5G
Partition 2 of type Linux and of size 5 GiB is set

Command (m for help): #n
Partition type: #直接回车
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): #直接回车
Using default response p
Partition number (3,4, default 3): #直接回车
First sector (20973568-41943039, default 20973568): #直接回车
Using default value 20973568
Last sector, +sectors or +size{K,M,G} (20973568-41943039, default 41943039): #+5G
Partition 3 of type Linux and of size 5 GiB is set

Command (m for help): #p    查看分区

Disk /dev/sdc: 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: 0x9953e222

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048    10487807     5242880   83  Linux
/dev/sdc2        10487808    20973567     5242880   83  Linux
/dev/sdc3        20973568    31459327     5242880   83  Linux

Command (m for help): #w    保存退出
The partition table has been altered!

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

3、查看给硬盘的分区

[root@localhost ~]# fdisk -l /dev/sdc
Disk /dev/sdc: 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: 0x9953e222

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048    10487807     5242880   83  Linux
/dev/sdc2        10487808    20973567     5242880   83  Linux
/dev/sdc3        20973568    31459327     5242880   83  Linux

创建卷组

用sdc的三个分区,创建xcloudvg卷组

[root@localhost ~]# vgcreate xcloudvg /dev/sdc1 /dev/sdc2 /dev/sdc3
  Physical volume "/dev/sdc1" successfully created
  Physical volume "/dev/sdc2" successfully created
  Physical volume "/dev/sdc3" successfully created
  Volume group "xcloudvg" successfully created

创建逻辑卷

用刚刚创建的xcloudvg卷组创建大小为12G的逻辑卷xcloudlv

[root@localhost ~]# lvcreate -n xcloudlv -L 12G xcloudvg
  Logical volume "xcloudlv" created.

查看创建的逻辑卷,/dev/mapper/xcloudvg-xcloudlv就是我们创建的逻辑卷

[root@localhost ~]# fdisk -l
   ...
Disk /dev/mapper/xcloudvg-xcloudlv: 12.9 GB, 12884901888 bytes, 25165824 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

格式化逻辑卷

格式化刚刚创建的逻辑卷(xfs格式)

[root@localhost ~]# mkfs -t xfs /dev/mapper/xcloudvg-xcloudlv
meta-data=/dev/mapper/xcloudvg-xcloudlv isize=256    agcount=4, agsize=786432 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=3145728, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
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

挂载

/dev/mapper/xcloudvg-xcloudlv挂载到/mnt目录

[root@localhost ~]# mount /dev/mapper/xcloudvg-xcloudlv /mnt
[root@localhost ~]# df -h
Filesystem                     Size  Used Avail Use% Mounted on
/dev/mapper/centos-root         36G  855M   35G   3% /
devtmpfs                       1.9G     0  1.9G   0% /dev
tmpfs                          1.9G     0  1.9G   0% /dev/shm
tmpfs                          1.9G  8.5M  1.9G   1% /run
tmpfs                          1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/sda1                      497M  125M  373M  25% /boot
tmpfs                          378M     0  378M   0% /run/user/0
/dev/mapper/xcloudvg-xcloudlv   12G   33M   12G   1% /mnt
最后修改:2021 年 08 月 08 日
如果觉得我的文章对你有用,请随意赞赏