linux新建挂载目录命令,告诉你Ubuntu添加新分区并设置挂载点的方法及命令

最近在Ubuntu下做Android项目,可是解压根文件系统以后,就报警说硬盘不够。当初设置使用的大小为15G。不过扩展分区还是很方便的。当然首先你得设置添加使用的硬盘大小,这次我一下提高到了30G,看它还报警否。

一、创建新分区

首先查看已经有的分区:

root@ubuntu:/# fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes

255 heads, 63 sectors/track, 3916 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000e11ac

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1        1871    15021056   83  Linux

/dev/sda2            1871        1958      704513    5  Extended

/dev/sda5            1871        1958      704512   82  Linux swap / Solaris

root@ubuntu:/#

从上面的信息看出/dev/sda1、/dev/sda2两个主分区,那么大家可以创建一个/dev/sda3

root@ubuntu:/# fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

switch off the mode (command 'c') and change display units to

sectors (command 'u').

Command (m for help):

m for help就看的出,输入 m 为帮助;

Command action

a   toggle a bootable flag

b   edit bsd disklabel

c   toggle the dos compatibility flag

d   delete a partition

l   list known partition types

m   print this menu

n   add a new partition

o   create a new empty DOS partition table

p   print the partition table

q   quit without saving changes

s   create a new empty Sun disklabel

t   change a partition's system id

u   change display/entry units

v   verify the partition table

w   write table to disk and exit

x   extra functionality (experts only)

Command (m for help):

从上面信息知道,n 为添加分区,即新建分区;w 为保存。

Command (m for help): n

Command action

l   logical (5 or over)

p   primary partition (1-4)

创建逻辑分区还是主分区,这里输入 p 创建主分区。

一旦出现:

Selected partition 4

No free sectors available

表示没有空闲硬盘,这时你得手动在虚拟机上添加。

接着按默认数据输入,最后记得输入 w 保存。q为退出。

二、格式化新建分区并设置挂载点

格式化:

root@Ubuntu:/# mkfs.ext4 /dev/sda3

创建挂载点:

root@ubuntu:/# mount -t ext4 /dev/sda3 /home/work

把新建的分区挂载到/home/work目录,/home/work目录大小就为自己先添加的硬盘大小。

这时你就可以查看到home/work里面有个lost+found目录。

三、让系统开机自动挂载

只要在/etc/fstab中添加一行,做过根文件系统的应该知道:

/dev/sda3       /home/work  ext4    defaults    1   0

重启下就可以见效了。

查看使用情况:

root@ubuntu:/# df

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda1             14784996   5147264   8886680  37% /

none                    248640       208    248432   1% /dev

none                    254244       248    253996   1% /dev/shm

none                    254244       384    253860   1% /var/run

none                    254244         0    254244   0% /var/lock

/dev/sda3             15480852   8684096   6010376  60% /home/work

root@ubuntu:/#

当然在/home/work目录,我已经添加了很多东西。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值