Skip to content

Instantly share code, notes, and snippets.

@lnthien97
Created November 11, 2024 06:42
Show Gist options
  • Save lnthien97/8873367ce70284a758f8e9f34470055f to your computer and use it in GitHub Desktop.
Save lnthien97/8873367ce70284a758f8e9f34470055f to your computer and use it in GitHub Desktop.
root@lab-182:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 79.9M 1 loop /snap/lxd/22923
loop1 7:1 0 61.9M 1 loop /snap/core20/1405
loop2 7:2 0 44.7M 1 loop /snap/snapd/15534
sda 8:0 0 30G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 1.8G 0 part /boot
└─sda3 8:3 0 14.2G 0 part
└─ubuntu--vg-ubuntu--lv 253:0 0 14.2G 0 lvm /
we extend ubuntu--vg-ubuntu--lv from 14GB to 30GB
parted /dev/sda
(parted) resizepart 3
(parted) -0
(parted) print
Number Start End Size File system Name Flags
1 1049kB 2097kB 1049kB bios_grub
2 2097kB 1881MB 1879MB ext4
3 1881MB 32.2GB 30.3GB
(parted) quit
root@lab-182:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 79.9M 1 loop /snap/lxd/22923
loop1 7:1 0 61.9M 1 loop /snap/core20/1405
loop2 7:2 0 44.7M 1 loop /snap/snapd/15534
sda 8:0 0 30G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 1.8G 0 part /boot
└─sda3 8:3 0 28.2G 0 part
└─ubuntu--vg-ubuntu--lv 253:0 0 14.2G 0 lvm /
root@lab-182:~# pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name ubuntu-vg
PV Size <14.25 GiB / not usable 0
Allocatable yes (but full)
...
pvresize /dev/sda3
Physical volume "/dev/sda3" changed
1 physical volume(s) resized or updated / 0 physical volume(s) not resized
root@lab-swift-storage-182:~# pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name ubuntu-vg
PV Size <28.25 GiB / not usable 16.50 KiB
Allocatable yes
...
root@lab-182:~# lvdisplay
--- Logical volume ---
LV Path /dev/ubuntu-vg/ubuntu-lv
LV Name ubuntu-lv
VG Name ubuntu-vg
LV UUID dWIdjn-daqk-fgN0-4lWH-YjlG-fYkm-N21HgN
LV Write Access read/write
LV Creation host, time ubuntu-server, 2023-12-20 02:41:40 +0000
LV Status available
# open 1
LV Size <14.25 GiB
...
root@lab-182:~# lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from <14.25 GiB (3647 extents) to <28.25 GiB (7231 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
root@lab-182:~# df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 393M 1.2M 392M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 14G 9.3G 4.0G 71% /
root@lab-182:~# 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 = 2, new_desc_blocks = 4
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 7404544 (4k) blocks long.
root@lab-182:~# df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 393M 1.2M 392M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 28G 9.4G 18G 36% /
--end--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment