2013-03-07 18:58:33 -05:00
---
2015-04-10 16:17:45 -04:00
layout: doc
2018-02-10 16:05:38 -05:00
title: Resize Disk Image
2015-10-28 18:14:40 -04:00
permalink: /doc/resize-disk-image/
2015-10-11 03:04:59 -04:00
redirect_from:
2015-10-28 18:14:40 -04:00
- /en/doc/resize-disk-image/
2018-02-10 16:05:38 -05:00
- /en/doc/resize-root-disk-image/
2015-10-11 03:04:59 -04:00
- /doc/ResizeDiskImage/
2018-02-10 16:05:38 -05:00
- /doc/ResizeRootDiskImage/
2015-10-11 03:04:59 -04:00
- /wiki/ResizeDiskImage/
2018-02-10 16:05:38 -05:00
- /wiki/ResizeRootDiskImage/
2013-03-07 18:58:33 -05:00
---
2018-02-10 16:05:38 -05:00
Resize Disk Image
2015-11-19 18:57:10 -05:00
-----------------
2013-03-07 18:58:33 -05:00
2018-02-10 16:05:38 -05:00
There are several disk images which can be easily extended, but pay attention to the overall consumed space of your sparse/thin disk images.
See also [OS Specific Follow-up Instructions ](/doc/resize-disk-image/#os-specific-follow-up-instructions ) at the end of this page.
2013-03-07 18:58:33 -05:00
2018-02-21 10:10:14 -05:00
### Template disk image (R4.0)
If you want install a lot of software in your TemplateVM, you may need to increase the amount of disk space your TemplateVM can use.
*Make sure changes in the TemplateVM between reboots don't exceed 10G.*
1. Resize the *root image* using Qubes version specific procedure below.
2. Start the template.
3. Resize the filesystem using OS appropriate tools (Qubes will handle this automatically under Linux).
4. Verify available space in the template using `df -h` or OS specific tools.
5. Shutdown the template.
### Template disk image (R3.2)
2013-11-22 03:30:20 -05:00
2018-02-10 16:05:38 -05:00
If you want install a lot of software in your TemplateVM, you may need to increase the amount of disk space your TemplateVM can use.
*Make sure changes in the TemplateVM between reboots don't exceed 10G.*
2018-02-03 18:12:10 -05:00
2018-02-10 16:05:38 -05:00
1. Make sure that all the VMs based on this template are shut down (including netvms etc).
2. Resize the *root image* using Qubes version specific procedure below.
3. If any netvm/proxyvm used by this template is based on it, set template's netvm to none.
4. Start the template.
2018-02-21 10:10:14 -05:00
5. Resize the filesystem using OS appropriate tools (Linux is `sudo resize2fs /dev/mapper/dmroot` ).
2018-02-10 16:05:38 -05:00
6. Verify available space in the template using `df -h` or OS specific tools.
7. Shutdown the template.
8. Restore original netvm setting (if changed), and check firewall settings (setting netvm to none causes the firewall to reset to "block all")
2013-03-07 18:58:33 -05:00
2018-02-10 16:05:38 -05:00
### Expand disk image (R4.0)
2018-02-03 18:12:10 -05:00
2018-02-10 16:05:38 -05:00
1048576 MiB is the maximum size which can be assigned to storage through Qube Manager.
2018-02-03 18:12:10 -05:00
2018-02-10 16:05:38 -05:00
To grow the root or private disk image of an AppVM beyond this limit, `qvm-volume` can be used:
2018-02-03 18:12:10 -05:00
~~~
2018-02-10 16:05:38 -05:00
qvm-volume extend < vm_name > :root < size >
~~~
OR
~~~
qvm-volume extend < vm_name > :private < size >
2018-02-03 18:12:10 -05:00
~~~
2018-02-10 16:05:38 -05:00
Note: Size is the target size (i.e. 4096MB or 16GB, ...), not the size to add to the existing disk.
2014-04-13 22:58:00 -04:00
2018-02-10 16:05:38 -05:00
### Expand disk image (R3.2)
2014-04-13 22:58:00 -04:00
2018-02-10 16:05:38 -05:00
1048576 MB is the maximum size which can be assigned to storage through Qubes Manager.
2014-04-13 22:58:00 -04:00
2018-02-10 16:05:38 -05:00
To grow the private disk image of an AppVM beyond this limit, `qvm-grow-root` or [qvm-grow-private ](/doc/dom0-tools/qvm-grow-private/ ) can be used:
2014-04-13 22:58:00 -04:00
2015-09-26 19:00:33 -04:00
~~~
2018-02-10 16:05:38 -05:00
qvm-grow-root < vm-name > < size >
2015-09-26 19:00:33 -04:00
~~~
2018-02-10 16:05:38 -05:00
OR
2015-09-26 19:00:33 -04:00
~~~
2018-02-10 16:05:38 -05:00
qvm-grow-private < vm-name > < size >
2015-09-26 19:00:33 -04:00
~~~
2014-04-13 22:58:00 -04:00
2018-02-10 16:05:38 -05:00
Note: Size is the target size (i.e. 4096MB or 16GB, ...), not the size to add to the existing disk.
2014-04-13 22:58:00 -04:00
2018-02-10 16:05:38 -05:00
### Resize a StandaloneVM Root Image
2014-04-13 22:58:00 -04:00
2018-02-21 10:10:14 -05:00
For more flexibility, you may also turn your TemplateVM into a StandaloneVM.
2018-02-10 16:05:38 -05:00
Doing this means it will have its own root filesystem *(StandaloneVMs use a copy of the template, instead of smart sharing)* .
To do this run `qvm-create --standalone` from `dom0` console, then perform the [OS Specific Follow-up Instructions ](/doc/resize-disk-image/#os-specific-follow-up-instructions ) below.
2014-04-13 22:58:00 -04:00
2018-02-10 16:05:38 -05:00
### Shrinking a disk image
2014-04-13 22:58:00 -04:00
2018-02-10 16:05:38 -05:00
Ext4 and most other filesystems do not support online shrinking, so it can't be done as conveniently as growing the image.
Note that we don't want to touch the VM filesystem directly in dom0 for security reasons.
2017-12-21 16:16:15 -05:00
2018-02-10 16:05:38 -05:00
1. Create a new qube with smaller disk using Qube Manager or `qvm-create`
2. Move data to the new qube using `qvm-copy` , backup & restore, or OS utilities
3. Delete old qube using Qube Manager or `qvm-remove`
2017-12-21 16:16:15 -05:00
2018-02-03 18:12:10 -05:00
OS Specific Follow-up Instructions
-----------------
2013-03-07 18:58:33 -05:00
2018-02-10 16:05:38 -05:00
After expanding volumes, the partition table and file-system may need to be adjusted.
2018-02-05 10:55:34 -05:00
Use tools appropriate to the OS in your qube.
Brief instructions for Windows 7, FreeBSD, and Linux are provided below.
2013-03-07 18:58:33 -05:00
2013-10-04 06:47:53 -04:00
#### Windows 7
2013-03-07 18:58:33 -05:00
2013-10-04 06:47:53 -04:00
1. Click Start
2. type "diskmgmt.msc" - this takes you to Disk Management
3. Right-click on your existing volume, select "Extend Volume..."
4. Click through the wizard.
2013-03-07 18:58:33 -05:00
2013-10-04 06:47:53 -04:00
No reboot required.
2013-03-07 18:58:33 -05:00
#### FreeBSD
2015-09-26 19:00:33 -04:00
~~~
2013-03-07 18:58:33 -05:00
gpart recover ada0
sysctl kern.geom.debugflags=0x10
gpart resize -i index ada0
zpool online -e poolname ada0
2015-09-26 19:00:33 -04:00
~~~
2016-10-14 15:52:38 -04:00
#### Linux
2018-02-21 10:10:14 -05:00
Qubes will automatically grow the filesystem for you on AppVMs but not HVMs (or Template root images on R3.2).
2016-10-14 15:52:38 -04:00
You will see that there is unallocated free space at the end of your primary disk.
2018-02-10 16:05:38 -05:00
You can use standard linux tools like `fdisk` and `resize2fs` to make this space available.