Link to home
Start Free TrialLog in
Avatar of Dima Iva
Dima Iva

asked on

How to use free space on Ubuntu after removing an LV?

I installed Ubuntu and messed up partitioning, ending up with one of the LVs taking half of my 240Gb, but only used for 1% of its capacity. I got help here: https://www.experts-exchange.com/questions/29225890/How-to-merge-ubuntu-LVMs.html#a43347541 and deleted this LV:


/dev/mapper/ubuntu--vg-lv--2   121G  792M  114G   1% /home


Now I wonder what do with the resulting free 121GB. My /root is 49GB and my /var is also 49GB.  Should I split 121GB to extend both / and /var by 60GBs each or should I only increase /root size and leave empty space for /var for later?  What proportion would make sense and what commands should I use? 


root@device:/home/dspace# df -h 
Filesystem                         Size  Used Avail Use% Mounted on 
udev                               3.9G     0  3.9G   0% /dev 
tmpfs                              797M  1.5M  795M   1% /run 
/dev/mapper/ubuntu--vg-ubuntu--lv   49G   33G   15G  69% / 
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                          976M  314M  595M  35% /boot 
/dev/mapper/ubuntu--vg-lv--1        49G  5.7G   41G  13% /var 
/dev/loop0                         100M  100M     0 100% /snap/core/11798 
/dev/loop1                          11M   11M     0 100% /snap/canonical-livepatch/104 
/dev/loop2                          11M   11M     0 100% /snap/canonical-livepatch/105 
/dev/loop3                          56M   56M     0 100% /snap/core18/2128 
/dev/loop4                         100M  100M     0 100% /snap/core/11743 
/dev/loop5                          56M   56M     0 100% /snap/core18/2074 
/dev/loop6                          68M   68M     0 100% /snap/lxd/21545 
/dev/loop7                          62M   62M     0 100% /snap/core20/1081 
/dev/loop8                          71M   71M     0 100% /snap/lxd/21029 
/dev/loop9                          33M   33M     0 100% /snap/snapd/13270 
/dev/loop10                         33M   33M     0 100% /snap/snapd/13170 
/dev/loop11                         62M   62M     0 100% /snap/core20/1169 
/dev/loop12                         39M   39M     0 100% /snap/postgresql10/47 
tmpfs                              797M   20K  797M   1% /run/user/1000 

Open in new window


root@device:/home/dspace# lsblk 

NAME                     MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT 

loop0                      7:0    0 99.5M  1 loop /snap/core/11798 

loop1                      7:1    0 10.2M  1 loop /snap/canonical-livepatch/104 

loop2                      7:2    0 10.2M  1 loop /snap/canonical-livepatch/105 

loop3                      7:3    0 55.4M  1 loop /snap/core18/2128 

loop4                      7:4    0 99.3M  1 loop /snap/core/11743 

loop5                      7:5    0 55.5M  1 loop /snap/core18/2074 

loop6                      7:6    0 67.3M  1 loop /snap/lxd/21545 

loop7                      7:7    0 61.8M  1 loop /snap/core20/1081 

loop8                      7:8    0 70.3M  1 loop /snap/lxd/21029 

loop9                      7:9    0 32.4M  1 loop /snap/snapd/13270 

loop10                     7:10   0 32.3M  1 loop /snap/snapd/13170 

loop11                     7:11   0 61.9M  1 loop /snap/core20/1169 

loop12                     7:12   0 38.7M  1 loop /snap/postgresql10/47 

sda                        8:0    0  240G  0 disk  

├─sda1                     8:1    0    1M  0 part  

├─sda2                     8:2    0    1G  0 part /boot 

└─sda3                     8:3    0  239G  0 part  

  ├─ubuntu--vg-ubuntu--lv 

  │                      253:0    0   50G  0 lvm  / 

  ├─ubuntu--vg-lv--0     253:1    0   16G  0 lvm  [SWAP] 

  └─ubuntu--vg-lv--1     253:2    0   50G  0 lvm  /var 

Open in new window


Avatar of Deepak Sharma
Deepak Sharma
Flag of India image

Hello Dima,
Can you please share the output of below commands:
# pvs
# vgs
# lvs
# df -hT / /var
Thanks
While I am waiting for you to provide me the above commands output, about this question:
Should I split 121GB to extend both / and /var by 60GBs each or should I only increase /root size and leave empty space for /var for later?  What proportion would make sense and what commands should I use?  
​​​​​
/dev/mapper/ubuntu--vg-ubuntu--lv   49G   33G   15G  69% / 

Open in new window

/dev/mapper/ubuntu--vg-lv--1        49G  5.7G   41G  13% /var 

Open in new window

Your / is already way too much utilized as compared to /var (hardly utilized).
I would first see what's causing / to increase this much. This is actually a cause of concern unless you have moved a lot of data in your home directory (likely) or some other location under /.
Going at this rate, your / will be full pretty soon.
This answers your question.
Obviously, here / will need to be increased.
You can leave /var as it is given your situation.

ASKER CERTIFIED SOLUTION
Avatar of Deepak Sharma
Deepak Sharma
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dima Iva
Dima Iva

ASKER

Thank you, Deepak.  Below is the output of the commands.  So, just to double check, by running: lvresize -rL +60G /dev/mapper/ubuntu--vg-ubuntu--lv I will add 60G to my /,  increasing its size to 109GB, and then I can decide what to do with the remaining free 60GB at later date?

root@device:/home/dspace# pvs 
  PV         VG        Fmt  Attr PSize    PFree    
  /dev/sda3  ubuntu-vg lvm2 a--  <239.00g <123.00g 

root@device:/home/dspace# vgs 
  VG        #PV #LV #SN Attr   VSize    VFree    
  ubuntu-vg   1   3   0 wz--n- <239.00g <123.00g 

root@device:/home/dspace# lvs 
  LV        VG        Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert 
  lv-0      ubuntu-vg -wi-ao---- 16.00g                                            
  lv-1      ubuntu-vg -wi-ao---- 50.00g                                                     
  ubuntu-lv ubuntu-vg -wi-ao---- 50.00g                                                     

root@device:/home/dspace# df -hT / /var 
Filesystem                        Type  Size  Used Avail Use% Mounted on 
/dev/mapper/ubuntu--vg-ubuntu--lv ext4   49G   32G   15G  69% / 
/dev/mapper/ubuntu--vg-lv--1      ext4   49G  5.7G   41G  13% /var 

Open in new window

Yes Dima. You are absolutely correct :)
Wow, that was great! Thank you.

root@device:/home/dspace# lvresize -rL +60G /dev/mapper/ubuntu--vg-ubuntu--lv  
Size of logical volume ubuntu-vg/ubuntu-lv changed from 50.00 GiB (12800 extents) to 110.00 GiB (28160 extents). 
Logical volume ubuntu-vg/ubuntu-lv successfully resized. 
resize2fs 1.45.5 (07-Jan-2020) 
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required 
old_desc_blocks = 7, new_desc_blocks = 14 
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 28835840 (4k) blocks long. 

Open in new window



You are most welcome Dima.
Glad I could help.