在我们虚拟机界面添加新磁盘,然后步骤如下
硬盘分区:
[root@rhcsa ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.40.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.
Created a new DOS (MBR) disklabel with disk identifier 0x990495ff.
Command (m for help): o
Created a new DOS (MBR) disklabel with disk identifier 0xc3b2ba40.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-44040191, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-44040191, default 44040191): +2G
Created a new partition 1 of type 'Linux' and of size 2 GiB.
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2):
First sector (4196352-44040191, default 4196352):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (4196352-44040191, default 44040191): +2G
Created a new partition 2 of type 'Linux' and of size 2 GiB.
Command (m for help): n
Partition type
p primary (2 primary, 0 extended, 2 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3):
First sector (8390656-44040191, default 8390656):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (8390656-44040191, default 44040191): +3G
Created a new partition 3 of type 'Linux' and of size 3 GiB.
Command (m for help): n
Partition type
p primary (3 primary, 0 extended, 1 free)
e extended (container for logical partitions)
Select (default e): e
Selected partition 4
First sector (14682112-44040191, default 14682112):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (14682112-44040191, default 44040191):
Created a new partition 4 of type 'Extended' and of size 14 GiB.
Command (m for help): n
All primary partitions are in use.
Adding logical partition 5
First sector (14684160-44040191, default 14684160):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (14684160-44040191, default 44040191): +3G
Created a new partition 5 of type 'Linux' and of size 3 GiB.
Command (m for help): n
All primary partitions are in use.
Adding logical partition 6
First sector (20977664-44040191, default 20977664):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (20977664-44040191, default 44040191): +3G
Created a new partition 6 of type 'Linux' and of size 3 GiB.
Command (m for help): n
All primary partitions are in use.
Adding logical partition 7
First sector (27271168-44040191, default 27271168):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (27271168-44040191, default 44040191):
Created a new partition 7 of type 'Linux' and of size 8 GiB.
Command (m for help): p
Disk /dev/sda: 21 GiB, 22548578304 bytes, 44040192 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xc3b2ba40
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 4196351 4194304 2G 83 Linux
/dev/sda2 4196352 8390655 4194304 2G 83 Linux
/dev/sda3 8390656 14682111 6291456 3G 83 Linux
/dev/sda4 14682112 44040191 29358080 14G 5 Extended
/dev/sda5 14684160 20975615 6291456 3G 83 Linux
/dev/sda6 20977664 27269119 6291456 3G 83 Linux
/dev/sda7 27271168 44040191 16769024 8G 83 Linux
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
[root@rhcsa ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.40.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.
Created a new DOS (MBR) disklabel with disk identifier 0x76f4ae84.
Command (m for help): g
Created a new GPT disklabel (GUID: CA42BD46-2412-4200-9885-6C329228F30C).
Command (m for help): n
Partition number (1-128, default 1):
First sector (2048-41943006, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-41943006, default 41940991): +4G
Created a new partition 1 of type 'Linux filesystem' and of size 4 GiB.
Command (m for help): n
Partition number (2-128, default 2):
First sector (8390656-41943006, default 8390656):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (8390656-41943006, default 41940991): +3G
Created a new partition 2 of type 'Linux filesystem' and of size 3 GiB.
Command (m for help): n
Partition number (3-128, default 3):
First sector (14682112-41943006, default 14682112):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (14682112-41943006, default 41940991):
Created a new partition 3 of type 'Linux filesystem' and of size 13 GiB.
Command (m for help): p
Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: CA42BD46-2412-4200-9885-6C329228F30C
Device Start End Sectors Size Type
/dev/sdb1 2048 8390655 8388608 4G Linux filesystem
/dev/sdb2 8390656 14682111 6291456 3G Linux filesystem
/dev/sdb3 14682112 41940991 27258880 13G Linux filesystem
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
格式化:
[root@rhcsa ~]# mkfs.xfs /dev/sda1
[root@rhcsa ~]# mkfs.ext4 /dev/sda2
[root@rhcsa ~]# lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sda
├─sda1 xfs 9457ccee-7b50-459f-819d-ce16963e666f
├─sda2 ext4 1.0 8ef7c3cf-fc4e-4cb4-98cc-e287d7ef0167
├─sda3
├─sda4
├─sda5
├─sda6
└─sda7
挂载:
[root@rhcsa ~]# mkdir /guazai1
[root@rhcsa ~]# mount /dev/sda1 /guazai1/
[root@rhcsa ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 21G 0 disk
├─sda1 8:1 0 2G 0 part /guazai1
├─sda2 8:2 0 2G 0 part
├─sda3 8:3 0 3G 0 part
├─sda4 8:4 0 1K 0 part
├─sda5 8:5 0 3G 0 part
├─sda6 8:6 0 3G 0 part
└─sda7 8:7 0 8G 0 part
[root@rhcsa ~]# mkdir /guazai2
[root@rhcsa ~]# blkid /dev/sda2
/dev/sda2: UUID="8ef7c3cf-fc4e-4cb4-98cc-e287d7ef0167" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="c3b2ba40-02"
[root@rhcsa ~]# mount UUID="8ef7c3cf-fc4e-4cb4-98cc-e287d7ef0167" /guazai2