ubuntu磁盘挂载

前言:如果你系统有一个磁盘(比如在左侧菜单栏有以下图标)单独用来放代码,在home目录下如果想要像操作一个磁盘那样简单,可以使用以下的方法

1.参看磁盘的信息:df -h

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7.8G  4.0K  7.8G   1% /dev
tmpfs           1.6G  1.5M  1.6G   1% /run
/dev/sda7        46G   27G   18G  61% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none            7.9G  224M  7.6G   3% /run/shm
none            100M   84K  100M   1% /run/user
/dev/sda6       830G  293G  496G  38% /media/zjh/c4b953ff-d44d-454f-b409-26b0d5610e06

可以看到最后一个盘是另外分出来的盘

2.使用dlkid命令来查看UUID信息

$ sudo dlkid

/dev/sda5: UUID="35446084-cb8b-427c-b7a9-be3998e61e18" TYPE="swap"
/dev/sda6: UUID="c4b953ff-d44d-454f-b409-26b0d5610e06" TYPE="ext4"
/dev/sda7: UUID="cf35bde6-43f2-4a80-80b9-24497bc1982b" TYPE="ext4" 

这里能得到/dev/sda6的UUID

3.创建一空目录

$mkdir code

4.编辑/etc/fstab文件

# 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).
#
#                
# / was on /dev/sda7 during installation
UUID=cf35bde6-43f2-4a80-80b9-24497bc1982b /               ext4    errors=remount-ro 0       1
UUID=c4b953ff-d44d-454f-b409-26b0d5610e06 /home/xxx/code               ext4    errors=remount-ro 0       1       
# swap was on /dev/sda5 during installation
UUID=35446084-cb8b-427c-b7a9-be3998e61e18 none            swap    sw              0       0

添加上面加黑的一行,把/etc/sda6挂载到/home/xxx/code目录下,这里的xxx是你自己的目录,挂载目录必须是空目录

5.#mount -a

这样的话就把那个磁盘挂载过来了。
关注微信公众号,定期为你推荐移动开发相关文章。


ubuntu磁盘挂载_第1张图片
songwenju

你可能感兴趣的:(ubuntu磁盘挂载)