Ubuntu根分区扩容
Ubuntu在安装完系统后,发现根分区的可用空间和实际硬盘大小不一致。
我硬盘是119G,根分区只有57G
root@i3-5010u:~# fdisk -l /dev/sdb
Disk /dev/sdb: 119.24 GiB, 128035676160 bytes, 250069680 sectors
Disk model: TOSHIBA THNSNJ12
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: gpt
Disk identifier: 35B03760-1D46-4508-BEC5-E499FC7778FA
Device Start End Sectors Size Type
/dev/sdb1 2048 2203647 2201600 1G EFI System
/dev/sdb2 2203648 6397951 4194304 2G Linux filesystem
/dev/sdb3 6397952 250066943 243668992 116.2G Linux filesystem
root@i3-5010u:~# df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 783M 5.1M 778M 1% /run
efivarfs 128K 101K 23K 82% /sys/firmware/efi/efivars
/dev/mapper/ubuntu--vg-ubuntu--lv 57G 48G 6.6G 88% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sdb2 2.0G 270M 1.6G 15% /boot
/dev/sdb1 1.1G 6.2M 1.1G 1% /boot/efi
/dev/sda 458G 4.0G 431G 1% /data
tmpfs 783M 12K 783M 1% /run/user/0
查看lvm的信息,显示PV和VG里有58G没有被使用。
不知道Ubuntu为啥要保留这部分空间。
root@i3-5010u:~# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb3 ubuntu-vg lvm2 a-- <116.19g 58.09g
root@i3-5010u:~# vgs
VG #PV #LV #SN Attr VSize VFree
ubuntu-vg 1 1 0 wz--n- <116.19g 58.09g
root@i3-5010u:~# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
ubuntu-lv ubuntu-vg -wi-ao---- 58.09g
接下来把lv扩容
注意:操作有风险,建议备份数据
root@i3-5010u:~# lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from 58.09 GiB (14872 extents) to <116.19 GiB (29744 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
扩容系统分区
root@i3-5010u:~# resize2fs /dev/ubuntu-vg/ubuntu-lv
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 8, new_desc_blocks = 15
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 30457856 (4k) blocks long.
接下来在查看分区空间情况,这些就正常了。
root@i3-5010u:~# df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 783M 5.1M 778M 1% /run
efivarfs 128K 101K 23K 82% /sys/firmware/efi/efivars
/dev/mapper/ubuntu--vg-ubuntu--lv 115G 48G 62G 44% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sdb2 2.0G 270M 1.6G 15% /boot
/dev/sdb1 1.1G 6.2M 1.1G 1% /boot/efi
/dev/sda 458G 4.0G 431G 1% /data
tmpfs 783M 12K 783M 1% /run/user/0
CreateBy:2024-07-12T18:34:39+08:00,UpdateBy:2024-07-12T18:47:32+08:00
版权声明:署名-非商业性使用-禁止演绎 3.0 未本地化版本 (CC BY-NC-ND 3.0)
留言板开发中,站长邮箱:admin@aliencn.net。欢迎交流。