准备
插入 M.2 硬盘后,打开电源,检查硬盘是否被系统识别
显示信息,发现有设备 nvme0n1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS loop0 7:0 0 63.9M 1 loop /snap/core20/2318 loop1 7:1 0 64M 1 loop /snap/core20/2379 loop2 7:2 0 87M 1 loop /snap/lxd/27037 loop3 7:3 0 87M 1 loop /snap/lxd/29351 loop4 7:4 0 40.4M 1 loop /snap/snapd/20671 loop5 7:5 0 38.8M 1 loop /snap/snapd/21759 sda 8:0 0 465.8G 0 disk ├─sda1 8:1 0 1G 0 part /boot/efi ├─sda2 8:2 0 2G 0 part └─sda3 8:3 0 462.7G 0 part ├─ubuntu--vg-lv--0 253:0 0 32G 0 lvm [SWAP] ├─ubuntu--vg-lv--1 253:1 0 1G 0 lvm /boot └─ubuntu--vg-lv--2 253:2 0 429.7G 0 lvm / nvme0n1 259:0 0 1.8T 0 disk
|
获取新硬盘完整路径
显示信息
1 2 3 4 5
| Disk /dev/nvme0n1: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors Disk model: Samsung SSD 990 PRO 2TB Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
|
新硬盘格式化为 ext4
1
| sudo mkfs -t ext4 /dev/nvme0n1
|
输出信息
1 2 3 4 5 6 7 8 9 10 11 12 13
| mke2fs 1.46.5 (30-Dec-2021) Discarding device blocks: done Creating filesystem with 488378646 4k blocks and 122101760 inodes Filesystem UUID: b51468a6-ed06-47e1-9173-9975da25a197 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 102400000, 214990848
Allocating group tables: done Writing inode tables: done Creating journal (262144 blocks): done Writing superblocks and filesystem accounting information: done
|
尝试挂载
尝试挂载硬盘到目录 /mnt/disk.m2
新建目录
挂载命令
1
| sudo mount -t ext4 /dev/nvme0n1 /mnt/disk.m2
|
检查挂载
在输出信息中找到 /dev/nvme0n1 相关信息
1
| /dev/nvme0n1 on /mnt/disk.m2 type ext4 (rw,relatime)
|
取消挂载
1
| sudo umount /mnt/disk.m2
|
配置自动挂载
在文件末尾新增配置
1 2
| /dev/nvme0n1 /mnt/disk.m2 ext4 defaults 0 2
|