Device Start End Sectors Size Type /dev/sdb1 2048 18749325278 18749323231 8.7T Linux filesystem
大约有如上信息,根据分区大小等判断需要挂载的硬盘的位置。示例选择 /dev/sdb1。
2 创建挂载点并挂载
一般情况下,需要创建一个目录作为挂载点。
1
$ sudo mkdir /mnt/data
接下来,执行命令将硬盘挂载至挂载点,即可通过挂载点访问硬盘。
1
$ sudo mount /dev/sdb1 /mnt/data
卸载硬盘则使用 umount 命令。
1
$ sudo umount /mnt/data
umount 既可以卸载挂载点,也可以卸载设备,二者等效。
1
$ sudo umount /dev/sdb1
3 挂载点已有内容
对待挂载点已有内容的情况(如挂载至 /home),挂载会暂时将原内容隐藏,直到卸载挂载点。
4 自动挂载
可以通过配置 /etc/fstab 文件实现开机自动挂载。
选择自己喜欢的编辑器(如 vim)打开文件,内容类似:
1 2 3 4 5 6 7 8 9 10 11 12 13
$ sudo vim /etc/fstab # /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/sda2 during installation UUID=c3610f52-3ec7-46a2-9f1d-6cf49a3cf676 / ext4 errors=remount-ro 0 1 # /boot/efi was on /dev/sda1 during installation UUID=F14C-F088 /boot/efi vfat umask=0077 0 1 /swapfile none swap sw 0 0