心理

当前位置 /首页/完美生活/心理/列表

ubuntu创建分区出错

ubuntu创建分区出错

1、创建一块新的硬盘分区:

因为windows中D盘空间比较富裕,遂进入Windows将D盘压缩出50G的未分配空间。

进入Ubuntu,run “sudo fdisk -l” 查看当前硬盘分区情况, Linux filesystem 在/dev/sdb上。

sudo fdisk /dev/sdb

Command (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

分区号:因为已经有了1-7,这里默认为8,回车默认

会自动找到你压缩出的50G空间,接着按默认数据输入,最后记得输入 w 保存。q为退出。重启。

mkfs -t ext4 /dev/sdb8 将创建的分区格式化为ext4格式

2、挂载

在home中创建一个临时文件夹,这里命名为temp

sudo mount -t ext4 /dev/sdb8 /home/huo/temp

3、复制

sudo cp -ax /usr/* home/huo/temp 将/usr分区现有内容拷贝到分区

sudo umount /dev/sdb8 为了后面挂载/usr,再将sdb8卸载

4、替换

sudo mv /usr /

sudo mkdir /usr

因为/usr被重命名,所以sudo命令暂时失效,run“su”进入root用户

mount /dev/sdb8 /usr 将新的/usr挂载到sdb8

5、设置开机自动挂载

在/etc/fstab最后添加一行:

/dev/sdb8 /usr ext4 defaults 0 1

6、释放原来的/usr空间

reboot重启之后删除/

DONE.

TAG标签:分区 Ubuntu #