Linux挂载移动硬盘或U盘

0x00前言

  挂载的含义:Linux系统把所有的设备都视为文件,不同的设备文件在根目录(树的根)开始的某个路径之下(树枝),所以要使用设备需要将其指定在特定的路径之下(就像挂载某一树枝上)所以叫挂载。Linux直接插上移动硬盘或U盘是无法使用的,接着我们就自己挂载使用吧。

0x01小白最简单的使用方式

  1. fdisk -l 查看得到自己要挂载的设备名字
    注:linux下移动硬盘和U盘的文件名都是/dev/sd[a-p]
    查看设备名
    可以看到我的移动硬盘有4个分区(其中system字段值为“W95 Ext’d (LBA)”的是移动硬盘的逻辑分区),然后确定(根据容量或者顺序)我要挂载的设备名/dev/sdb5/
  2. mount 设备名 挂载路径名
    mount /dev/sdb5/ ./data/
    注:路径可以是绝对路径 /home/data/,也可以是相对路径 ./data/

  3. 检查是否成功
    cd ./data/
    ls
    看到设备中的文件即挂载成功

0x02 mount命令

  在命令行输入:mount -h

The command is `mount [-t fstype] something somewhere'.
Details found in /etc/fstab may be omitted.
       mount -a [-t|-O] ...     : mount all stuff from /etc/fstab
       mount device             : mount device at the known place
       mount directory          : mount known device here
       mount -t type dev dir    : ordinary mount command
Note that one does not really mount a device, one mounts
a filesystem (of the given type) found on the device.
One can also mount an already visible directory tree elsewhere:
       mount --bind olddir newdir
or move a subtree:
       mount --move olddir newdir
One can change the type of mount containing the directory dir:
       mount --make-shared dir
       mount --make-slave dir
       mount --make-private dir
       mount --make-unbindable dir
One can change the type of all the mounts in a mount subtree
containing the directory dir:
       mount --make-rshared dir
       mount --make-rslave dir
       mount --make-rprivate dir
       mount --make-runbindable dir
A device can be given by name, say /dev/hda1 or /dev/cdrom,
or by label, using  -L label  or by uuid, using  -U uuid .
Other options: [-nfFrsvw] [-o options] [-p passwdfd].
For many more details, say  man 8 mount .