欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 房产 > 家装 > 解决 Linux /dev/mapper/ubuntu--vg-ubuntu--lv 磁盘空间不足的问题

解决 Linux /dev/mapper/ubuntu--vg-ubuntu--lv 磁盘空间不足的问题

2025/3/17 3:19:48 来源:https://blog.csdn.net/wowocpp/article/details/146204540  浏览:    关键词:解决 Linux /dev/mapper/ubuntu--vg-ubuntu--lv 磁盘空间不足的问题

解决 Linux /dev/mapper/ubuntu–vg-ubuntu–lv 磁盘空间不足的问题
https://blog.csdn.net/weixin_47908992/article/details/139882219

查看LVM卷组的信息
vgdisplay

root@ubuntu:~# vgdisplay--- Volume group ---VG Name               ubuntu-vgSystem ID             Format                lvm2Metadata Areas        1Metadata Sequence No  2VG Access             read/writeVG Status             resizableMAX LV                0Cur LV                1Open LV               1Max PV                0Cur PV                1Act PV                1VG Size               <19.00 GiBPE Size               4.00 MiBTotal PE              4863Alloc PE / Size       1024 / 4.00 GiBFree  PE / Size       3839 / <15.00 GiBVG UUID               hZPoxm-kSBU-fmKs-2yXD-hHoe-3T7e-PCIFSe
Free PE / Size 3839 / <15.00 GiB,这是还可以扩充的大小

使用命令进行磁盘扩容

lvextend -L 10G /dev/mapper/ubuntu--vg-ubuntu--lv      //增大或减小至19G
lvextend -L +15G /dev/mapper/ubuntu--vg-ubuntu--lv     //增加10G
lvreduce -L -10G /dev/mapper/ubuntu--vg-ubuntu--lv     //减小10G
lvresize -l  +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv   //按百分比扩容resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv            //重新调整逻辑卷大小

具体操作如下
// 按百分比进行磁盘扩容

root@ubuntu:~# lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lvSize of logical volume ubuntu-vg/ubuntu-lv changed from 4.00 GiB (1024 extents) to <19.00 GiB (4863 extents).Logical volume ubuntu-vg/ubuntu-lv successfully resized.

// 刷新分区

root@ubuntu:~# resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv 
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 3
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 4979712 (4k) blocks long.

// 查看文件系统磁盘空间的使用情况(发现此时已经扩容到19G)

root@ubuntu:~# df -h
Filesystem                         Size  Used Avail Use% Mounted on
udev                               451M     0  451M   0% /dev
tmpfs                               97M  1.3M   96M   2% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   19G  3.9G   14G  22% /
tmpfs                              482M     0  482M   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                              482M     0  482M   0% /sys/fs/cgroup
/dev/loop0                          92M   92M     0 100% /snap/core/8689
/dev/loop1                          90M   90M     0 100% /snap/core/8268
/dev/sda2                          976M   77M  832M   9% /boot
tmpfs                               97M     0   97M   0% /run/user/0

// 再次查看LVM卷组的信息(可扩容的空间已经成为0)

root@ubuntu:~# vgdisplay--- Volume group ---VG Name               ubuntu-vgSystem ID             Format                lvm2Metadata Areas        1Metadata Sequence No  4VG Access             read/writeVG Status             resizableMAX LV                0Cur LV                1Open LV               1Max PV                0Cur PV                1Act PV                1VG Size               <19.00 GiBPE Size               4.00 MiBTotal PE              4863Alloc PE / Size       4863 / <19.00 GiBFree  PE / Size       0 / 0   VG UUID               hZPoxm-kSBU-fmKs-2yXD-hHoe-3T7e-PCIFSe

涉及的操作命令简单介绍:

查看块设备的信息 【-f】:显示每个块设备的文件系统类型(如ext4、NTFS、FAT32等)以及文件系统的标签(如果有)。

