centos硬盘挂载踩坑

查看磁盘列表

方式一

fdisk -l

1
2
3
4
5
6
7
8
9
Disk /dev/sdd: 59.6 GiB, 64023257088 bytes, 125045424 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
Disklabel type: dos
Disk identifier: 0xcad4ebea

Device Boot Start End Sectors Size Id Type
/dev/sdd4 * 256 125045423 125045168 59.6G c W95 FAT32 (LBA)
  • 能看到当前机器上面的硬盘列表和硬盘分区等信息。

方式二

lsblk

创建挂载点

mkdir /data

  • /data 为计划要挂载到的目录文件夹,可以根据需求修改。

硬盘格式化与分区

进入磁盘管理

fdisk /dev/sdd

分区命令

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
DOS (MBR)
a toggle a bootable flag (设置可引导标记)
b edit nested BSD disklabel (编辑 bsd 磁盘标签)
c toggle the dos compatibility flag (设置 DOS 操作系统兼容标记)

Generic
d delete a partition (删除一个分区)
F list free unpartitioned space (列出空闲的未分区空间)
l list known partition types 显示已知的分区类型。82 为 Linux swap 分区,83 为 Linux 分区
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 (退出不保存)

Create a new label
g create a new empty GPT partition table (新建空白GPT分区表,这个应该就表明fdisk已经支持GPT,还需要进一步的认证。)
G create a new empty SGI (IRIX) partition table (新建空白IRIX分区表)
o create a new empty DOS partition table (新建空白DOS分区表)
s create a new empty Sun partition table (新建空白SUN磁盘标签)

挂载

临时挂载

mount /dev/sdd4 /data

  • 该方式为临时挂载方式,重启后挂载失效;

永久挂载

查看设备ID和磁盘格式

blkid /dev/sdd4

1
/dev/sdd4: UUID="cca1f7f8-c939-4d0b-a790-cb85f728dd13" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="cad4ebea-04"
  • 之前尝试用 /dev/sdd4 方式配置挂载失败

    挂载设置

    vim /etc/fstab

    1
    UUID=cca1f7f8-c939-4d0b-a790-cb85f728dd13 /data ext4    defaults        0 2
  • 末尾添加一行挂载信息;
Author: suce
Link: https://haoubox.cn/2021/09/11/centos硬盘挂载踩坑/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.