Questions tagged [bind-mount]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
312
votes
1answer
233k views

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.
33
votes
3answers
18k views

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 ...
23
votes
5answers
25k views

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.
14
votes
1answer
5k views

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 --...
13
votes
1answer
811 views

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 -...
12
votes
2answers
2k views

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@...
10
votes
1answer
2k views

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 ...
9
votes
2answers
3k views

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 ...
8
votes
2answers
2k views

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 /...
7
votes
1answer
5k views

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,...
7
votes
3answers
5k views

Mount directory onto root

I have a folder containing certain files. Is there a way to mount it onto /, so that the contents of a given directory appear in the corresponding locations in /? In my case, the directories contain ...
7
votes
1answer
6k views

bind mount /var with fstab

I'm messing around with having both /home and /var on a separate partition which will be mounted in /myhdd. Next, I use mount --bind to mount /var on /myhdd/var and /home on /myhdd/home. With this ...
6
votes
1answer
580 views

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'...
5
votes
2answers
333 views

Meaning of statement that 'getcwd functions work correctly' in FreeBSD man page for mount_nullfs?

In FreeBSD, man mount_nullfs states that: The primary differences between a virtual copy of the file system and a symbolic link are that the getcwd(3) functions work correctly in the virtual ...
5
votes
3answers
4k views

How do I set up bind mounts on startup correctly in the systemd world?

systemd, trying to be smart, parallelizes mounting entries of /etc/fstab. Unfortunately, this randomly messes up bind mounts: A look at my fstab, cleaned up a bit: $ grep -Ev 'ntfs|swap|#' /etc/...
5
votes
1answer
3k views

Two *different* mountpoints having the *same* absolute path (bind-mount problem)

Scenario a NFS share is mounted on /mnt/temp/dir (and other shares are mounted in subdirectories), I umount everything there but supposedly, it doesn't work well (maybe I start with umount /mnt/temp/...
4
votes
5answers
2k views

pwd: show mountpoint

I have mounted a directory to another directory using mount --bind so that an sftp user of my server can access this directory. mount --bind /path/share /path/home/user/stuff I have put this in /etc/...
4
votes
1answer
999 views

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 ...
4
votes
2answers
655 views

Mounting new filesystem affects non-recursive bind mounts?

It hasn't always behaved this way, but nowadays I get this inconsistent behaviour. Bind mounts don't copy existing mounts (unless you use --rbind), but new mounts (and unmounts) get copied ...
4
votes
0answers
227 views

openvpn route-up script no mount permissions

I'm trying to mount a couple of nfs shares after my openvpn tunnel is up. Previously this worked on ubuntu 12.04 and ubuntu 14.04. I made a clean install with ubuntu 16.04 and can't get it to work. ...
4
votes
1answer
2k views

CentOS 7 unable to cleanly umount a bind mount using rbind and rslave

The following sequence of commands will fail on CentOS 7 (kernel version: 3.10.0-327.10.1.el7.x86_64): [hidden]$ mkdir -p A B/a C/b [hidden]$ sudo mount --bind A B/a [hidden]$ sudo mount --rbind B C/...
3
votes
5answers
1k views

Link 2 existing files

I have 2 existing files : abcd and xyz. $ cat abcd abcd $ cat xyz xyz Now, when I try to softlink these files, I get this message : ln: cannot create xyz: File exists I do not want to use ln -sf ...
3
votes
2answers
1k views

Mount --bind in the same filesystem move files as in the same filesystem

If I mount --bind /a in /b and if I mv /a/bigfile /b/ it will take a lot of type (if the origin file is big). This will actually copy the file and then delete from the origin instead of simple update ...
3
votes
1answer
694 views

How to get mount information of host inside a docker container

I need the mountpoints of all disks attached to a host inside a docker container. The mount information is available in /proc/1/mounts file, but I cannot access that file on all OS. When I run the ...
3
votes
2answers
638 views

How to split FHS read-only and read/write directories across two disks with Linux/systemd, without partitioning the raed/write disk?

My objective is to have the physical storage for the Linux FHS read/write directories (/home, /srv, /tmp, /var) on a separate (logical or physical) disk from the potentially read-only rest of the root ...
3
votes
1answer
83 views

Why do repeated bind mounts create entries for the source directory?

Why does a repeated bind mount create multiple entries in /proc/mounts? # md -p /mnt/test-mount/{source,target} # mount --bind /mnt/test-mount/{source,target} # grep test-mount /proc/mounts /dev/...
3
votes
1answer
335 views

How to exclude bind mounts from findmnt results list?

