Resizing the hard disk for an LXC virtual machine.
If you create a virtual machine in LXC, but later on find that the disk you provisioned is too small, you can increase its size.
First, make sure your virtual machine is shut down. Then, execute the following command:
lxc config edit vmname
Your text editor will open. Navigate to the line where your disk is defined (probably under devices -> root) and increase the size parameter, e.g. from 10GiB
to 50GiB
. Then save the file and exit the editor.
Then, start your virtual machine again:
lxc start vmname
The added space should now be available, but you will need to expand your partition and filesystem. How to do so differs between OSs and file systems. If you’re running a Windows client, diskmgmt.msc
should have all the functionality you need. However you may need to delete the recovery partition in order to extend the C:
drive. See [removing-a-windows-recovery-partition] for more info about that.