howto create shared ramdisk on proxmox to lxc container?

Egner

Renowned Member
Aug 2, 2015
96
1
73
I have done a ramdisk on my proxmox host that using LXC.

This is my fstab on proxmox host :
tmpfs /mnt/ramdisk tmpfs nodev,nosuid,nodiratime,size=40G 0 0

Code:
Filesystem            Size  Used Avail Use% Mounted on
udev                   10M     0   10M   0% /dev
tmpfs                  13G   58M   13G   1% /run
/dev/dm-0              15G  4.0G   10G  29% /
tmpfs                  32G   63M   32G   1% /dev/shm
tmpfs                 5.0M     0  5.0M   0% /run/lock
tmpfs                  32G     0   32G   0% /sys/fs/cgroup
tmpfs                  40G  1.7M   40G   1% /mnt/ramdisk
/dev/mapper/pve-data  100G   23G   77G  23% /var/lib/vz
/dev/fuse              30M   32K   30M   1% /etc/pve
cgmfs                 100K     0  100K   0% /run/cgmanager/fs


The problem is that i have setup a config for my lxc container like this:
mp0: /mnt/ramdisk,mp=/mnt/ramdisk
rootfs: local:105/vm-105-disk-1.raw,size=40G

And the lxc cointainer is mapping the /mnt/ramdisk to the server with the 40G space. But if i try to just save something to the folder it takes the ram from the lxc container and not the shared folder.
So can i on any how change the folder from tmpfs to something like common /dev/loop4 or something so it don't se it as a ramdisk itself.

this is how it look like in the vm:

Code:
root@ngx01-p2:/mnt# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop3       40G   11G   27G  29% /
none            100K     0  100K   0% /dev
cgroup           12K     0   12K   0% /sys/fs/cgroup
tmpfs            32G     0   32G   0% /sys/fs/cgroup/cgmanager
tmpfs            40G  1.7M   40G   1% /mnt/ramdisk
tmpfs           6.3G   44K  6.3G   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           1.6G     0  1.6G   0% /run/shm


thanks.
 
the behaviour is correct though - a tmpfs is memory exposed as file system, so its usage is accounted as used memory..
 
so, if I wanted to create a say 32gb ramdisk on the host system and then mount it into two lxc containers so that they can both read/write to it, the containers would (each) need to have at least 32 gb of memory?
 
yes, if they should be able to fully write to that tmpfs. it's not the usage, but the writes (including deletion in the other direction) which are accounted to the cgroup. where the tmpfs comes from doesn't matter - the cgroup is on another level than mount namespaces, even though they are both used (together with other stuff) to make up a "container" ;)
 

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!