In a bash script I have the following lines: TARGETS="$(findmnt -n -v -t btrfs -o TARGET --list)" UUIDS="$(findmnt -n -v -t btrfs -o UUID --list)" I run this script on some servers (running Arch ...
3
votes
1answer
410 views

AppArmor and bind-mounts

Can someone outline the semantics of AppArmor with respect to bind-mounted folders? As I understand after reading the documentation (1, 2, 3, 4) - yes, I am using Ubuntu 12.04 with the 3.8 kernel - ...
3
votes
1answer
782 views

How can I automatically make ZFS filesyatems mount shared / rshared?

I have a number of ZFS sub-filesystems (so that I can granularly manage snapshots and ZFS options) like so: tank/media tank/media/pictures tank/media/pictures/photos tank/media/movies tank/media/...
3
votes
1answer
967 views

bind mounts by systemd don't magically work with systemd-tmpfiles?

I have an weird challenge from on my Debian 8 box. The background is I want to mount some directories as tmpfs, to avoid physical IO (disk wakeup / flash wear). Probably I should just mount a ...
3
votes
1answer
64 views

Why can I not bind a mount namespace to a file

I observe the following: As unprivileged user in shell No 1: user@box:~$ sysctl kernel.unprivileged_userns_clone kernel.unprivileged_userns_clone = 1 user@box:~$ unshare --mount --user nobody@box:~$ ...
3
votes
0answers
49 views

Is linux mount propagation asynchronous to the mount call?

I have two processes in different mount namespaces. They have a shared directory bind mounted to /mnt/share. The "master" uses MS_SHARED propagation for the mount, while the "slave" uses MS_SLAVE. ...
3
votes
0answers
228 views

Workaround for mount -bind behavior change between wheezy and jessie?

I recently upgraded a system from wheezy to jessie that makes use of bind mounts. But with the update the behavior of the bind mount has changed, and now acts as bind one filesystem will recursively ...
3
votes
2answers
816 views

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 ...
3
votes
0answers
53 views

how to see original and --bind mountpoints [duplicate]

Lest say I mount a usb drive to /mnt and next I run this... mount --bind /mnt /tmp/test.d It's a successful bind, but now when I run lsblk only the bind point shows. How can I get all bound and ...
2
votes
1answer
370 views

ls -la doesn't display correct permission for a mount --bind folder

Please read the following steps to understand my problem, Execute following commands mkdir ~/src mkdir ~/destination sudo mount ~/src ~/destination --bind -o ro src folder has been bind mounted to ...
2
votes
1answer
590 views

Mounting two folders to corresponding directories within external volume?

I'm trying to mount /etc/folder and /var/folder to the same external volume UUID=xyz. This external volume already has subdirectories etc_folder and var_folder and has been formatted and available to ...
2
votes
1answer
48 views

Mounting is slow after 4000 mounts

I have a need to create about 10,000 total bind mounts for various chroots. After about 3000-4000 mounts, it slows down significantly from 100/s to about 5-10/s. I'm assuming it's hitting some weird ...
2
votes
1answer
417 views

use a different socket than /dev/log, system-wide

Is there a way to make a whole Debian (Jessie) installation use a different syslog socket than /dev/log (like, for example, /tmp/my-other-log) ? Reason: I'm running Debian Jessie in a chroot ...
2
votes
0answers
1k views

CentOS 7 - Can't mount /var/tmp as bind

I'm working on a freshly installed CentOS7 with LVM. I want to bind mount /var/tmp to /tmp and added the following to /etc/fstab. /tmp /var/tmp none rw,nodev,noexec,nosuid,bind 0 0 ...
2
votes
0answers
43 views

Does the Linux kernel have knowledge of bind mounts? [duplicate]

I've been looking for a way to list bind mounts or at least determine if a particular mount is a bind mount. Several answers on this website say that because it is a parameter of a mount operation it ...
2
votes
0answers
443 views

How to 'snapshot' a chroot?

I want to perform something similar to a 'clone' on vmware fusion/virtualbox/a VM manager. Host and chroot are both ubuntu. One complicating factor may be that this chroot may have one or more child ...
2
votes
1answer
979 views

How to bind arduino as a fix block-device — /dev/ttyACM0?

I want to bind my Arduino Mega as /dev/ttyACM0. Sometimes, it turns out to be /dev/ttyACM0 and sometimes as /dev/ttyACM1. I have taken help from this question and this tutorial Someone please help ...
1
vote
2answers
882 views

Bind Mounting across different file systems

Does the command mount -o bind allow mounting a folder from a different file system (vfat, ntfs) to a folder in Linux native partition?
1
vote
1answer
138 views

/root as bind mount?

I am migrating my system from Debian 32 bit to Debian 64 bit. It is installed on /dev/sda2, so I created /dev/sda3, installed the new system there, synched installed packages and configuration files ...
1
vote
2answers
199 views

What link should i use for home- & owncloud-data?

the plan is to built a debian-based sever with owncloud for syncing addressbooks, calendars, files etc. and also access large video-files in the LAN via webdav from some kodi-clients (maybe also use ...
1
vote
1answer
1k views

Is it possible to mount a file with different ownership/permissions?

I have been experimenting with privilege escalation using the mount command and would like to know if it is possible to create a suid file owned by root without having access to any external device. i....
1
vote
1answer
278 views

/etc/fstab fails to bind mount on boot, but running mount -a works correctly

I'm running a modified WD MyCloud (Gen 1) NAS with Debian 8 (Jessie) installed on it. Due to the nuances of the device, I can't resize the root partition, and am struggling with space on it. To ...
1
vote
1answer
375 views

Shadow bind mount in fstab

I have a custom, non-default Ubuntu installation, where I use my other Linux distro's boot manager (rEFInd). As such, I don't want Ubuntu to see my EFI partition, on the principle that it has no ...
1
vote
1answer
466 views

How to unmount a mountpoint with rbind and rslave?

Trying to use a chrooted system via mount -B stage3 gentoo mount -t sysfs none gentoo/sys mount -t proc none gentoo/proc mount -R /dev gentoo/dev mount --make-rslave gentoo/dev unshare --fork chroot ...