Ubuntu将新增磁盘挂载到home下

home磁盘空间不足,其他闲置硬盘是原来windows的,不能直接使用(磁盘格式及权限等原因),比如编译安卓源码等。

这样的话就需要将新的磁盘格式化成fat32后挂载到/home下的一个目录,这样就可以方便使用啦。

具体步骤如下:

1.格式化磁盘:

a.使用命令:

sudo mkfs -t ext3 /dev/sdb1

如果执行后开始出现进度就是正在执行,需要等待,是需要时间的。

最后显示如下:

mke2fs 1.41.14 (22-Dec-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
12804096 inodes, 51199147 blocks
2559957 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
1563 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

 就表明成功了。

b.sdb1是用df命令查看出的,列出了已挂载的设备列表。

如果执行a的时候出现如下提示:

mke2fs 1.41.14 (22-Dec-2010)
/dev/sdb1 is mounted; will not make a filesystem here!

 说明这个磁盘已挂载需要取消挂载:

执行命令:

sudo umount /dev/sdb1

注意:是umount,不是unmount !

执行完这个命令后再执行a即可。

c.不能直接将磁盘挂载到home下,只能先挂载到mnt下:

执行命令挂载到/mnt下:

sudo mkdir -p /mnt/dir
这个命令是在/mnt下新建一个名为dir的目录,这个目录名当然你可以随便取。

然后:

sudo gedit /etc/fstab
这个命令打开fstab文件,在里面添加一行如下:

/dev/sdax /mnt/dir  ext3  relatime    0  2
sudo mount -a
这个命令使挂载生效。

然后执行命令打开文件权限:

sudo chmod 777 -R /mnt/dir
 
 ln -s /mnt/dir ~/dir
这个是把/mnt/dir建一个软链接到主目录下的dir目录上
以后你只要在主目录下打开dir也就直接访问到了/mnt/dir了。

ok,现在进入你的home下的dir目录为所欲为吧,哈哈。

猜你喜欢

转载自dingran.iteye.com/blog/1626642