ubuntu 22.04 扩容LVM空间

扩容磁盘命令记录

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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.

创建分区

1
2
3
pvcreate -ff -y /dev/sdb1
vgextend ubuntu-vg /dev/sdb1
# 注意ubuntu-vg,是通过vgdisplay查看,才知道的,要具体看环境

image.png

扩容命令 ubuntu-lv 的逻辑空间才能真正生效

1
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

这个时候其实只是逻辑分区生效 接下来还要对分区进行直接生效

1
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv

注意上个命令,才是生效了,df -h 才能看到磁盘扩大了。

Licensed under CC BY-NC-SA 4.0
最后更新于 Jan 06, 2025 05:52 UTC
comments powered by Disqus
Built with Hugo
主题 StackJimmy 设计
Caret Up