We use a kernel intrinsic to work with shared memory objects (shm_open
) and never really open "a file on disk". The kernel merely condensates the shared memory object as a file but it really isn't one. So moving it somewhere else is unlikely to work.
Test:
8a21ac6ff7eb:/# ls -lh /dev/shm
total 2.1M
-rw------- 1 pihole pihole 340K Dec 1 05:51 FTL-clients
-rw------- 1 pihole pihole 4.0K Dec 1 05:51 FTL-clients-lookup
-rw------- 1 pihole pihole 328 Dec 1 05:51 FTL-counters
-rw------- 1 pihole pihole 20K Dec 1 05:51 FTL-dns-cache
-rw------- 1 pihole pihole 4.0K Dec 1 05:51 FTL-dns-cache-lookup
-rw------- 1 pihole pihole 4.0K Dec 1 05:51 FTL-domains
-rw------- 1 pihole pihole 4.0K Dec 1 05:51 FTL-domains-lookup
-rw------- 1 pihole pihole 556K Dec 1 05:51 FTL-fifo-log
-rw------- 1 pihole pihole 88 Dec 1 05:51 FTL-lock
-rw------- 1 pihole pihole 8.0K Dec 1 05:51 FTL-overTime
-rw------- 1 pihole pihole 4.0K Dec 1 05:51 FTL-per-client-regex
-rw------- 1 pihole pihole 288K Dec 1 05:51 FTL-queries
-rw------- 1 pihole pihole 768K Dec 1 05:51 FTL-recycler
-rw------- 1 pihole pihole 144 Dec 1 05:51 FTL-settings
-rw------- 1 pihole pihole 80K Dec 1 05:51 FTL-strings
-rw------- 1 pihole pihole 28K Dec 1 05:51 FTL-upstreams
8a21ac6ff7eb:/# mv /dev/shm/FTL-* ~
8a21ac6ff7eb:/# ls -lh ~
total 5.3M
-rw------- 1 pihole pihole 340K Dec 1 05:51 FTL-clients
-rw------- 1 pihole pihole 4.0K Dec 1 05:51 FTL-clients-lookup
-rw------- 1 pihole pihole 328 Dec 1 05:51 FTL-counters
-rw------- 1 pihole pihole 20K Dec 1 05:51 FTL-dns-cache
-rw------- 1 pihole pihole 4.0K Dec 1 05:51 FTL-dns-cache-lookup
-rw------- 1 pihole pihole 4.0K Dec 1 05:51 FTL-domains
-rw------- 1 pihole pihole 4.0K Dec 1 05:51 FTL-domains-lookup
-rw------- 1 pihole pihole 556K Dec 1 05:51 FTL-fifo-log
-rw------- 1 pihole pihole 88 Dec 1 05:51 FTL-lock
-rw------- 1 pihole pihole 8.0K Dec 1 05:51 FTL-overTime
-rw------- 1 pihole pihole 4.0K Dec 1 05:51 FTL-per-client-regex
-rw------- 1 pihole pihole 288K Dec 1 05:51 FTL-queries
-rw------- 1 pihole pihole 768K Dec 1 05:51 FTL-recycler
-rw------- 1 pihole pihole 144 Dec 1 05:51 FTL-settings
-rw------- 1 pihole pihole 80K Dec 1 05:51 FTL-strings
-rw------- 1 pihole pihole 28K Dec 1 05:51 FTL-upstreams
drwxr-xr-x 1 root root 4.0K Dec 1 05:01 bin
-rw-r--r-- 1 root root 308 Dec 1 05:51 crontab.txt
drwxr-xr-x 5 root root 360 Dec 1 05:51 dev
drwxr-xr-x 1 root root 4.0K Dec 1 05:51 etc
drwxr-xr-x 1 root root 4.0K Dec 1 05:01 home
drwxr-xr-x 1 root root 4.0K Dec 1 05:01 lib
-rw------- 1 pihole pihole 3.1M Nov 25 00:00 macvendor.db
drwxr-xr-x 5 root root 4.0K Sep 6 11:35 media
drwxr-xr-x 2 root root 4.0K Sep 6 11:35 mnt
drwxr-xr-x 1 root root 4.0K Dec 1 05:01 opt
-rw-r--r-- 1 root root 8 Dec 1 05:01 pihole.docker.tag
dr-xr-xr-x 547 root root 0 Dec 1 05:51 proc
drwx------ 2 root root 4.0K Sep 6 11:35 root
drwxr-xr-x 1 root root 4.0K Dec 1 05:51 run
drwxr-xr-x 1 root root 4.0K Dec 1 05:01 sbin
drwxr-xr-x 2 root root 4.0K Sep 6 11:35 srv
dr-xr-xr-x 13 root root 0 Dec 1 05:51 sys
drwxrwxrwt 1 root root 4.0K Dec 1 05:51 tmp
drwxr-xr-x 1 root root 4.0K Dec 1 05:01 usr
drwxr-xr-x 1 root root 4.0K Dec 1 05:01 var
8a21ac6ff7eb:/# ls -lh /dev/shm
total 0
8a21ac6ff7eb:/# df -h
Filesystem Size Used Avail Use% Mounted on
overlay 467G 284G 160G 65% /
tmpfs 64M 0 64M 0% /dev
shm 64M 2.1M 62M 4% /dev/shm
/dev/mapper/vgubuntu-root 467G 284G 160G 65% /etc/hosts
tmpfs 7.8G 0 7.8G 0% /proc/asound
tmpfs 7.8G 0 7.8G 0% /proc/acpi
tmpfs 7.8G 0 7.8G 0% /proc/scsi
tmpfs 7.8G 0 7.8G 0% /sys/firmware
Even after moving away the file handle, the memory is still accounted for in /dev/shm
as expected. These simply aren't "files" and users really often misunderstand that the term "file" is often only indirect under Linux. Look only at /proc
where nothing is actually a "real" file. Or socket files, ...