{"authors":["utzer"],"canonical_url":"https://newblog.utzer.de/2019/10/02/how-to-add-a-swap-drive-to-your-system/","categories":["Linux","qemu"],"content":"How to add a swap drive to your system, in this case I did this for a virtual machine (qemu) running [Arch Linux](https://wiki.archlinux.org/index.php/Swap).\n\nSee at the bottom for information about the virtual drive for qemu.\n\nList current available to system disks:\n\n```\nsudo blkid\n```\n\nList all disks:\n\n```\nsudo lsblk\n```\n\nFormat as swap:\n\n```\nsudo mkswap /dev/vdb\n```\n\ngives back the UUID\n\nNow the new swap disk will be shown when executing this again:\n\n```\nsudo blkid\n```\n\n(also give the UUID)\n\nTake the UUID from above and add an entry in /etc/fstab like this:\n\n```\necho \"UUID=56445300-90f5-40b4-860b-99037d0e8aad none swap sw 0 0\" |sudo tee -a /etc/fstab\n```\n\nActiate available swap disks, ie. from fstab or on GPT volume.\n\n```\nsudo swapon -a\n```\n\nCheck the swap is available now:\n\n```\nsudo swapon --show\n```\n\nThe qemu image I created as \"raw\", VirtIO and set the cache mode to \"writeback\", this should be fine for swap while being fast too. See explanation [here](https://pve.proxmox.com/wiki/Performance_Tweaks) and [here](https://pve.proxmox.com/wiki/Performance_Tweaks#Use_raw_disk_image_and_not_qcow2).\n\nI also looked at [this](https://raymii.org/s/tutorials/KVM_add_disk_image_or_swap_image_to_virtual_machine_with_virsh.html) information about how to add a swap disk.\n\nAs always, give me your feedback, I will add information that can help in the future.\n","content_format":"markdown","date":"2019-10-02T08:04:57Z","description":"How to add a swap drive to your system, in this case I did this for a virtual machine (qemu) running [Arch Linux](https://wiki.archlinux.org/index.php/Swap). See at the bottom for information about the virtual drive for qemu. List current available to system disks: ``` sudo blkid ``` List all disks:","html_url":"https://newblog.utzer.de/2019/10/02/how-to-add-a-swap-drive-to-your-system/","json_url":"https://newblog.utzer.de/2019/10/02/how-to-add-a-swap-drive-to-your-system/index.json","lastmod":"2019-10-02T08:04:57Z","markdown_url":"https://newblog.utzer.de/2019/10/02/how-to-add-a-swap-drive-to-your-system/index.md","media":[],"schema_version":1,"tags":["Arch","linux","Swap","system"],"title":"How to add a swap drive to your system","type":"blog_post"}