Ubuntu扩展根目录空间
Ubuntu扩展根目录空间
此文章为扩展磁盘空间
Ubuntu扩展磁盘空间
通过上面文章进行操作我们可以得到一个20G的sda4
df -h查看,可以看到根目录空间不足,而新扩展的sda4有20G
root@li:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 793M 1.6M 792M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 19G 15G 2.8G 85% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda4 20G 45M 19G 1% /home/all
/dev/sda2 976M 108M 801M 12% /boot
/dev/loop0 56M 56M 0 100% /snap/core18/2128
/dev/loop1 56M 56M 0 100% /snap/core18/2409
/dev/loop2 62M 62M 0 100% /snap/core20/1518
/dev/loop4 68M 68M 0 100% /snap/lxd/22753
/dev/loop3 71M 71M 0 100% /snap/lxd/21029
/dev/loop5 47M 47M 0 100% /snap/snapd/16010
/dev/loop6 47M 47M 0 100% /snap/snapd/16292
tmpfs 793M 0 793M 0% /run/user/0
所以将根目录空间扩展。
umount /dev/sda4
vgextend ubuntu-vg /dev/sda4
调用lvextend进行扩容,20G为我自己设的,根据各自情况来
lvextend -L +20G /dev/ubuntu-vg/ubuntu-lv /dev/sda4
使用lvdisplay, 发现lv空间已经增加
root@li:~# lvdisplay
--- Logical volume ---
LV Path /dev/ubuntu-vg/ubuntu-lv
LV Name ubuntu-lv
VG Name ubuntu-vg
LV UUID XYJs9M-cx52-QCdf-Jyea-367K-evC0-Vsk9NF
LV Write Access read/write
LV Creation host, time ubuntu-server, 2022-06-07 14:08:01 +0000
LV Status available
LV Size <39.00 GiB
Current LE 9983
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
使用df -h,发现根目录容量并未增加
root@li:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 793M 1.6M 792M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 19G 15G 2.7G 85% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda2 976M 108M 801M 12% /boot
/dev/loop1 56M 56M 0 100% /snap/core18/2409
/dev/loop2 62M 62M 0 100% /snap/core20/1518
/dev/loop4 68M 68M 0 100% /snap/lxd/22753
/dev/loop3 71M 71M 0 100% /snap/lxd/21029
/dev/loop5 47M 47M 0 100% /snap/snapd/16010
/dev/loop6 47M 47M 0 100% /snap/snapd/16292
tmpfs 793M 0 793M 0% /run/user/0
/dev/loop7 56M 56M 0 100% /snap/core18/2538
使用 resize2fs /dev/mapper/ubuntu–vg-ubuntu–lv 进行刷新
root@li:~# resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 5
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 10222592 (4k) blocks long.
使用df -h 再次查看,发现根目录容量已增加
root@li:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 793M 1.6M 792M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 39G 15G 22G 41% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda2 976M 108M 801M 12% /boot
/dev/loop1 56M 56M 0 100% /snap/core18/2409
/dev/loop2 62M 62M 0 100% /snap/core20/1518
/dev/loop4 68M 68M 0 100% /snap/lxd/22753
/dev/loop3 71M 71M 0 100% /snap/lxd/21029
/dev/loop5 47M 47M 0 100% /snap/snapd/16010
/dev/loop6 47M 47M 0 100% /snap/snapd/16292
tmpfs 793M 0 793M 0% /run/user/0
/dev/loop7 56M 56M 0 100% /snap/core18/2538
Ubuntu扩展根目录空间
https://blog.isle.ink//archives/ubuntu-kuo-zhan-gen-mu-lu-kong-jian