root@ubuntu:/home/michael# lsblk -f
NAME FSTYPE FSVER LABEL UUID                                   FSAVAIL FSUSE% MOUNTPOINTS
loop0squash 4.0                                                      0   100% /snap/chromium/2497
loop1squash 4.0                                                      0   100% /snap/chromium/2529
loop2squash 4.0                                                      0   100% /snap/core20/1950
loop3squash 4.0                                                      0   100% /snap/core20/1974
loop4squash 4.0                                                      0   100% /snap/core22/806
loop5squash 4.0                                                      0   100% /snap/bare/5
loop6squash 4.0                                                      0   100% /snap/core22/817
loop7squash 4.0                                                      0   100% /snap/cups/974
loop8squash 4.0                                                      0   100% /snap/cups/980
loop9squash 4.0                                                      0   100% /snap/firefox/2908
loop10squash 4.0                                                      0   100% /snap/firefox/2850
loop11squash 4.0                                                      0   100% /snap/lxd/22753
loop12squash 4.0                                                      0   100% /snap/gnome-3-38-2004/140
loop13squash 4.0                                                      0   100% /snap/gtk-common-themes/1535
loop14squash 4.0                                                      0   100% /snap/gnome-3-38-2004/143
loop15squash 4.0                                                      0   100% /snap/snapd/19361
loop16squash 4.0                                                      0   100% /snap/lxd/24061
loop17squash 4.0                                                      0   100% /snap/snapd/19457
sda                                                                           
├─sda1
│    ext2   1.0         0c16e136-b08b-48e6-beb1-27379362182b    417.3M    37% /boot
├─sda2
│                                                                             
└─sda5LVM2_m LVM2        qjGstm-EyqI-EL1p-tm6H-TZkq-tQt2-0Asw5u                ├─ubuntu--vg-root│  ext4   1.0         02df78f3-9fac-45f6-a163-bc25f8477529     19.2G    79% /var/snap/firefox/common/host-hunspell│                                                                           /└─ubuntu--vg-swap_1swap   1           f1afd974-2f40-42f3-b9bc-a89da3b559d8                  [SWAP]
sr0                                                                           

显示物理卷的详细信息,包括物理卷的名称、大小、卷组、状态等。

root@ubuntu:/home/michael# pvdisplay --- Physical volume ---PV Name               /dev/sda5VG Name               ubuntu-vgPV Size               119.28 GiB / not usable 0   Allocatable           yes (but full)PE Size               4.00 MiBTotal PE              30536Free PE               0Allocated PE          30536PV UUID               qjGstm-EyqI-EL1p-tm6H-TZkq-tQt2-0Asw5u

显示卷组的详细信息,包括卷组的名称、物理卷数量、逻辑卷数量、总大小、空闲空间等。

root@ubuntu:/home/michael# vgdisplay --- Volume group ---VG Name               ubuntu-vgSystem ID             Format                lvm2Metadata Areas        1Metadata Sequence No  5VG Access             read/writeVG Status             resizableMAX LV                0Cur LV                2Open LV               2Max PV                0Cur PV                1Act PV                1VG Size               119.28 GiBPE Size               4.00 MiBTotal PE              30536Alloc PE / Size       30536 / 119.28 GiBFree  PE / Size       0 / 0   VG UUID               xwbdQH-DBvq-qdzk-DQ3H-ofgA-0Y4B-Sl3FwF

显示逻辑卷的详细信息,比如逻辑卷的名称、大小、路径、状态等。

root@ubuntu:/home/michael# lvdisplay --- Logical volume ---LV Path                /dev/ubuntu-vg/rootLV Name                rootVG Name                ubuntu-vgLV UUID                zIloDt-sa12-qqXk-7fKM-6Veu-09Pq-aedUBbLV Write Access        read/writeLV Creation host, time ubuntu, 2022-06-29 11:28:04 +0800LV Status              available# open                 1LV Size                <118.33 GiBCurrent LE             30292Segments               2Allocation             inheritRead ahead sectors     autocurrently set to     256
Block device           253:0--- Logical volume ---LV Path                /dev/ubuntu-vg/swap_1LV Name                swap_1VG Name                ubuntu-vgLV UUID                di3eEs-oTyG-4u4z-JlVF-2P7a-6ke0-x6tIqxLV Write Access        read/writeLV Creation host, time ubuntu, 2022-06-29 11:28:04 +0800LV Status              available# open                 2LV Size                976.00 MiBCurrent LE             244Segments               1Allocation             inheritRead ahead sectors     autocurrently set to     256
Block device           253:1

显示文件系统使用情况
【-h】:以易读的方式显示文件系统大小,将字节单位转换为更常见的千字节、兆字节和千兆字节。
【-T】:在输出中显示文件系统类型。

root@ubuntu:/home/michael# df -hT
Filesystem                  Type   Size  Used Avail Use% Mounted on
tmpfs                       tmpfs  791M  3.6M  787M   1% /run
/dev/mapper/ubuntu--vg-root ext4   117G   92G   20G  83% /
tmpfs                       tmpfs  3.9G     0  3.9G   0% /dev/shm
tmpfs                       tmpfs  5.0M  4.0K  5.0M   1% /run/lock
/dev/sda1                   ext2   719M  265M  418M  39% /boot
tmpfs                       tmpfs  791M  116K  791M   1% /run/user/1000

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词