记录:Ubuntu 20.04.2 LTS 挂载新硬盘
1、使用 df -Th 查询硬盘目前使用情况
Filesystem Type Size Used Avail Use% Mounted on
udev devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs tmpfs 797M 676K 796M 1% /run
/dev/vda1 ext4 40G 3.6G 34G 10% /
tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
tmpfs tmpfs 797M 0 797M 0% /run/user/0
2、通过 fdisk -l 查看电脑的硬盘
Disk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 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: 0xc04c8785
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 83886046 83883999 40G 83 Linux
Disk /dev/vdb: 200 GiB, 214748364800 bytes, 419430400 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
也可以通过 lsblk -f 来查看
NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
vda
└─vda1 ext4 / 8b92483a-a5dd-44af-81f7-87713be4d51c 33.9G 9% /
vdb
/dev/vdb 就是要挂载的硬盘,这是一块空的硬盘,没有数据。
3、删除 /dev/vdb 的分区,输入 d,然后根据提示输入对应分区号就可以了。这是磁盘有数据的时候才需要这样操作,如果没有数据,是一块全新的硬盘,可以忽略这个步骤。(操作前,请备份好原有硬盘的数据)
4、用 mkfs.ext4 /dev/vdb 命令,将硬盘格式化为 ext4
mke2fs 1.45.5 (07-Jan-2020)
Found a dos partition table in /dev/vdb
Proceed anyway? (y,N) y
Creating filesystem with 52428800 4k blocks and 13107200 inodes
Filesystem UUID: a4d3a9d0-76a4-4001-9bd0-2f22628db9ce
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done
5、挂载格式化好的硬盘
mkdir /mnt/vdb
mount /dev/vdb /mnt/vdb
6、用 df -Th 命令查看已挂载的磁盘
Filesystem Type Size Used Avail Use% Mounted on
udev devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs tmpfs 797M 680K 796M 1% /run
/dev/vda1 ext4 40G 3.6G 34G 10% /
tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
tmpfs tmpfs 797M 0 797M 0% /run/user/0
/dev/vdb ext4 196G 61M 186G 1% /mnt/vdb
7、设置开机自动挂载 在 /etc/fstab 中追加 /dev/vdb /mnt/vdb ext4 defaults 0 0
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/vda1 during installation
UUID=8b92483a-a5dd-44af-81f7-87713be4d51c / ext4 errors=remount-ro 0 1
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0
/dev/vdb /mnt/vdb ext4 defaults 0 0