1

I am trying to increase the disk size of a VM that I initially set up with 4 GB memory to 10 GB. I successfully increased it to 8 GB (by getting rid of lv_swap and running lvextend after updating it in the VirtualBox GUI) earlier, but have been unable to further increase it. I increased the memory through VirtualBox' GUI to 10 G, and if I run cat /proc/meminfo I get the following output:

MemTotal:       10905472 kB
MemFree:        10387160 kB
...

However, if I run df -h I get

Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/lv_root   7.4G  6.2G  853M  89% /
tmpfs                 5.3G  272K  5.2G   1% /dev/shm
/dev/sda1             485M   58M  402M  13% /boot

If I run sudo gparted it only lists boot and root; boot with ~500M and root with just under 8G and I can't expand root using that. I tried doing it from a LiveDVD and ended up with the same result. If I just run sudo lvextend ..., it says there isn't enough unallocated to add it. Since tmpfs looks overly large, I tried remounting tmpfs with a smaller size but the extra memory didn't show up and when I rebooted the machine it had the same size as before.

Does anyone have any idea how to allocate that extra memory to root rather than tmpfs or wherever it's now floating around? Any ideas on why it's not usable?

Update: The root cause of the confusion was due to confusion between memory/disk space on my part as well as SO and other community-based resources I searched. I am leaving the question mostly as asked (shortening the meminfo output) because when I was trying to find answers, I found a lot that confused the two and not a lot that ended up clarifying the answer, and it would have been helpful for me to find something in this format.

1
  • The term "memory" refers to RAM, not hard disk storage. Please edit your question to clarify what you are asking. Commented Jun 21, 2018 at 17:37

1 Answer 1

6

I accidentally only increased the motherboard size (I'm not sure why it worked the first time when I increased it to 8G)

To solve my issue:

I went to > Settings > Storage and created a new Hard Drive under Controller:SATA. When I rebooted the machine, I ran sudo gparted (or lsblk -f) and got the new HD name. I was then able to use the instructions here to make the space usable. In short, I ran:

  1. sudo pvcreate /dev/sdb

    • /dev/sdb was the new disk location
  2. sudo vgextend pv_name vg_name

    • pv_name is the name of the new physical volume; can be found by running sudo pvdisplay
    • vg_name is the name of the volume group of the pv to be expanded; can be found by running sudo pvdisplay
  3. sudo lvextend -t -r -l+100%FREE /dev/mapper/lv_root

    • checks if the volume can be successfully extended to 100% of the free space (-l+100%FREE)
    • (-t for test)
    • (find lv_root with ls /dev/mapper/)
  4. sudo lvextend -r -l+100%FREE /dev/mapper/lv_root

    • extends the volume (no -t)

Hopefully my 5 hours of misadventure help someone else out!

1
  • You saved me 5 hours of misadventure. ty!
    – sadtank
    Commented Jan 8, 2019 at 22:35

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