挂载

用mount命令

1
2
3
sudo mount /dev/sda3 /mnt/sda3
sudo mount /dev/sda4 /mnt/sda4
sudo mount /dev/sda5 /mnt/sda5

查看设备挂载情况也可以用mount,但是用lsblk更直观

1
lsblk

使用blkid命令可以查看分区的UUID

1
blkid /dev/sda3

开机自动挂载,修改/etc/fstab

1
2
3
4
5
LABEL=writable  /       ext4    discard,x-systemd.growfs        0       1
LABEL=system-boot /boot/firmware vfat defaults 0 1
UUID=00082550000E6F29 /mnt/sda3 ntfs defaults 0 2
UUID=000B92D500017040 /mnt/sda4 ntfs defaults 0 2
UUID=000D948D00089BC1 /mnt/sda5 ntfs defaults 0 2

磁盘使用情况

1
df -h

卸载

1
2
umount /dev/sda3
umount /mnt/sda3

分区

fdisk命令,生产环境下可以做一个自动化脚本来进行分区

1
2
fdisk -l # 查看磁盘分区列表
sudo fdisk /dev/sdb # 对sdb磁盘进行分区

fdisk命令行指令用法:一般d、l、w、q、n这几个命令用得比较多,以下是帮助菜单内容(按m进入)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Help:

DOS (MBR)
a toggle a bootable flag
b edit nested BSD disklabel
c toggle the dos compatibility flag

Generic
d delete a partition
F list free unpartitioned space
l list known partition types (列出分区类型)
n add a new partition (新建一个分区)
p print the partition table (打印分区表)
t change a partition type
v verify the partition table
i print information about a partition

Misc
m print this menu
u change display/entry units
x extra functionality (experts only)

Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file

Save & Exit
w write table to disk and exit (保存磁盘的分区更改)
q quit without saving changes (退出fdisk)

Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table

格式化

mkfs命令支持多种文件系统格式

1
2
3
4
5
6
7
8
9
10
11
12
13
mkfs.bfs     
mkfs.btrfs
mkfs.cramfs
mkfs.ext2
mkfs.ext3
mkfs.ext4
mkfs.fat
mkfs.jffs2
mkfs.minix
mkfs.msdos
mkfs.ntfs
mkfs.ubifs
mkfs.vfat

以ext4格式为例

image-20260119140119043

修复

fsck命令族

1
2
3
4
5
6
7
8
9
10
fsck         
fsck.btrfs
fsck.cramfs
fsck.ext2
fsck.ext3
fsck.ext4
fsck.fat
fsck.minix
fsck.msdos
fsck.vfat

以ext4格式为例

image-20260119140300990


下里巴人
海纳百川,文以载道
hywing技术自留地
总访问 113701 次 | 本页访问 326