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.