loading...

Expand disk in virtualbox Ubuntu 18 guest

schollii profile image schollii ・2 min read

I needed to expand the virtual disk drive of several Ubuntu 18.10 vm guests I had. I looked around the web a bit and found that the posts explaining how to do that involve more steps that is now necessary on Ubuntu 18. So here is what was sufficient on 3 separate VM's:

  1. Resize virtual disk in VirtualBox:
    1. Power down the VM
    2. Go to Virtual Media Manager (VMM)
    3. Select the disk that corresponds to your VM and resize the disk file (this is possible only on powered down VM)
    4. Start VM
  2. Resize partition in guest:

    1. Install gparted: sudo apt install gparted
    2. Start gparted
    3. Select partition
    4. Select resize
    5. Stretch it to desired size
    6. Check the details to confirm it did what you want
    7. Make OS see the entire partition using pvresize:

      $ sudo pvresize /dev/sda1
        Physical volume "/dev/sda1" changed
        1 physical volume(s) resized / 0 physical volume(s) not resized
      
  3. Resize the logical volume using lvresize:

    $ sudo lvresize -l +100%FREE /dev/mapper/ubuntu--vg-root
      Size of logical volume ubuntu-vg/root changed from 29.03 GiB (7432 extents) to <48.85 GiB (12505 extents).
      Logical volume ubuntu-vg/root successfully resized.
    
  4. Resize the filesystem:

    $ sudo resize2fs /dev/mapper/ubuntu--vg-root
    $ df -h
    /dev/mapper/ubuntu--vg-root   48G   21G   26G  45% /
    

Two of the pages that helped a lot:

Posted on by:

schollii profile

schollii

@schollii

Apple IIe -> Distributed computing (C/C++, Python, Lua, Java, C#, Javascript) -> DevOps (Docker, Kubernetes, Helm, Terraform, Spinnaker, AWS)

Discussion

markdown guide