From 2576c530dc8246e6892532c1530bbb7b0002dc7e Mon Sep 17 00:00:00 2001 From: awokd <34515595+awokd@users.noreply.github.com> Date: Sat, 3 Feb 2018 23:12:10 +0000 Subject: [PATCH 1/9] 4.0 updates adjust title to "Private" vs. counterpart document "Root" add 4.0 content add placeholder procedure for Shrinking private disk image (Linux VM, R4.0) remove outdated, root.img specific content misc. spelling/grammar --- configuration/resize-disk-image.md | 80 ++++++++++++++---------------- 1 file changed, 37 insertions(+), 43 deletions(-) diff --git a/configuration/resize-disk-image.md b/configuration/resize-disk-image.md index 35159d7f..b68b56dd 100644 --- a/configuration/resize-disk-image.md +++ b/configuration/resize-disk-image.md @@ -1,6 +1,6 @@ --- layout: doc -title: Resize Disk Image +title: Resize Private Disk Image permalink: /doc/resize-disk-image/ redirect_from: - /en/doc/resize-disk-image/ @@ -8,33 +8,55 @@ redirect_from: - /wiki/ResizeDiskImage/ --- -Resize Disk Image +Resize Private 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. +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/). -### Private disk image -1048576 MB is the maximum size which can be assigned to a private storage through qubes-manager. +### Private disk image (R4.0) -To grow the private disk image of a AppVM beyond this limit [qubes-grow-private](/doc/dom0-tools/qvm-grow-private/) can be used: +1048576 MiB is the maximum size which can be assigned to a private storage through Qube Manager. + +To grow the private disk image of an AppVM beyond this limit, [qvm-volume](/doc/dom0-tools/qvm-volume/) can be used: + +~~~ +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) + +1048576 MB is the maximum size which can be assigned to a private 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: ~~~ qvm-grow-private ~~~ -Note: Size is the target size (i.e. 4096MB or 16GB, ...), not the size to add to the existing disk. +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) +### Shrinking private disk image (Linux VM, R4.0) -**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 new VM with smaller disk and move the data.** +1. Create a new qube with smaller disk using Qube Manager or qvm-create +2. Move data using OS tools +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 can't be done as convenient as image grown. 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 of the possibility is to interrupt its normal startup by adding `rd.break` kernel option: +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 @@ -76,37 +98,11 @@ Done. >With no argument, resize2fs grows the filesystem to match the underlying block device (the .img file you just shrunk) -### Template disk image +OS Specific Follow-up Instructions +----------------- -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. See also additional information and caveats about [resizing the root disk image]. - -1. Make sure that all the VMs based on this template are shut off (including netvms etc). -2. Sanity check: verify that none of loop device are pointing at this template root.img. Run this in dom0: `sudo losetup -a` -3. Resize root.img file. Run this in dom0: `truncate -s ` (the root.img path can be obtained from qvm-prefs). -4. If any netvm/proxyvm used by this template is based on it, set template netvm to none. -5. Start the template. -6. Execute `sudo resize2fs /dev/mapper/dmroot` in the template. -7. Verify available space in the template using `df -h` -8. Shutdown the template. -9. Restore original netvm setting (if changed), check firewall settings (setting netvm to none causes firewall reset to "block all") - -### HVM disk image - -In this example we will grow the disk image of an HVM to 30GB. - -First, stop/shutdown the HVM. - -Then, from a Dom0 terminal (in KDE: System Tools -\> Terminal Emulator) do the following: - -~~~ -cd /var/lib/qubes/appvms// -ls -lh root.img (<--verify current size of disk image) -truncate -s 30GB root.img -ls -lh root.img (<--verify new size of disk image) -~~~ - -The partition table and file-system must be adjusted after this change. -Use tools appropriate to the OS in your HVM. Brief instructions for Windows 7, +After resizing 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. #### Windows 7 @@ -129,8 +125,6 @@ zpool online -e poolname ada0 #### Linux +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. - - -[resizing the root disk image]: /doc/resize-root-disk-image/ From c380832af15b3651b1d5647209becbef7121622a Mon Sep 17 00:00:00 2001 From: awokd <34515595+awokd@users.noreply.github.com> Date: Sat, 3 Feb 2018 23:37:46 +0000 Subject: [PATCH 2/9] 4.0 updates Add root specific content moved from /doc/resize-disk-image Add 4.0 content Remove outdated (: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](/doc/dom0-tools/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 @@ -27,28 +65,4 @@ Then start Terminal for this StandaloneVM and run: sudo resize2fs /dev/mapper/dmroot ~~~ -Shutdown the StandaloneVM and you will have extended the size of it's `root.img` - - -### Resize a TemplateVM Root Image - -Shut down the TemplateVM, as well as all VMs based on that template (since they -share `root.img`). -In `dom0` Konsole run the following command (replace the size and path): -*Make sure changes in the TemplateVM between reboots didn't exceed 10G.* - -~~~ -truncate -s 20G /var/lib/qubes/vm-templates/fedora-21/root.img -~~~ - -Then start only the TemplateVM and run the following. Note that if you are -resizing the TemplateVM used by, e.g., your NetVM, you may need to disable -networking so when the TemplateVM is started, it does not autostart other VMs -based on the same `root.img`. Otherwise you will get an error message `Nothing -to do!`. - -~~~ -sudo resize2fs /dev/mapper/dmroot -~~~ - -Shutdown the TemplateVM and you will have extended the size of it's `root.img`. +Shutdown the StandaloneVM and you will have extended the size of its `root.img`. From 0cd1cf06646972e0f0b93ca255d53b8ad580f394 Mon Sep 17 00:00:00 2001 From: awokd <34515595+awokd@users.noreply.github.com> Date: Sat, 3 Feb 2018 23:40:44 +0000 Subject: [PATCH 3/9] adjust disk resizing titles --- doc.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc.md b/doc.md index 154fc482..c951c8ac 100644 --- a/doc.md +++ b/doc.md @@ -124,8 +124,8 @@ 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/) - * [Resizing AppVM and HVM Disk Images](/doc/resize-disk-image/) - * [Extending `root.img` Size](/doc/resize-root-disk-image/) + * [Resize Private Disk Image](/doc/resize-disk-image/) + * [Resize Root Disk Image](/doc/resize-root-disk-image/) * [RPC Policies](/doc/rpc-policy/) * [Installing ZFS in Qubes](/doc/zfs/) * [Mutt Guide](/doc/mutt/) From 6bfaf3f35ec7e0885d5c66767cfecb9000125630 Mon Sep 17 00:00:00 2001 From: awokd <34515595+awokd@users.noreply.github.com> Date: Sat, 3 Feb 2018 23:46:08 +0000 Subject: [PATCH 4/9] tweak R4.0 shrink procedure --- configuration/resize-disk-image.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/configuration/resize-disk-image.md b/configuration/resize-disk-image.md index b68b56dd..5aa6321f 100644 --- a/configuration/resize-disk-image.md +++ b/configuration/resize-disk-image.md @@ -16,7 +16,7 @@ There are several disk images which can be easily extended, but pay attention to ### Private disk image (R4.0) -1048576 MiB is the maximum size which can be assigned to a private storage through Qube Manager. +1048576 MiB is the maximum size which can be assigned to private storage through Qube Manager. To grow the private disk image of an AppVM beyond this limit, [qvm-volume](/doc/dom0-tools/qvm-volume/) can be used: @@ -28,7 +28,7 @@ Note: Size is the target size (i.e. 4096MB or 16GB, ...), not the size to add to ### Private disk image (R3.2) -1048576 MB is the maximum size which can be assigned to a private storage through Qubes Manager. +1048576 MB is the maximum size which can be assigned to private 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: @@ -40,9 +40,9 @@ Note: Size is the target size (i.e. 4096MB or 16GB, ...), not the size to add to ### Shrinking private disk image (Linux VM, R4.0) -1. Create a new qube with smaller disk using Qube Manager or qvm-create -2. Move data using OS tools -3. Delete old qube using Qube Manager or qvm-remove +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 +3. Delete old qube using Qube Manager or `qvm-remove` ### Shrinking private disk image (Linux VM, R3.2) From 4f4c3973521a70309f5434c294b9b3593a5b1f9b Mon Sep 17 00:00:00 2001 From: awokd <34515595+awokd@users.noreply.github.com> Date: Sat, 3 Feb 2018 23:49:36 +0000 Subject: [PATCH 5/9] call out "OS Specific" procedure in linked doc --- configuration/resize-root-disk-image.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configuration/resize-root-disk-image.md b/configuration/resize-root-disk-image.md index 630a1dcf..eef31d8b 100644 --- a/configuration/resize-root-disk-image.md +++ b/configuration/resize-root-disk-image.md @@ -11,9 +11,11 @@ redirect_from: 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. See also additional information and caveats about [resizing private disk images](/doc/resize-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 off (including netvms etc). From e36fc0ec3bd8216422a1356ffb99c952a4b61478 Mon Sep 17 00:00:00 2001 From: awokd <34515595+awokd@users.noreply.github.com> Date: Mon, 5 Feb 2018 15:55:34 +0000 Subject: [PATCH 6/9] Fix line breaks and misc spelling --- configuration/resize-disk-image.md | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/configuration/resize-disk-image.md b/configuration/resize-disk-image.md index 5aa6321f..dd5aaf25 100644 --- a/configuration/resize-disk-image.md +++ b/configuration/resize-disk-image.md @@ -11,7 +11,8 @@ redirect_from: Resize Private 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 disk images. +See also additional information and caveats about [resizing the root disk image](/doc/resize-root-disk-image/). ### Private disk image (R4.0) @@ -46,7 +47,8 @@ Note: Size is the target size (i.e. 4096MB or 16GB, ...), not the size to add to ### 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.** +**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: @@ -55,15 +57,16 @@ The basic idea is to: 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: +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: +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 @@ -85,7 +88,9 @@ 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 loose your data!** Then reset kernel options back to default: +**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 @@ -93,17 +98,18 @@ 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`. +>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) +>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. -Use tools appropriate to the OS in your qube. Brief instructions for Windows 7, -FreeBSD, and Linux are provided below. +Use tools appropriate to the OS in your qube. +Brief instructions for Windows 7, FreeBSD, and Linux are provided below. #### Windows 7 From d6910de8b046f1a35f49edea63cfe6d63acfb04a Mon Sep 17 00:00:00 2001 From: awokd <34515595+awokd@users.noreply.github.com> Date: Mon, 5 Feb 2018 15:56:51 +0000 Subject: [PATCH 7/9] fix line breaks --- configuration/resize-root-disk-image.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configuration/resize-root-disk-image.md b/configuration/resize-root-disk-image.md index eef31d8b..3c3567b4 100644 --- a/configuration/resize-root-disk-image.md +++ b/configuration/resize-root-disk-image.md @@ -53,7 +53,9 @@ Note: Size is the target size (i.e. 4096MB or 16GB, ...), not the size to add to ### 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. +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): From 852d970927fd54c1bfd1f082b01198a73b96292d Mon Sep 17 00:00:00 2001 From: awokd <34515595+awokd@users.noreply.github.com> Date: Wed, 7 Feb 2018 12:47:14 +0000 Subject: [PATCH 8/9] remove broken /doc/dom0-tools link for now --- configuration/resize-disk-image.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration/resize-disk-image.md b/configuration/resize-disk-image.md index dd5aaf25..4a7c9087 100644 --- a/configuration/resize-disk-image.md +++ b/configuration/resize-disk-image.md @@ -19,7 +19,7 @@ See also additional information and caveats about [resizing the root disk image] 1048576 MiB is the maximum size which can be assigned to private storage through Qube Manager. -To grow the private disk image of an AppVM beyond this limit, [qvm-volume](/doc/dom0-tools/qvm-volume/) can be used: +To grow the private disk image of an AppVM beyond this limit, `qvm-volume` can be used: ~~~ qvm-volume extend :private From 341a578f9bf8312739d6fe17345c6e2ae010b860 Mon Sep 17 00:00:00 2001 From: awokd <34515595+awokd@users.noreply.github.com> Date: Wed, 7 Feb 2018 12:48:16 +0000 Subject: [PATCH 9/9] remove broken /doc/dom0-tools links for now --- configuration/resize-root-disk-image.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configuration/resize-root-disk-image.md b/configuration/resize-root-disk-image.md index 3c3567b4..8f38dae0 100644 --- a/configuration/resize-root-disk-image.md +++ b/configuration/resize-root-disk-image.md @@ -31,7 +31,7 @@ If you want install a lot of software in your TemplateVM, you may need to increa 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](/doc/dom0-tools/qvm-volume/) can be used: +To grow the root disk image of an AppVM beyond this limit, `qvm-volume` can be used: ~~~ qvm-volume extend :root @@ -43,7 +43,7 @@ Note: Size is the target size (i.e. 4096MB or 16GB, ...), not the size to add to 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](/doc/dom0-tools/qvm-grow-root/) can be used: +To grow the root disk image of an AppVM beyond this limit, `qvm-grow-root` can be used: ~~~ qvm-grow-root