From 08967c34d2730dd1ab1e75f000b886a8cc8d98a8 Mon Sep 17 00:00:00 2001 From: awokd <34515595+awokd@users.noreply.github.com> Date: Sat, 10 Feb 2018 21:05:38 +0000 Subject: [PATCH 1/4] consolidate in info from root resize doc --- configuration/resize-disk-image.md | 122 ++++++++++++----------------- 1 file changed, 49 insertions(+), 73 deletions(-) diff --git a/configuration/resize-disk-image.md b/configuration/resize-disk-image.md index 4a7c9087..ead7c4bd 100644 --- a/configuration/resize-disk-image.md +++ b/configuration/resize-disk-image.md @@ -1,113 +1,89 @@ --- layout: doc -title: Resize Private Disk Image +title: Resize Disk Image permalink: /doc/resize-disk-image/ redirect_from: - /en/doc/resize-disk-image/ +- /en/doc/resize-root-disk-image/ - /doc/ResizeDiskImage/ +- /doc/ResizeRootDiskImage/ - /wiki/ResizeDiskImage/ +- /wiki/ResizeRootDiskImage/ --- -Resize Private Disk Image +Resize Disk Image ----------------- -There are several disk images which can be easily extended, but pay attention to the overall consumed space of your sparse disk images. -See also additional information and caveats about [resizing the root disk image](/doc/resize-root-disk-image/). +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. -### Private disk image (R4.0) +### Template disk image -1048576 MiB is the maximum size which can be assigned to private storage through Qube Manager. +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.* -To grow the private disk image of an AppVM beyond this limit, `qvm-volume` can be used: +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. + You may instead resize the *private image* with the appropriate commands if your software installs to `/home` for example. +3. If any netvm/proxyvm used by this template is based on it, set template's netvm to none. +4. Start the template. +5. Resize the filesystem using OS appropriate tools (Qubes will handle this automatically with Linux templates). +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") +### Expand disk image (R4.0) + +1048576 MiB is the maximum size which can be assigned to storage through Qube Manager. + +To grow the root or private disk image of an AppVM beyond this limit, `qvm-volume` can be used: + +~~~ +qvm-volume extend :root +~~~ +OR ~~~ qvm-volume extend :private ~~~ Note: Size is the target size (i.e. 4096MB or 16GB, ...), not the size to add to the existing disk. -### Private disk image (R3.2) +### Expand disk image (R3.2) -1048576 MB is the maximum size which can be assigned to private storage through Qubes Manager. +1048576 MB is the maximum size which can be assigned to storage through Qubes Manager. -To grow the private disk image of an AppVM beyond this limit, [qvm-grow-private](/doc/dom0-tools/qvm-grow-private/) can be used: +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: +~~~ +qvm-grow-root +~~~ +OR ~~~ qvm-grow-private ~~~ Note: Size is the target size (i.e. 4096MB or 16GB, ...), not the size to add to the existing disk. -### Shrinking private disk image (Linux VM, R4.0) +### Resize a StandaloneVM Root Image + +Another way to increase the size of is to turn your TemplateVM into a StandaloneVM. +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. + +### Shrinking a disk image + +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. 1. Create a new qube with smaller disk using Qube Manager or `qvm-create` -2. Move data to the new qube using `qvm-copy` or OS utilities +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` -### Shrinking private disk image (Linux VM, R3.2) - -**This operation is dangerous and this is why it isn't available in standard Qubes tools. -If you have enough disk space, it is safer to create a new VM with a smaller disk and move the data.** - -The basic idea is to: - -1. Shrink filesystem on the private disk image. -2. Then shrink the image. - -Ext4 does 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. -First you need to start VM without `/rw` mounted. -One possibility is to interrupt its normal startup by adding the `rd.break` kernel option: - -~~~ -qvm-prefs -s kernelopts rd.break -qvm-start --no-guid -~~~ - -And wait for qrexec connect timeout (or simply press Ctrl-C). -Then you can connect to VM console and shrink the filesystem: - -~~~ -sudo xl console -# you should get dracut emergency shell here -mount --bind /dev /sysroot/dev -chroot /sysroot -mount /proc -e2fsck -f /dev/xvdb -resize2fs /dev/xvdb -umount /proc -exit -umount /sysroot/dev -poweroff -~~~ - -Now you can resize the image: - -~~~ -truncate -s /var/lib/qubes/appvms//private.img -~~~ - -**It is critical to use the same (or bigger for some safety margin) size in truncate call compared to resize2fs call. -Otherwise you will lose your data!** -Then reset kernel options back to default: - -~~~ -qvm-prefs -s kernelopts default -~~~ - -Done. - ->In order to avoid error, you might want to first reduce the filesystem to a smaller size than desired (say 3G), then truncate the image to the target size (for example 4G), and lastly grow the filesystem to the target size. ->In order to do this, after the `truncate` step, start the vm again in maintenance mode and use the following command to extend the filesystem to the correct size : `resize2fs /dev/xvdb`. -> ->With no argument, resize2fs grows the filesystem to match the underlying block device (the .img file you just shrunk). - - OS Specific Follow-up Instructions ----------------- -After resizing volumes, the partition table and file-system may need to be adjusted. +After expanding volumes, the partition table and file-system may need to be adjusted. Use tools appropriate to the OS in your qube. Brief instructions for Windows 7, FreeBSD, and Linux are provided below. @@ -133,4 +109,4 @@ zpool online -e poolname ada0 Qubes will automatically grow the filesystem for you on AppVMs but not HVMs. You will see that there is unallocated free space at the end of your primary disk. -You can use standard linux tools like fdisk and mkfs to make this space available. +You can use standard linux tools like `fdisk` and `resize2fs` to make this space available. From aff67c7380b7ebac43f69cf7f38b41f20fc8488f Mon Sep 17 00:00:00 2001 From: awokd <34515595+awokd@users.noreply.github.com> Date: Sat, 10 Feb 2018 21:09:30 +0000 Subject: [PATCH 2/4] Delete resize-root-disk-image.md --- configuration/resize-root-disk-image.md | 72 ------------------------- 1 file changed, 72 deletions(-) delete mode 100644 configuration/resize-root-disk-image.md diff --git a/configuration/resize-root-disk-image.md b/configuration/resize-root-disk-image.md deleted file mode 100644 index 7765fe75..00000000 --- a/configuration/resize-root-disk-image.md +++ /dev/null @@ -1,72 +0,0 @@ ---- -layout: doc -title: Resize Root Disk Image -permalink: /doc/resize-root-disk-image/ -redirect_from: -- /en/doc/resize-root-disk-image/ -- /doc/ResizeRootDiskImage/ -- /wiki/ResizeRootDiskImage/ ---- - -Resize Root Disk Image ----------------------- - -See additional information and caveats about [resizing private disk images](/doc/resize-disk-image/), paying particular attention to "OS Specific Follow-up Instructions" at the end. - -### Template disk image - -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. Make sure that all the VMs based on this template are shut down (including netvms etc). -2. Resize 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. -5. Resize the filesystem using OS appropriate tools (Qubes will handle this automatically with Linux templates). -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), check firewall settings (setting netvm to none causes the firewall to reset to "block all") - -### Root disk image (R4.0) - -1048576 MiB is the maximum size which can be assigned to root storage through Qube Manager. - -To grow the root disk image of an AppVM beyond this limit, `qvm-volume` can be used: - -~~~ -qvm-volume extend :root -~~~ - -Note: Size is the target size (i.e. 4096MB or 16GB, ...), not the size to add to the existing disk. - -### Root disk image (R3.2) - -1048576 MB is the maximum size which can be assigned to root storage through Qubes Manager. - -To grow the root disk image of an AppVM beyond this limit, `qvm-grow-root` can be used: - -~~~ -qvm-grow-root -~~~ - -Note: Size is the target size (i.e. 4096MB or 16GB, ...), not the size to add to the existing disk. - -### Resize a StandaloneVM Root Image (R3.2) - -Another way to increase the size of `root.img` is to turn your TemplateVM into a StandaloneVM. -Doing this means it will have it's own root filesystem *(StandaloneVMs use a copy of template, instead of smart sharing)*. -To do this run `qvm-create --standalone` from `dom0` console. - -In `dom0` console run the following command (replace the size and path): - -~~~ -truncate -s 20G /var/lib/qubes/appvms/standalonevm/root.img -~~~ - -Then start Terminal for this StandaloneVM and run: - -~~~ -sudo resize2fs /dev/mapper/dmroot -~~~ - -Shutdown the StandaloneVM and you will have extended the size of its `root.img`. From d07c6f16d1e244b0e7bc0719e1a379e7cf9de707 Mon Sep 17 00:00:00 2001 From: awokd <34515595+awokd@users.noreply.github.com> Date: Sat, 10 Feb 2018 21:10:42 +0000 Subject: [PATCH 3/4] remove "Resize Root Disk Image" --- doc.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc.md b/doc.md index 4d86174f..f97ac3fb 100644 --- a/doc.md +++ b/doc.md @@ -124,8 +124,7 @@ Configuration Guides * [How to set up a ProxyVM as a VPN Gateway](/doc/vpn/) * [Storing AppVMs on Secondary Drives](/doc/secondary-storage/) * [Multibooting](/doc/multiboot/) - * [Resize Private Disk Image](/doc/resize-disk-image/) - * [Resize Root Disk Image](/doc/resize-root-disk-image/) + * [Resize Disk Image](/doc/resize-disk-image/) * [RPC Policies](/doc/rpc-policy/) * [Installing ZFS in Qubes](/doc/zfs/) * [Mutt Guide](/doc/mutt/) From 940f0e8d699482f6e373c34861ccf7010e6698c2 Mon Sep 17 00:00:00 2001 From: awokd <34515595+awokd@users.noreply.github.com> Date: Wed, 21 Feb 2018 15:10:14 +0000 Subject: [PATCH 4/4] add r4.0 template resize --- configuration/resize-disk-image.md | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/configuration/resize-disk-image.md b/configuration/resize-disk-image.md index ead7c4bd..28c48aee 100644 --- a/configuration/resize-disk-image.md +++ b/configuration/resize-disk-image.md @@ -18,17 +18,27 @@ There are several disk images which can be easily extended, but pay attention to See also [OS Specific Follow-up Instructions](/doc/resize-disk-image/#os-specific-follow-up-instructions) at the end of this page. -### Template disk image +### 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) 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. 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. - You may instead resize the *private image* with the appropriate commands if your software installs to `/home` for example. 3. If any netvm/proxyvm used by this template is based on it, set template's netvm to none. 4. Start the template. -5. Resize the filesystem using OS appropriate tools (Qubes will handle this automatically with Linux templates). +5. Resize the filesystem using OS appropriate tools (Linux is `sudo resize2fs /dev/mapper/dmroot`). 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") @@ -67,7 +77,7 @@ Note: Size is the target size (i.e. 4096MB or 16GB, ...), not the size to add to ### Resize a StandaloneVM Root Image -Another way to increase the size of is to turn your TemplateVM into a StandaloneVM. +For more flexibility, you may also turn your TemplateVM into a StandaloneVM. 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. @@ -107,6 +117,6 @@ zpool online -e poolname ada0 #### Linux -Qubes will automatically grow the filesystem for you on AppVMs but not HVMs. +Qubes will automatically grow the filesystem for you on AppVMs but not HVMs (or Template root images on R3.2). You will see that there is unallocated free space at the end of your primary disk. You can use standard linux tools like `fdisk` and `resize2fs` to make this space available.