Sample Header Ad - 728x90

Weird result mounting a tmpfs as root in the directory tree

2 votes
1 answer
170 views
Using unshare -Umr I created a new user, mount namespaces where the calling process is moved into. Then via mount -t tmpfs tmpfs / I mounted a new tmpfs instance on the root / of the directory tree within the new mount namespace. Since the tmpfs is empty I would expect to see an empty list from the command ls -la /, however here is the output: ubuntu@ubuntu:~$ unshare -Umr /bin/bash root@ubuntu:~# mount -t tmpfs tmpfs / root@ubuntu:~# ls -la / total 5309704 drwxr-xr-x 24 nobody nogroup 4096 Nov 22 2023 . drwxrwxrwt 2 root root 40 Nov 11 15:47 .. drwxr-xr-x 2 nobody nogroup 4096 Jan 25 2023 bin drwxr-xr-x 3 nobody nogroup 4096 Jan 25 2023 boot drwxr-xr-x 2 nobody nogroup 4096 Nov 11 2019 cdrom drwxr-xr-x 17 nobody nogroup 3820 Aug 22 14:22 dev drwxr-xr-x 105 nobody nogroup 4096 Mar 14 2024 etc -rw-r--r-- 1 root root 1688371200 Jan 19 2021 GISO drwxr-xr-x 3 nobody nogroup 4096 Nov 11 2019 home lrwxrwxrwx 1 nobody nogroup 34 Jan 25 2023 initrd.img -> boot/initrd.img-4.15.0-202-generic lrwxrwxrwx 1 nobody nogroup 34 Jan 25 2023 initrd.img.old -> boot/initrd.img-4.15.0-132-generic drwxr-xr-x 21 nobody nogroup 4096 Jan 25 2023 lib drwxr-xr-x 2 nobody nogroup 4096 Jan 25 2023 lib64 drwx------ 2 nobody nogroup 16384 Nov 11 2019 lost+found drwxr-xr-x 2 nobody nogroup 4096 Feb 10 2021 media drwxr-xr-x 2 nobody nogroup 4096 Aug 5 2019 mnt drwxr-xr-x 3 nobody nogroup 4096 Nov 26 2020 opt dr-xr-xr-x 123 nobody nogroup 0 Aug 22 12:22 proc drwx------ 4 nobody nogroup 4096 Dec 6 2023 root drwxr-xr-x 24 nobody nogroup 820 Nov 11 15:20 run drwxr-xr-x 2 nobody nogroup 12288 Jan 25 2023 sbin drwxr-xr-x 4 nobody nogroup 4096 Nov 11 2019 snap drwxr-xr-x 3 nobody nogroup 4096 Jan 24 2020 srv -rw------- 1 nobody nogroup 3748659200 Nov 11 2019 swap.img dr-xr-xr-x 13 nobody nogroup 0 Nov 11 15:40 sys drwxrwxrwt 10 nobody nogroup 4096 Nov 11 15:42 tmp drwxr-xr-x 10 nobody nogroup 4096 Aug 5 2019 usr drwxr-xr-x 13 nobody nogroup 4096 Aug 5 2019 var lrwxrwxrwx 1 nobody nogroup 31 Jan 25 2023 vmlinuz -> boot/vmlinuz-4.15.0-202-generic lrwxrwxrwx 1 nobody nogroup 31 Jan 25 2023 vmlinuz.old -> boot/vmlinuz-4.15.0-132-generic root@ubuntu:~# as in the filesystem mounted as / before the tmpfs was mounted over. Why I am getting this result ?
Asked by CarloC (385 rep)
Nov 11, 2024, 01:03 PM
Last activity: Dec 2, 2024, 03:54 PM