How to mount a host partition within a VM as swap?

Nov 17, 2017
16
0
6
59
My proxmox host has an SSD that I want to use as swap space for one of my VMs. I don't understand how to connect it though. If I try to add another disc as hardware in the VM hardware tab, it only lists my ZFS stuff - but the partition I want to use is just a raw partion (/dev/nvme0n1p6). Towards the end of this list (p5 is swap for the host):

root@zen:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 3.7T 0 disk
├─sda1 8:1 0 1007K 0 part
├─sda2 8:2 0 3.7T 0 part
└─sda9 8:9 0 8M 0 part
sdb 8:16 0 3.7T 0 disk
├─sdb1 8:17 0 1007K 0 part
├─sdb2 8:18 0 3.7T 0 part
└─sdb9 8:25 0 8M 0 part
zd0 230:0 0 8G 0 disk
zd16 230:16 0 32G 0 disk
├─zd16p1 230:17 0 28G 0 part
├─zd16p2 230:18 0 1K 0 part
└─zd16p5 230:21 0 4G 0 part
zd32 230:32 0 32G 0 disk
├─zd32p1 230:33 0 28G 0 part
├─zd32p2 230:34 0 1K 0 part
└─zd32p5 230:37 0 4G 0 part
zd48 230:48 0 32G 0 disk
├─zd48p1 230:49 0 28G 0 part
├─zd48p2 230:50 0 1K 0 part
└─zd48p5 230:53 0 4G 0 part
zd64 230:64 0 32G 0 disk
├─zd64p1 230:65 0 28G 0 part
├─zd64p2 230:66 0 1K 0 part
└─zd64p5 230:69 0 4G 0 part
zd80 230:80 0 32G 0 disk
├─zd80p1 230:81 0 28G 0 part
├─zd80p2 230:82 0 1K 0 part
└─zd80p5 230:85 0 4G 0 part
zd96 230:96 0 32G 0 disk
├─zd96p1 230:97 0 28G 0 part
├─zd96p2 230:98 0 1K 0 part
└─zd96p5 230:101 0 4G 0 part
zd112 230:112 0 32G 0 disk
├─zd112p1 230:113 0 28G 0 part
├─zd112p2 230:114 0 1K 0 part
└─zd112p5 230:117 0 4G 0 part
nvme0n1 259:0 0 477G 0 disk
├─nvme0n1p1 259:1 0 29.8G 0 part
├─nvme0n1p2 259:2 0 100G 0 part
├─nvme0n1p3 259:3 0 1K 0 part
├─nvme0n1p5 259:4 0 128G 0 part [SWAP]
├─nvme0n1p6 259:5 0 64G 0 part
└─nvme0n1p7 259:6 0 155.1G 0 part
root@zen:~#


Any pointers would be very much appreciated.

Thanks
 
you need to use the CLI or API, this is not available on the GUI. please also note that adding a local device prevents migration!

Code:
qm set VMID -SLOT /path/to/block/device/on/host

e.g.,
Code:
qm set 100 -scsi2 /dev/sda
 
you need to use the CLI or API, this is not available on the GUI. please also note that adding a local device prevents migration!

Code:
qm set VMID -SLOT /path/to/block/device/on/host

e.g.,
Code:
qm set 100 -scsi2 /dev/sda

Ah, thank you! I shall try this when I get home this evening, but it makes sense.
 
I now have the swap setup I was trying to achieve - thank you.

Migration probably isn't an issue for me (yet) as this is just my home server. But I will bear that in mind if it ever becomes relevant.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!