news 2026/7/10 4:51:13

新建硬盘---分区----格式化----挂载,笔记

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
新建硬盘---分区----格式化----挂载,笔记

在我们虚拟机界面添加新磁盘,然后步骤如下

硬盘分区:

[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

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/7/10 4:49:15

分期迭代搭建智慧招采体系,合力信招投标平台实战案例

北京合力信,2010年,北京合力信工程投资咨询有限公司是以新奥能源工程造价审计中心为班底,经住建部批准成立的拥有工程造价甲级咨询资质的专业公司。 一、项目历程:六年合作,迭代落地 为加速招采业务数字化转型、全面…

作者头像 李华
网站建设 2026/7/10 4:48:24

Python 3.12 实现永续合约多空双开策略:胜率96%背后的3个关键参数与回测

Python 3.12 实现永续合约多空双开策略:胜率96%背后的3个关键参数与回测永续合约交易中,多空双开策略因其独特的风险对冲特性备受量化交易者关注。本文将深入解析一个实测胜率达96%的多空双开策略,从Python代码实现到参数调优,完整…

作者头像 李华
网站建设 2026/7/10 4:47:19

MiniMax M3发布引定价风波,从Mini到Max的成长阵痛与技术追求

【MiniMax M3发布与定价风波】 编辑部消息,刚刚过去的六月,有机会进入大模型公司MiniMax内部,全程围观了M3模型的发布。M3是中国模型里少有的强化了编程和agent能力的原生多模态模型,被寄予厚望。6月1日一早,M3正式发布…

作者头像 李华