首页 > 系统相关 >Ubuntu 22.04扩容LVM空间

Ubuntu 22.04扩容LVM空间

时间:2024-06-12 13:59:52浏览次数:23  
标签:run containerd Ubuntu 64M dev 22.04 ubuntu LVM shm

今天为了编译ThingsBoard的源代码,发现原来给虚拟机分配的40个G不够用了。于是乎在VMWare Workstation中扩容了40G的磁盘空间。但是此时lvm是不会自动扩容的,因此我们需要手动调整下卷的配置。

首先df -h检查发现挂载的空间的确没有变化

mrchip@ubuntu22:~$ df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              791M  2.5M  788M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   37G   35G     0 100% /
tmpfs                              3.9G     0  3.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/sda2                          2.0G  253M  1.6G  14% /boot
shm                                 64M     0   64M   0% /run/k3s/containerd/io.containerd.grpc.v1.cri/sandboxes/e80883038e918e14fc90c4519ecc708e642d079d7482ae9a0b78b456c0502ed3/shm
shm                                 64M     0   64M   0% /run/k3s/containerd/io.containerd.grpc.v1.cri/sandboxes/baca760e9d9316152da7adb633a6bb05ab76e6cbfe1267bea951f1b3a9038c05/shm
shm                                 64M     0   64M   0% /run/k3s/containerd/io.containerd.grpc.v1.cri/sandboxes/e8f65d1e3aa83c67c5c55ae5e2bce0b87e905477d0a7dc20ee6fc15a47d2a2eb/shm
shm                                 64M     0   64M   0% /run/k3s/containerd/io.containerd.grpc.v1.cri/sandboxes/1d091959988cd36e8f71b01572a2e37e341238d263627d8eb839798c4dec86d9/shm
tmpfs                              791M  4.0K  791M   1% /run/user/1000

然后运行lsblk发现磁盘的确变大了

NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
loop0                       7:0    0 48.6M  1 loop /snap/cmake/1390
loop1                       7:1    0 48.6M  1 loop /snap/cmake/1391
loop2                       7:2    0 63.9M  1 loop /snap/core20/2182
loop3                       7:3    0 63.9M  1 loop /snap/core20/2318
loop4                       7:4    0 66.2M  1 loop /snap/core24/405
loop5                       7:5    0 66.2M  1 loop /snap/core24/423
loop6                       7:6    0   87M  1 loop /snap/lxd/27948
loop7                       7:7    0 17.7M  1 loop /snap/helm/414
loop8                       7:8    0   87M  1 loop /snap/lxd/28373
loop9                       7:9    0 38.7M  1 loop /snap/snapd/21465
loop10                      7:10   0 38.8M  1 loop /snap/snapd/21759
sda                         8:0    0   80G  0 disk
├─sda1                      8:1    0    1M  0 part
├─sda2                      8:2    0    2G  0 part /boot
└─sda3                      8:3    0   38G  0 part
  └─ubuntu--vg-ubuntu--lv 253:0    0   37G  0 lvm  /
sr0                        11:0    1    2G  0 rom

接下来我们记录命令操作来扩容分区

1. 将新的空间新建一个磁盘分区

mrchip@ubuntu22:~$ sudo fdisk /dev/sda
[sudo] password for mrchip:

