Score:2

How can I increase the size of lvm partition?

lb flag

I have a ubuntu 18.04 system. I have a total of 3 partitions and in my third partition, I have an LVM partition. I need to increase the size of that partition. Here is the output of lsblk I need to increase the size of ubuntu--vg-ubuntu--lv partition inside /dev/sda3

NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                         8:0    0  140G  0 disk
├─sda1                      8:1    0    1M  0 part
├─sda2                      8:2    0    1G  0 part /boot
└─sda3                      8:3    0   49G  0 part
  └─ubuntu--vg-ubuntu--lv 253:0    0 24.5G  0 lvm  /
sr0                        11:0    1  969M  0 rom

Here is the output of df-h

udev                               3.9G     0  3.9G   0% /dev
tmpfs                              789M  1.3M  787M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   24G   22G  1.4G  95% /
tmpfs                              3.9G     0  3.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                              3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda2                          974M  219M  688M  25% /boot
overlay                             24G   22G  1.4G  95% /var/lib/docker/overlay2/bb5dcb08fd6998aa3e438d3f2a43aeaea79fb22964abf42b4c5a869cde848b2a/merged
overlay                             24G   22G  1.4G  95% /var/lib/docker/overlay2/55b43f1550428d3a82d2c2aebeb71bc9d53aac8185dd92644dfb27e806643b21/merged
overlay                             24G   22G  1.4G  95% /var/lib/docker/overlay2/d812b2347f599e207581e3cd6465013c5bf397aed3e4574a029f0289c42b3a4a/merged
overlay                             24G   22G  1.4G  95% /var/lib/docker/overlay2/742e299d503c794052c173e34c78c75034e96870802856cfb15475478cbc6b01/merged
shm                                 64M   28K   64M   1% /var/lib/docker/containers/551b12883006bdf12d8a7602d862639b25cefdaac1623c62a0dfbc54970e6134/mounts/shm
shm                                 64M     0   64M   0% /var/lib/docker/containers/5f0ba3554d80c9b04823d09fed7a8c07c79f0059ba53d5a302ad981c6c419f42/mounts/shm
shm                                 64M     0   64M   0% /var/lib/docker/containers/aa50634d995d73db38c109365c7a7f330d3ba3dd8adf6901ab0668536787ea21/mounts/shm
shm                                 64M     0   64M   0% /var/lib/docker/containers/058f86b327e7efb701b5741a529157fdd01cc4785f3fb71a02355f3533664b5b/mounts/shm
overlay                             24G   22G  1.4G  95% /var/lib/docker/overlay2/d59ce13ad4c6790a0870b3f493b7093173c72da454eeaf03f96a311e16287d4b/merged
overlay                             24G   22G  1.4G  95% /var/lib/docker/overlay2/474c51077a4becbc431b85ae8204648206cb3321ccf5b778882961d410ba32c2/merged
overlay                             24G   22G  1.4G  95% /var/lib/docker/overlay2/fb516c559bd0d8368215a888320ab9624f6eac47fce9536ca6c3c4eddcb98af4/merged
overlay                             24G   22G  1.4G  95% /var/lib/docker/overlay2/f4d78c070438f018f39cd7a170594c84b6d5b1983eb9240f55e3c33c131503c9/merged
shm                                 64M     0   64M   0% /var/lib/docker/containers/eea2e2895e013598106f35980d444b0b192a9ad60e8d12071edc729f1b38a9de/mounts/shm
shm                                 64M     0   64M   0% /var/lib/docker/containers/7df0cb94fb37ee61fdec8fb2db4fc4938fe56b8ac5809f109b9ed73fd6cb07d6/mounts/shm
shm                                 64M   16K   64M   1% /var/lib/docker/containers/5a1f23081c327b5e431b985f051c85c02eaf143db4bca9984cd55c5b69485e0e/mounts/shm
shm                                 64M  8.0K   64M   1% /var/lib/docker/containers/a8b8c20bdaa2ca9f934348ec9aa754399217f9e58e69e886deef5b0df3ab7074/mounts/shm
tmpfs                              789M     0  789M   0% /run/user/1000

Here is the output of lvs

LV        VG        Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  ubuntu-lv ubuntu-vg -wi-ao---- 24.50g

Here is the output of vgs

VG        #PV #LV #SN Attr   VSize   VFree
  ubuntu-vg   1   1   0 wz--n- <49.00g <24.50g
hamza toor avatar
lb flag
Really sorry. Did it by mistake. My release is 18.04
hamza toor avatar
lb flag
Thanks for pointing out
darth_epoxy avatar
nl flag
`gparted` allows you to resize partitions, it's a GUI tool. BE CAREFUL as it won't ask you twice so don't go reformatting or deleting things becasue you won't get it back.
hamza toor avatar
lb flag
@darth_epoxy can I do it through command line?
darth_epoxy avatar
nl flag
You can use fdisk but I am unable to provide an answer as I don't know if LVM will be a problem. Try `fdisk -l` to see if the partition shows up then do some fdisk research. Resizing can create PMBR mismatches on GPT formatted partitions so I can only imagine LVM will be the same or worse. That's why they made gparted with the cleveer stuff built in.
oldfred avatar
cn flag
Some more info: http://askubuntu.com/questions/852019/i-wish-to-expand-my-lvm2-partition & http://askubuntu.com/questions/196125/how-can-i-resize-an-lvm-partition-i-e-physical-volume
Score:2
sb flag

In fact ubuntu--vg-ubuntu--lv in not direct inside sda3.

Partition sda3 is assigned to LVM PV (PhysicalVolume) size 49GiB
on this PV is created LVM VG (VolumeGroup): ubuntu-vg size 49GiB
in this VG is created LVM LV (LogicalVolume): ubuntu-lv size 24.5GiB

In VG is unassigned 24.50GiB, on disk sda is unassigned 90GiB space...

If you want increase size of ubuntu-lv but not increase size of VG/PV/sda3,
you can enlarge ubuntu-lv at maximum of curent VG size 49GiB.

This add 5GiB from unassigned VG space to LV ubuntu-lv:

sudo lvresize --size +5G --resizefs ubuntu-vg/ubuntu-lv

This add all unassigned VG space to LV ubuntu-lv:

sudo lvresize --extents +100%FREE --resizefs ubuntu-vg/ubuntu-lv

( --resizefs is for resize filesystem on it to fit new LV size )

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.