ubuntu新增磁盘扩展LV卷
登录平台
login as: wqbboy
wqbboy@172.17.2.86's password:
Welcome to Ubuntu 22.04.5 LTS (GNU/Linux 5.15.0-153-generic x86_64)* Documentation: https://help.ubuntu.com* Management: https://landscape.canonical.com* Support: https://ubuntu.com/proSystem information as of Tue Sep 9 02:55:55 AM UTC 2025System load: 1.36 Processes: 198Usage of /: 63.6% of 23.16GB Users logged in: 0Memory usage: 53% IPv4 address for enp0s3: 172.17.2.86Swap usage: 0%* Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8sjust raised the bar for easy, resilient and secure K8s cluster deployment.https://ubuntu.com/engage/secure-kubernetes-at-the-edgeExpanded Security Maintenance for Applications is not enabled.54 updates can be applied immediately.
To see these additional updates run: apt list --upgradableEnable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro statusNew release '24.04.3 LTS' available.
Run 'do-release-upgrade' to upgrade to it.Last login: Tue Sep 9 02:55:56 2025
wqbboy@mail:~$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 392M 1.2M 390M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 24G 15G 7.3G 68% /
tmpfs 2.0G 316K 2.0G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 2.0G 130M 1.7G 8% /boot
tmpfs 392M 4.0K 392M 1% /run/user/1000
查看内存、磁盘
wqbboy@mail:~$ free -mtotal used free shared buff/cache available
Mem: 3911 2059 786 5 1065 1617
Swap: 3910 0 3910
wqbboy@mail:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 87M 1 loop /snap/lxd/29351
loop1 7:1 0 63.9M 1 loop /snap/core20/2318
loop2 7:2 0 89.4M 1 loop /snap/lxd/31333
loop3 7:3 0 63.8M 1 loop /snap/core20/2599
loop4 7:4 0 38.8M 1 loop /snap/snapd/21759
loop5 7:5 0 50.8M 1 loop /snap/snapd/25202
sda 8:0 0 25.7G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 2G 0 part /boot
└─sda3 8:3 0 23.7G 0 part└─ubuntu--vg-ubuntu--lv 253:0 0 23.7G 0 lvm /
sdb 8:16 0 62.5G 0 disk
sr0 11:0 1 1024M 0 rom
新增磁盘,创建PV
wqbboy@mail:~$ sudo pvcreate /dev/sdb
[sudo] password for wqbboy:Physical volume "/dev/sdb" successfully created.
wqbboy@mail:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 87M 1 loop /snap/lxd/29351
loop1 7:1 0 63.9M 1 loop /snap/core20/2318
loop2 7:2 0 89.4M 1 loop /snap/lxd/31333
loop3 7:3 0 63.8M 1 loop /snap/core20/2599
loop4 7:4 0 38.8M 1 loop /snap/snapd/21759
loop5 7:5 0 50.8M 1 loop /snap/snapd/25202
sda 8:0 0 25.7G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 2G 0 part /boot
└─sda3 8:3 0 23.7G 0 part└─ubuntu--vg-ubuntu--lv 253:0 0 23.7G 0 lvm /
sdb 8:16 0 62.5G 0 disk
sr0 11:0 1 1024M 0 rom
扩展vg
wqbboy@mail:~$ sudo vgextend ubuntu-vg /dev/sdbVolume group "ubuntu-vg" successfully extended
wqbboy@mail:~$ sudo vg
sudo: vg: command not found
wqbboy@mail:~$ sudo vgdisplay--- Volume group ---VG Name ubuntu-vgSystem IDFormat lvm2Metadata Areas 2Metadata Sequence No 3VG Access read/writeVG Status resizableMAX LV 0Cur LV 1Open LV 1Max PV 0Cur PV 2Act PV 2VG Size 86.15 GiBPE Size 4.00 MiBTotal PE 22055Alloc PE / Size 6066 / <23.70 GiBFree PE / Size 15989 / <62.46 GiBVG UUID xtkRsn-Oe4t-ue9p-b79w-wAN0-jyb6-YruPju
扩展LV全部空间
wqbboy@mail:~$ sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lvSize of logical volume ubuntu-vg/ubuntu-lv changed from <23.70 GiB (6066 extents) to 86.15 GiB (22055 extents).Logical volume ubuntu-vg/ubuntu-lv successfully resized.
wqbboy@mail:~$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 392M 1.2M 390M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 24G 15G 7.3G 68% /
tmpfs 2.0G 320K 2.0G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 2.0G 130M 1.7G 8% /boot
tmpfs 392M 4.0K 392M 1% /run/user/1000
wqbboy@mail:~$ sudo lvdisplay--- Logical volume ---LV Path /dev/ubuntu-vg/ubuntu-lvLV Name ubuntu-lvVG Name ubuntu-vgLV UUID SV4Jlf-XwHf-DrsR-RwLr-buep-Tt6X-aKSaQQLV Write Access read/writeLV Creation host, time ubuntu-server, 2025-09-06 23:41:51 +0000LV Status available# open 1LV Size 86.15 GiBCurrent LE 22055Segments 2Allocation inheritRead ahead sectors auto- currently set to 256Block device 253:0wqbboy@mail:~$ sudo vgdisplay--- Volume group ---VG Name ubuntu-vgSystem IDFormat lvm2Metadata Areas 2Metadata Sequence No 4VG Access read/writeVG Status resizableMAX LV 0Cur LV 1Open LV 1Max PV 0Cur PV 2Act PV 2VG Size 86.15 GiBPE Size 4.00 MiBTotal PE 22055Alloc PE / Size 22055 / 86.15 GiBFree PE / Size 0 / 0VG UUID xtkRsn-Oe4t-ue9p-b79w-wAN0-jyb6-YruPjuwqbboy@mail:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 87M 1 loop /snap/lxd/29351
loop1 7:1 0 63.9M 1 loop /snap/core20/2318
loop2 7:2 0 89.4M 1 loop /snap/lxd/31333
loop3 7:3 0 63.8M 1 loop /snap/core20/2599
loop4 7:4 0 38.8M 1 loop /snap/snapd/21759
loop5 7:5 0 50.8M 1 loop /snap/snapd/25202
sda 8:0 0 25.7G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 2G 0 part /boot
└─sda3 8:3 0 23.7G 0 part└─ubuntu--vg-ubuntu--lv 253:0 0 86.2G 0 lvm /
sdb 8:16 0 62.5G 0 disk
└─ubuntu--vg-ubuntu--lv 253:0 0 86.2G 0 lvm /
sr0 11:0 1 1024M 0 rom
刷新LV卷
wqbboy@mail:~$ sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 11
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 22584320 (4k) blocks long.wqbboy@mail:~$ sudo vgdisplay--- Volume group ---VG Name ubuntu-vgSystem IDFormat lvm2Metadata Areas 2Metadata Sequence No 4VG Access read/writeVG Status resizableMAX LV 0Cur LV 1Open LV 1Max PV 0Cur PV 2Act PV 2VG Size 86.15 GiBPE Size 4.00 MiBTotal PE 22055Alloc PE / Size 22055 / 86.15 GiBFree PE / Size 0 / 0VG UUID xtkRsn-Oe4t-ue9p-b79w-wAN0-jyb6-YruPjuwqbboy@mail:~$ sudo lvdisplay--- Logical volume ---LV Path /dev/ubuntu-vg/ubuntu-lvLV Name ubuntu-lvVG Name ubuntu-vgLV UUID SV4Jlf-XwHf-DrsR-RwLr-buep-Tt6X-aKSaQQLV Write Access read/writeLV Creation host, time ubuntu-server, 2025-09-06 23:41:51 +0000LV Status available# open 1LV Size 86.15 GiBCurrent LE 22055Segments 2Allocation inheritRead ahead sectors auto- currently set to 256Block device 253:0
查看空间
wqbboy@mail:~$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 392M 1.2M 390M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 85G 15G 67G 19% /
tmpfs 2.0G 320K 2.0G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 2.0G 130M 1.7G 8% /boot
tmpfs 392M 4.0K 392M 1% /run/user/1000
wqbboy@mail:~$
防火墙设置
curl: (35) OpenSSL SSL_connect: Connection reset by peer in connection to download.docker.com:443
解决办法
sudo ufw allow 443/tcp