Welcome to fdisk (util-linux 2.37.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

GPT PMBR size mismatch (83886079 != 167772159) will be corrected by write.
This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.


Command (m for help): n
Partition number (4-128, default 4):
First sector (83884032-167772126, default 83884032):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (83884032-167772126, default 167772126):

Created a new partition 4 of type 'Linux filesystem' and of size 40 GiB.

Command (m for help): w
The partition table has been altered.
Syncing disks.

2. 将新建的分区sda4转换为PV并拓展ubuntu-vg这个卷组

mrchip@ubuntu22:~$ sudo pvcreate -ff -y /dev/sda4
  Physical volume "/dev/sda4" successfully created.
mrchip@ubuntu22:~$ sudo vgextend ubuntu-vg /dev/sda4
  Volume group "ubuntu-vg" successfully extended
mrchip@ubuntu22:~$ sudo vgdisplay
  --- Volume group ---
  VG Name               ubuntu-vg
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               77.99 GiB
  PE Size               4.00 MiB
  Total PE              19966
  Alloc PE / Size       9472 / 37.00 GiB
  Free  PE / Size       10494 / 40.99 GiB
  VG UUID               aa7Nif-O9wu-0AMo-pxFA-RTsq-v48M-MZ5EUm

3. 扩容ubuntu-lv这个逻辑空间

sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
  Size of logical volume ubuntu-vg/ubuntu-lv changed from 37.00 GiB (9472 extents) to 77.99 GiB (19966 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.
mrchip@ubuntu22:~$ df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              791M  2.5M  788M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   37G   35G     0 100% /
tmpfs                              3.9G     0  3.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/sda2                          2.0G  253M  1.6G  14% /boot
shm                                 64M     0   64M   0% /run/k3s/containerd/io.containerd.grpc.v1.cri/sandboxes/e80883038e918e14fc90c4519ecc708e642d079d7482ae9a0b78b456c0502ed3/shm
shm                                 64M     0   64M   0% /run/k3s/containerd/io.containerd.grpc.v1.cri/sandboxes/baca760e9d9316152da7adb633a6bb05ab76e6cbfe1267bea951f1b3a9038c05/shm
shm                                 64M     0   64M   0% /run/k3s/containerd/io.containerd.grpc.v1.cri/sandboxes/e8f65d1e3aa83c67c5c55ae5e2bce0b87e905477d0a7dc20ee6fc15a47d2a2eb/shm
shm                                 64M     0   64M   0% /run/k3s/containerd/io.containerd.grpc.v1.cri/sandboxes/1d091959988cd36e8f71b01572a2e37e341238d263627d8eb839798c4dec86d9/shm
tmpfs                              791M  4.0K  791M   1% /run/user/1000

4. 对lvm分区的大小进行拓展

mrchip@ubuntu22:~$ sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 5, new_desc_blocks = 10
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 20445184 (4k) blocks long.

mrchip@ubuntu22:~$ df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              791M  2.5M  788M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   77G   35G   39G  48% /
tmpfs                              3.9G     0  3.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/sda2                          2.0G  253M  1.6G  14% /boot
shm                                 64M     0   64M   0% /run/k3s/containerd/io.containerd.grpc.v1.cri/sandboxes/e80883038e918e14fc90c4519ecc708e642d079d7482ae9a0b78b456c0502ed3/shm
shm                                 64M     0   64M   0% /run/k3s/containerd/io.containerd.grpc.v1.cri/sandboxes/baca760e9d9316152da7adb633a6bb05ab76e6cbfe1267bea951f1b3a9038c05/shm
shm                                 64M     0   64M   0% /run/k3s/containerd/io.containerd.grpc.v1.cri/sandboxes/e8f65d1e3aa83c67c5c55ae5e2bce0b87e905477d0a7dc20ee6fc15a47d2a2eb/shm
shm                                 64M     0   64M   0% /run/k3s/containerd/io.containerd.grpc.v1.cri/sandboxes/1d091959988cd36e8f71b01572a2e37e341238d263627d8eb839798c4dec86d9/shm
tmpfs                              791M  4.0K  791M   1% /run/user/1000

参考链接

  1. Linux LVM分区扩容
  2. 虚拟机下ubuntu使用df命令查看磁盘空间小于实际空间(解决Linux /dev/mapper/ubuntu--vg-ubuntu--lv 磁盘空间不足)
  3. LVM 'Can’t open /dev/sdb1 exclusively. Mounted filesystem?' Problem

标签:run,containerd,Ubuntu,64M,dev,22.04,ubuntu,LVM,shm
From: https://www.cnblogs.com/mrchip/p/18243814

相关文章

  • 针对ubuntu系统,如何更改环境变量中的网络代理
    要更改Ubuntu系统中的网络代理环境变量,可以按照以下步骤操作:打开终端。可以使用快捷键Ctrl+Alt+T来打开终端。使用nano或vim等编辑器打开~/.bashrc文件。运行以下命令:nano~/.bashrc在文件末尾添加以下几行代码,以设置你的网络代理:#设置HTTP代理exporthttp_p......
  • Linux下的lvm镜像与快照
    lvm镜像(mirror)(1)划分三个PV,其中2个PV大小要一模一样Disk/dev/sdb:21.5GB,21474836480bytes255heads,63sectors/track,2610cylindersUnits=cylindersof16065*512=8225280bytesSectorsize(logical/physical):512bytes/512bytesI/Osize(m......
  • ubuntu24 安装
    地址:https://cdimage.ubuntu.com/ubuntu/releases/24.04/release/                  按回车看具体信息等待 仍然等待,我大概用时20分钟,出现以下画面回车返回,出现下下个画面按“rebootnow“ 之后可能有个fail的画......
  • 深度解读数据库引入LLVM技术后如何提升性能
    GaussDB作为企业级的数据库,经过了多年的技术发展,具备丰富的技术特性,使用LLVM技术后提升了系统的查询性能,使得开发者在OLAP和OLTP多场景中均受益。Hi,别急!让技术触达每一个角落,赋能更多的人,GaussTech第3期《LLVM技术在GaussDB等数据库中的应用》,不仅带来满满的技术干货,还推出【分......
  • ubuntu22.04搭建tftp服务
    通常情况下我们调试linux内核的时候是在我们的ubuntu主机上进行的,这里同样以ubuntu为例,沃恩调试好内核之后,需要将我们调试好的内核下载到我们的开发板上跑起来,通常情况下是我们的板子先启动uboot,然后uboot通过网络服务命令将我们主机上编译好的内核下载到我们的开发板山的DRAM......
  • Ubuntu22给boot加密码
    目录确保安装了必要的GRUB工具生成GRUB密码编辑GRUB配置文件更新GRUB配置确保安装了必要的GRUB工具rambo@test1:~$sudoaptupdaterambo@test1:~$sudoaptinstallgrub-common生成GRUB密码rambo@test1:~$grub-mkpasswd-pbkdf2输入密码:重新输入口令:您......
  • ubuntu配置中国科学技术大学镜像源
    mv/etc/apt/sources.list/etc/apt/sources.list.baksudovim/etc/apt/sources.listdebhttp://mirrors.ustc.edu.cn/ubuntu-ports/xenialmainmultiverserestricteduniversedebhttp://mirrors.ustc.edu.cn/ubuntu-ports/xenial-backportsmainmultiverserestric......
  • ubuntu 24 拓容硬盘
    命令磁盘信息root@k3s-master:/mnt#lsblkNAMEMAJ:MINRMSIZEROTYPEMOUNTPOINTSloop07:0074.2M1loop/snap/core22/1380loop17:10130.1M1loop/snap/docker/2915loop2......
  • Ubuntu 20.04 配置LI-Calib问题总结
    系统环境为ubuntu20.04+ros1noetic。在配置浙大开源标定工具Li_Calib时会遇到一些匪夷所思的小问题,下面做个简单总结。1.PCL报错这里是因为PCL1.10需要C++14或以上标准,而源码的cmakelist里设置的是c++11,因此需要在两处做修改,一处是/src/Li_Calib/CMakeLists.txt,一处是/s......
  • Ubuntu 24.04 LTS 安装配置 MySQL Community Server 8.4.0 LTS
    1安装 AptRepository​​​​​​​地址MySQL::DownloadMySQLAPTRepositorysudodpkg-imysql-apt-config_0.8.30-1_all.deb #安装mysql8.4ltssudoaptupdatesudoapt-getinstallmysql-server#修改mysqlroot密码策略 2查看版本test@test:~$my......