1、基本存储配置
1) 添加一块10G大小的磁盘,将该磁盘分为两个主分区,大小为1G、2G。将剩余的空间全部划分为扩展分区。划分一个逻辑分区,大小为3G。(主分区文件系统类型为ext4,逻辑分区文件系统类型为xfs)
进入电源选项,选择打开电源时进入固件来选择硬盘的加载顺序。
调整磁盘顺序
查看磁盘情况
[root@server ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 10G 0 disk
sr0 11:0 1 10.2G 0 rom
nvme0n1 259:0 0 40G 0 disk
├─nvme0n1p1 259:1 0 500M 0 part /boot
├─nvme0n1p2 259:2 0 30G 0 part /
└─nvme0n1p3 259:3 0 1G 0 part [SWAP]
[root@server ~]#
划分磁盘分区
主分区
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): 1
First sector (2048-20971519, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-20971519, default 20971519): 2099200
Created a new partition 1 of type 'Linux' and of size 1 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): 2
First sector (2099201-20971519, default 2101248):
Last sector, +sectors or +size{K,M,G,T,P} (2101248-20971519, default 20971519): 6297600
Created a new partition 2 of type 'Linux' and of size 2 GiB.
Command (m for help):
划分扩展分区
Command (m for help): n
Partition type
p primary (2 primary, 0 extended, 2 free)
e extended (container for logical partitions)
Select (default p): e
Partition number (3,4, default 3): 3
First sector (2099201-20971519, default 6299648):
Last sector, +sectors or +size{K,M,G,T,P} (6299648-20971519, default 20971519):
Created a new partition 3 of type 'Extended' and of size 7 GiB.
Command (m for help):
划分逻辑分区
Command (m for help): n
All space for primary partitions is in use.
Adding logical partition 5
First sector (6301696-20971519, default 6301696):
Last sector, +sectors or +size{K,M,G,T,P} (6301696-20971519, default 20971519): 12599296
Created a new partition 5 of type 'Linux' and of size 3 GiB.
Command (m for help):
格式化并更改分区的文件系统
[root@server ~]# mkfs -t xfs /dev/sda5
meta-data=/dev/sda5 isize=512 agcount=4, agsize=196800 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=787200, 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
[root@server ~]#
最终结果
[root@server ~]# lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
├─sda1
├─sda2
├─sda3
└─sda5 xfs f5289c88-049e-4067-9674-fc81858cf99d
sr0 iso9660 RHEL-8-5-0-BaseOS-x86_64 2021-10-13-03-57-25-00 /run/media/root
nvme0n1
├─nvme0n1p1 xfs f59041bb-4e0f-4beb-a7da-443a1ecedbbc /boot
├─nvme0n1p2 xfs 03e7937c-8a55-4bb9-b877-dbb734128f8a /
└─nvme0n1p3 swap fb95cfa3-8ae2-4eb2-839c-9ca38531ed6a [SWAP]
[root@server ~]#
2) 将三个分区分别挂载到/dir1、/dir2、/dir3。
[root@server ~]# mount /dev/sda1 /dir1
[root@server ~]# mount /dev/sda2 /dir2
[root@server ~]# mount /dev/sda3 /dir3
[root@server ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 364M 0 364M 0% /dev
tmpfs 392M 0 392M 0% /dev/shm
tmpfs 392M 6.4M 385M 2% /run
tmpfs 392M 0 392M 0% /sys/fs/cgroup
/dev/nvme0n1p2 30G 5.1G 25G 17% /
/dev/nvme0n1p1 495M 242M 254M 49% /boot
tmpfs 79M 28K 79M 1% /run/user/0
/dev/sr0 11G 11G 0 100% /run/media/root/RHEL-8-5-0-BaseOS-x86_64
/dev/sda1 982M 2.7M 917M 1% /dir1
/dev/sda2 2.0G 6M 1.8G 1% /dir2
/dev/sda3 3.0G 54M 3.0G 2% /dir3
3) 在第一个主分区中创建一个文件为file1,内容为this is partition1。在第二个分区中创建一个文
件为file2,内容为this is partition2。在第三个分区中创建一个文件为file3,内容为this is
partition3。
[root@server ~]# vim /dir1/file1
[root@server ~]# vim /dir2/file2
[root@server ~]# vim /dir3/file3
[root@server ~]# cat /dir1/file1 /dir2/file2 /dir3/file3
this is partition1
this is partition2
this is partition3
总结