ubuntu 16.04添加新的分区

当我们在使用ubuntu过程中,会出现磁盘满了,这个时候如果你还有没有用的空间的话,可以尝试挂载一个新的分区。

我的分区操作为:

➜ sudo fdisk /dev/sdb
sudo: unable to resolve host eric-ms-7a54

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): m

Help:

  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag

  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table


Command (m for help): n
Partition type
   p   primary (1 primary, 1 extended, 2 free)
   l   logical (numbered from 5)
Select (default p): p
Partition number (3,4, default 3): 
First sector (1172658176-1953525167, default 1172658176): 
Last sector, +sectors or +size{K,M,G,T,P} (1172658176-1953525167, default 1953525167): 

Created a new partition 3 of type 'Linux' and of size 372.4 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy

The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).

➜  sudo fdisk -l      
sudo: unable to resolve host eric-ms-7a54
Disk /dev/loop0: 89.5 MiB, 93818880 bytes, 183240 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop1: 89.5 MiB, 93835264 bytes, 183272 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop2: 88.2 MiB, 92483584 bytes, 180632 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sda: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xfc3652c5

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1  *         4096 312123391 312119296 148.9G  7 HPFS/NTFS/exFAT
/dev/sda2       312123392 500113407 187990016  89.7G  7 HPFS/NTFS/exFAT


Disk /dev/sdb: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x75be86f6

Device     Boot      Start        End    Sectors   Size Id Type
/dev/sdb1  *          2046     782335     780290   381M  5 Extended
/dev/sdb2           782336 1172658175 1171875840 558.8G 83 Linux
/dev/sdb3       1172658176 1953525167  780866992 372.4G 83 Linux
/dev/sdb5             2048     782335     780288   381M 83 Linux

Partition 1 does not start on physical sector boundary.
Partition table entries are not in disk order.

这个时候需要重启一下,重启之后:

➜  ~ sudo mkfs.ext4 /dev/sdb3 
sudo: unable to resolve host eric-ms-7a54
[sudo] password for eric: 
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 97608374 4k blocks and 24403968 inodes
Filesystem UUID: d9025617-7c7c-4557-91c8-e98de7bed874
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968

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

➜  ~ mount -t ext4 /dev/sdb3 /home/eric/data 
mount: only root can use "--types" option
➜  ~ sudo mount -t ext4 /dev/sdb3 /home/data     
sudo: unable to resolve host eric-ms-7a54
mount: mount point /home/data does not exist
➜  ~ sudo mount -t ext4 /dev/sdb3 /home/eric/data 
sudo: unable to resolve host eric-ms-7a54
➜  ~ df -h 
Filesystem      Size  Used Avail Use% Mounted on
udev             16G     0   16G   0% /dev
tmpfs           3.2G  9.7M  3.2G   1% /run
/dev/sdb2       550G  516G  6.6G  99% /
tmpfs            16G   30M   16G   1% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs            16G     0   16G   0% /sys/fs/cgroup
/dev/loop0       90M   90M     0 100% /snap/core/6130
/dev/loop1       90M   90M     0 100% /snap/core/6034
/dev/loop2       89M   89M     0 100% /snap/core/5897
/dev/sdb5       361M  232M  107M  69% /boot
tmpfs           3.2G   52K  3.2G   1% /run/user/1000
/dev/sr0        5.9M  5.9M     0 100% /media/eric/FAST
/dev/sdb3       367G   67M  348G   1% /home/eric/data

然后sdb3就挂载到我创建的/home/eric/data目录了哈

设置开机自动挂载:

vim /etc/fstab
/dev/sdb3       /home/eric/data  ext4    defaults    1   0

按esc :wq保存退出,本人测试,重启没啥问题

参考文献

[1]. WARNING: Re-reading the partition table failed with error 16: Device or resource busy.https://blog.csdn.net/yusiguyuan/article/details/25396123

[2].Ubuntu添加新分区. https://www.cnblogs.com/liqw/p/3348484.html

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

农民小飞侠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值