mgutt Posted September 11, 2021 Share Posted September 11, 2021 This is a very special use case when you only need to run small and temporary containers with small disk usage and don't want to use your Array Disks (HDDs). Note: The RAM-Disk, all containers, their data and docker.img are lost after reboot / power-outage. So you maybe want to add the code to your Go-File to automatically re-create the RAM-Disk on reboot. Of course the containers will be still lost. This means, this guide is only useful for containers which contain tools for temporary usage. Feel free to use a persistent appdata path, but of course the containers will be re-downloaded on every reboot. In this example we use a 2GB RAM Disk (change count=2000 if you need more): mkdir -p /mnt/disks/docker/appdata mkdir /mnt/disks/docker/service mount -t ramfs ramfs /mnt/disks/docker/appdata/ dd if=/dev/zero of=/mnt/disks/docker/appdata/docker.img bs=1M count=2000 mkfs.xfs /mnt/disks/docker/appdata/docker.img mount -o loop /mnt/disks/docker/appdata/docker.img /mnt/disks/docker/service Now /mnt/disks/docker/appdata/ is a RAM-Disk. In this path we created a 2GB xfs-formatted docker.img file, which is mounted on /mnt/disks/docker/service. By that we need to change the docker settings as follows: After installing a "jlesage/mkvtoolnix" container, it returns the following usage: du -hd1 /mnt/disks/docker 2.0G /mnt/disks/docker/appdata 651M /mnt/disks/docker/service 2.6G /mnt/disks/docker df -ah | grep /mnt/disks/docker none 0 0 0 - /mnt/disks/docker/appdata /dev/loop2 2.0G 386M 1.6G 20% /mnt/disks/docker/service tmpfs 7.7G 68K 7.7G 1% /mnt/disks/docker/service/containers overlay 2.0G 386M 1.6G 20% /mnt/disks/docker/service/overlay2/3e72cc7e467ed786983b98fbb8273ac2f922be7dd087c87811a5dadf30c0c19a/merged This means we used 651MB of the 2GB docker.img. Any data which would be written to /appdata would raise the RAM usage! You want to reset everything? Execute this: umount /mnt/disks/docker/service umount /mnt/disks/docker/appdata rm -r /mnt/disks/docker/* Quote Link to comment
Niklas Posted April 30, 2023 Share Posted April 30, 2023 (edited) Would it be complicated to copy/move the docker-xfs.img to pool or array at shutdown and back again to ram at power up? I have lots of unused ram so I have been thinking of this for a while. It will save lots on wear on the SSD pools. Edited April 30, 2023 by Niklas Quote Link to comment
mgutt Posted April 30, 2023 Author Share Posted April 30, 2023 1 hour ago, Niklas said: Would it be complicated to copy/move the docker-xfs.img to pool or array at shutdown and back again to ram at power up? Consider this modification: Quote Link to comment
Niklas Posted April 30, 2023 Share Posted April 30, 2023 1 minute ago, mgutt said: Consider this modification: I have used your script for some time, thanks! It saves much but I still have several GBs written to cache pool every day (like 30+GB). Not counting any stuff affected by mover but I also have appdata on cache of course, but nothing that should write that amount every day. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.