How to add swap space

44 views
Skip to first unread message

bill...@gmail.com

unread,
Feb 8, 2020, 8:20:26 PM2/8/20
to qubes-users

I need to add swap space to a VM, but it's not clear to me how to do it.  If this were "normal" linux, I'd just add a swap file, but I don't know if I need can do that in dom0, and if that translates to available swap space in my VMs.  The last time I played with memory things in dom0, I brought the system down, so I'm a little hesitant to just go in and do it.

So... say I want to add a 50G swap file.  Can I just dd the space and make the swap file like normal in dom0?  Do I have to create another real swap partition?

Thanks!

billo

awokd

unread,
Feb 9, 2020, 9:14:43 AM2/9/20
to qubes...@googlegroups.com
bill...@gmail.com:
https://github.com/Qubes-Community/Contents/blob/master/docs/misc/iaq.adoc#how-can-i-provision-a-vm-with-a-largernon-standard-swap-and-tmp

--
- don't top post
Mailing list etiquette:
- trim quoted reply to only relevant portions
- when possible, copy and paste text instead of screenshots

dhorf-hfre...@hashmail.org

unread,
Feb 9, 2020, 10:58:07 AM2/9/20
to bill...@gmail.com, qubes...@googlegroups.com
On Sun, Feb 09, 2020 at 02:13:53PM +0000, 'awokd' via qubes-users wrote:
> https://github.com/Qubes-Community/Contents/blob/master/docs/misc/iaq.adoc#how-can-i-provision-a-vm-with-a-largernon-standard-swap-and-tmp

for "up to 10GB" and on a modern qubes with lvm-pool there is also ...
just start the the vm, no dom0 actions required:

vm$ sudo mkswap /dev/xvdc3
vm$ sudo swapon /dev/xvdc3
vm$ sudo mount -o remount,size=10g /tmp


the "50G" thing is harder, but can still be done "almost the same way".
again, start the vm, but one step in dom0 and two extra steps in the vm:

dom0$ qvm-volume resize vm:volatile 50GiB
vm$ sudo swapoff -a
vm$ sudo blkdiscard /dev/xvdc
vm$ sudo mkswap /dev/xvdc
vm$ sudo swapon /dev/xvdc
vm$ sudo mount -o remount,size=50g /tmp

the swapoff+blkdiscard is only about 90% reliable in my exp, if anything
fires a blockdevice-hotplug event in between those it will auto-swapon
the old device again. just repeat swapoff+blkdiscard if the mkswap
errors out about "in use".

both ways do not require any cleanup in the vm or in dom0.

you can check if you are on "modern qubes with lvm-pool" by checking
whether you have a /dev/xvdc3 inside the appvm.
or more importantly, that you do NOT have a xvdc2 (which indicates
file-pool reverse-cow is in in use).




bill...@gmail.com

unread,
Feb 13, 2020, 3:27:47 PM2/13/20
to qubes-users
Thanks to all for the replies.  It worked!

billo
Reply all
Reply to author
Forward
0 new messages