Ubuntu – How To Extend LVM partition

It is super complicated to fin how to resize a lvm partition when you have rtrfs volume.

But finally it is so simple. Check thiis:


ubuntu@ubuntu-L-64Bits:~$ ssh ubuntu@192.168.2.42
The authenticity of host '192.168.2.42 (192.168.2.42)' can't be established.
ED25519 key fingerprint is SHA256:OMCqKtur5D8CHsKchU1Xztu+yvWkVhk/xouQD9eijes.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.2.42' (ED25519) to the list of known hosts.
ubuntu@192.168.2.42's password:
Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 5.15.0-73-generic x86_64)
  • Documentation: https://help.ubuntu.com
  • Management: https://landscape.canonical.com
  • Support: https://ubuntu.com/advantage System information as of Mon Oct 16 01:46:28 PM UTC 2023 System load: 0.0 Processes: 249
    Usage of /: 58.0% of 244.04GB Users logged in: 1
    Memory usage: 20% IPv4 address for ens33: 192.168.2.42
    Swap usage: 0%
  • Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
    just raised the bar for easy, resilient and secure K8s cluster deployment. https://ubuntu.com/engage/secure-kubernetes-at-the-edge

Expanded Security Maintenance for Applications is not enabled.

42 updates can be applied immediately.
To see these additional updates run: apt list –upgradable

5 additional security updates can be applied with ESM Apps.
Learn more about enabling ESM Apps service at https://ubuntu.com/esm

*** System restart required ***
Last login: Thu Oct 5 22:10:18 2023 from 10.242.2.4
ubuntu@ubuntu-intranet:~$ sudo -s
[sudo] password for ubuntu:
root@ubuntu-intranet:/home/ubuntu# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 63.4M 1 loop /snap/core20/1974
loop1 7:1 0 63.5M 1 loop
loop2 7:2 0 91.8M 1 loop /snap/lxd/23991
loop3 7:3 0 91.8M 1 loop /snap/lxd/24061
loop5 7:5 0 53.3M 1 loop
loop6 7:6 0 40.9M 1 loop /snap/snapd/20290
loop7 7:7 0 63.5M 1 loop /snap/core20/2015
loop8 7:8 0 40.8M 1 loop /snap/snapd/20092
sda 8:0 0 750G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 1.5G 0 part /boot
└─sda3 8:3 0 248.5G 0 part
└─ubuntu–vg-ubuntu–lv 253:0 0 248.5G 0 lvm /
root@ubuntu-intranet:/home/ubuntu# growpart /dev/sda3
growpart disk partition
rewrite partition table so that partition takes up all the space it can
options:
-h | –help print Usage and exit
–fudge F if part could be resized, but change would be
less than ‘F’ bytes, do not resize (default: 1048576)
-N | –dry-run only report what would be done, show new ‘sfdisk -d’
-v | –verbose increase verbosity / debug
-u | –update R update the the kernel partition table info after growing
this requires kernel support and ‘partx –update’
R is one of:
– ‘auto’ : [default] update partition if possible
– ‘force’ : try despite sanity checks (fail on failure)
– ‘off’ : do not attempt
– ‘on’ : fail if sanity checks indicate no support

Example:
– growpart /dev/sda 1
Resize partition 1 on /dev/sda
must supply partition-number
root@ubuntu-intranet:/home/ubuntu# growpart /dev/sda 3
CHANGED: partition=3 start=3149824 old: size=521136128 end=524285952 new: size=1569714143 end=1572863967
root@ubuntu-intranet:/home/ubuntu# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 63.4M 1 loop /snap/core20/1974
loop1 7:1 0 63.5M 1 loop
loop2 7:2 0 91.8M 1 loop /snap/lxd/23991
loop3 7:3 0 91.8M 1 loop /snap/lxd/24061
loop5 7:5 0 53.3M 1 loop
loop6 7:6 0 40.9M 1 loop /snap/snapd/20290
loop7 7:7 0 63.5M 1 loop /snap/core20/2015
loop8 7:8 0 40.8M 1 loop /snap/snapd/20092
sda 8:0 0 750G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 1.5G 0 part /boot
└─sda3 8:3 0 748.5G 0 part
└─ubuntu–vg-ubuntu–lv 253:0 0 248.5G 0 lvm /
root@ubuntu-intranet:/home/ubuntu# df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 792M 1.7M 790M 1% /run
/dev/mapper/ubuntu–vg-ubuntu–lv 245G 142G 92G 61% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 1.5G 252M 1.2G 19% /boot
tmpfs 792M 4.0K 792M 1% /run/user/1000
root@ubuntu-intranet:/home/ubuntu# sudo lvextend -l +100%FREE /dev/mapper/ubuntu–vg-ubuntu–lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from <248.50 GiB (63615 extents) to <748.50 GiB (191615 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
root@ubuntu-intranet:/home/ubuntu# df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 792M 1.7M 790M 1% /run
/dev/mapper/ubuntu–vg-ubuntu–lv 245G 142G 92G 61% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 1.5G 252M 1.2G 19% /boot
tmpfs 792M 4.0K 792M 1% /run/user/1000
root@ubuntu-intranet:/home/ubuntu# 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 = 32, new_desc_blocks = 94
The filesystem on /dev/mapper/ubuntu–vg-ubuntu–lv is now 196213760 (4k) blocks long.

root@ubuntu-intranet:/home/ubuntu# df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 792M 1.7M 790M 1% /run
/dev/mapper/ubuntu–vg-ubuntu–lv 737G 142G 564G 21% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 1.5G 252M 1.2G 19% /boot
tmpfs 792M 4.0K 792M 1% /run/user/1000
root@ubuntu-intranet:/home/ubuntu#

1 réflexion au sujet de « Ubuntu – How To Extend LVM partition »

Laisser un commentaire

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.