Questions tagged [bind-mount]
133 questions
563
votes
3 answers
What is a bind mount?
What is a “bind mount”? How do I make one? What is it good for?
I've been told to use a bind mount for something, but I don't understand what it is or how to use it.
Gilles 'SO- stop being evil'
- 807,993
- 194
- 1,674
- 2,175
42
votes
3 answers
Why doesn't mount respect the read only option for bind mounts?
On my Arch Linux system (Linux Kernel 3.14.2) bind mounts do not respect the read only option
# mkdir test
# mount --bind -o ro test/ /mnt
# touch /mnt/foo
creates the file /mnt/foo. The relevant entry in /proc/mounts is
/dev/sda2 /mnt ext4…
StrongBad
- 5,151
- 9
- 47
- 73
36
votes
5 answers
List only bind mounts
Rather than using mount | grep, I'd like to use mount -l -t bind, but that doesn't work, and -t none shows all mounts.
l0b0
- 50,672
- 41
- 197
- 360
22
votes
1 answer
mount --bind other user as myself
I'm using fstab to bind a folder that belongs to another user in one of my own directories. I know that I can map users when I mount an SSHFS, I've been doing some research and I can't find a mount --bind equivalent.
Is there any way I can mount…
Niko
- 555
- 4
- 8
- 16
15
votes
2 answers
How is findmnt able to list bind mounts?
A lot of people keep saying that Linux does not keep information about bind mounts, so there is no way to get a list of them and their sources. Here are some examples:
from one of the the comments here:
IIRC this information is not kept anywhere:…
Melab
- 3,808
- 8
- 29
- 49
15
votes
1 answer
Unmount a rbind mount without affecting the original mount
Asked on serverfault but didn't get enough attention, so reposted here, with the hope some people here know the answer.
There is another question discussing about umounting rbind mounts, but the solution has unwanted effect. Consider the following…
icando
- 429
- 4
- 10
14
votes
1 answer
Why can't I bind-mount "/" inside a user namespace?
Why doesn't this work?
$ unshare -rm mount --bind / /mnt
mount: /mnt: wrong fs type, bad option, bad superblock on /, missing codepage or helper program, or other error.
These work ok:
$ unshare -rm mount --bind /tmp /mnt
$ unshare -rm mount --bind…
sourcejedi
- 48,311
- 17
- 143
- 296
14
votes
3 answers
Why is my bind mount visible outside its mount namespace?
So I'm trying to get a handle on how Linux's mount namespace works. So, I did a little experiment and opened up two terminals and ran the following:
Terminal 1
root@goliath:~# mkdir a b
root@goliath:~# touch a/foo.txt
root@goliath:~# unshare…
FatalError
- 243
- 2
- 6
13
votes
1 answer
How can I make a device available inside a systemd-nspawn container with user namespacing?
I would like to mount an encrypted image file using cryptsetup inside a systemd-nspawn container. However, I get this error message:
[root@container ~]# echo $key | cryptsetup -d - open luks.img luks
Cannot initialize device-mapper. Is dm_mod kernel…
sjy
- 826
- 8
- 22
11
votes
2 answers
Why can't I create a `hardlink` to a file from a "mount --bind" directory on the same filesystem?
Original Problem
I have a file on one filesystem: /data/src/file
and I want to hard link it to: /home/user/proj/src/file
but /home is on one disk, and /data is on another so I get an error:
$ cd /home/user/proj/src
$ ln /data/src/file .
ln: failed…
SO_fix_the_vote_sorting_bug
- 213
- 2
- 6
11
votes
4 answers
Unable to delete files to trash in a bind-mounted filesystem
I'm trying to set up shared home directory for two Linux installations and thus I'm using bind-mounts. My user is named dbz and his home directory is /home/dbz. I also have shared directory /home/shared where I store my shared files (this folder is…
dbzix
- 111
- 1
- 6
10
votes
1 answer
Umount device after bind mounting directories: is it safe?
I have a home partition which is shared by mulitple distros on the same box. I'm using bind mounts from fstab. Each Linux install has something like this:
UUID=[...] /mnt/data ext4 nodev,nosuid 0 2
/mnt/data/arch /home none …
Peter-Paul van Gemerden
- 203
- 2
- 5
10
votes
1 answer
bind mounting source to itself
What does mount --bind /dir1 /dir1 do? I've read https://www.kernel.org/doc/Documentation/filesystems/sharedsubtree.txt however it doesn't give a clear explanation. Looks like it is valid not only for directories, but also for files.
Mark
- 101
- 1
- 3
8
votes
1 answer
why do Linux bind mounts disappear if the mount point's inode changes?
In summary: if you bind mount a file /tmp/a on top of /tmp/b in a new mount namespace, but then the inode of /tmp/b changes in the parent namespace, the bind mount disappears in the child namespace. I'm trying to understand why.
mount(8) doesn't…
Shivaram Lingamneni
- 256
- 1
- 6
8
votes
2 answers
Directly mount btrfs subvolume or bind mount if already visible
If /dev/sda1 is a btrfs filesystem with subvol's root and persistent
And I've set the default subvol to root
Also, I've mounted /dev/sda1 (again root is default) to /
And I've mounted /dev/sda1 subvolid=0 to /btrfs, so I can access all the other…
user1902689
- 1,178
- 3
- 12
- 23