Increase root disk size on Linux


Arcaeus
Go to solution Solved by Arcaeus,

Recommended Posts

Hello, 

 

I have PiHole running in a small Ubuntu VM on my Unraid server (6.12.4) and have run out of space on the root vdisk. As I was watching the SpaceInvaderOne video that was in the guides section of the forum, after he showed how to increase the disk size in the Unraid GUI, he talked about extending the partition (although his video showed Windows).

 

I looked up a guide on how to do it in Linux, but it shows that I would have to unmount the disk first. Since this is the root disk that the OS and everything is running off of, I can't unmount it, and I can't change anything if the VM is shut down of course. 

 

So, how would I go about increasing the partition size? Or clone this disk to a larger one?

adjusted disk size.png

Edited by Arcaeus
Link to comment
  • Solution

Ok, figured it out. Here is what worked for me:

 

  1. Shutdown VM
  2. Adjust capacity in Unraid GUI VM page.
  3. Download gparted, move iso to desired location, and set gparted iso as primary boot disk.
  4. Boot into gparted iso and Extend vdisk to include new space.
  5. Apply and shutdown.
  6. Swap back to original vdisk as primary boot drive.
  7. Boot up VM
  8. SSH into VM (I use Moba)
  9. List disks and storage:
    1. df -h
  10. List file system size
    1. lsblk
  11. Since this should be lvm, run lvextend:
    1. lvextend -l +100%FREE <logical volume> 
    2. Mine specifically was:
      1. lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv 
  12. Resize the file system so it can use all of that space.
    1. resize2fs <file system path>
    2. Mine was
      1. resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
  13. "df -h" now shows correct size:
    1. image.png.d563d801a486d98e26df1da88a2dda20.png
  14. Message shows that disk has been resized successfully, which shows in "lsblk" again.

adjusted disk size success.png

Edited by Arcaeus
Link to comment
  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.