0

I am following this link. I missed the "During the install of Ubuntu for the partitioning method choose guided - use the entire disk and setup LVM...". And reached upto lvcreate command(Manually installing an HVM Guest VM) which gives the error, "Volume group "vgubuntu" has insufficient free space (6 extents): 1024 required."(The OS is Ubuntu, I had already tried in the Ubuntu StackExchange site)

Now is there a way(without ending up on needing to format the entire hard disc or requiring a live cd or pendrive etc.) to assign enough memory[I have 1 SSD with around ~250GB, only ~60GB free space(no files etc.)]?

Certain Background info:

sudo vgdisplay
--- Volume group ---
VG Name vgubuntu
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 237.97 GiB
PE Size 4.00 MiB
Total PE 60921
Alloc PE / Size 60915 / <237.95 GiB
Free PE / Size 6 / 24.00 MiB

sudo vgs
VG #PV #LV #SN Attr VSize VFree
vgubuntu 1 2 0 wz--n- 237.97g 24.00m

sudo pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vgubuntu lvm2 a-- 237.97g 24.00m

sudo lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root vgubuntu -wi-ao---- <237.00g
swap_1 vgubuntu -wi-ao---- 976.00m

I am using ext4.

Questions:

  1. Isn't this the right thing to do: lvreduce --resizefs -L 212G vgubuntu/root[Tries to shrink the filesystem first(--resizefs is a lifesaver!) and if successful reduce the size of existing root to 212GB, so that "Alloc PE / Size 60915 / <237.95 GiB" becomes "Alloc PE / Size (a New PE) / <212 GiB(approx.)"] lvcreate -L 8G -n ubuntu-hvm /dev/vgubuntu[Creates a Logical Volume with 8GB for the VolumeGroup vgubuntu]

  2. Is there any other way which I could do it without unmounting(probably not!)?

2
  • Have you tried lvreduce + lvcreate? Those commands look good. Your main question then seems to be whether you can do that without unmounting the logical volume. Is this correct?
    – fra-san
    May 26, 2021 at 10:13
  • Actually, I was not sure if the procedure I learned from the web is correct. Plus I wanted also to check if there was an easy way without any external devices.
    – D J
    May 26, 2021 at 11:59

1 Answer 1

2

Your lvreduce command would be correct if it was possible to on-line shrink your filesystem.

Unfortunately ext4/ext3/ext2 filesystems can only be extended but not reduced on-line.

Tested on Debian, but even the release notes of the most recent e2fsprogs source package don't indicate this has changed at all.

# lvcreate -L 8g -n lvtest vgsys
# mkfs.ext4 /dev/vgsys/lvtest
# mount /dev/vgsys/lvtest /mnt
# lvreduce --resizefs -L 4G /dev/vgsys/lvtest
Do you want to unmount "/mnt" ? [Y|n] n
fsadm: Cannot proceed with mounted filesystem "/mnt".
  /sbin/fsadm failed: 1
  Filesystem resize failed.

This answer describes a procedure that avoids rebooting, but it still requires transitioning to a tmpfs-based temporary root filesystem for shrinking the real root filesystem.

1
  • Looks like there are no easy way to do it!
    – D J
    May 26, 2021 at 14:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .