← Back to team overview

kernel-packages team mailing list archive

[Bug 1574514] Re: Strange behaviour with mount --bind

 

I just found this mail which describes a problem which has the same
root: http://www.spinics.net/lists/linux-fsdevel/msg92569.html:

root@xubuntu:~# mkdir tmp1
root@xubuntu:~# mkdir tmp2
root@xubuntu:~# mount -o bind /dev tmp1
root@xubuntu:~# ls tmp1/pts
root@xubuntu:~# mount -o bind /dev/pts tmp1/pts
root@xubuntu:~# ls tmp1/pts
0  1  2  3  4  5  6  ptmx
root@xubuntu:~# mount -o bind /dev tmp2
root@xubuntu:~# ls tmp1/pts tmp2/pts
tmp1/pts:
0  1  2  3  4  5  6  ptmx

tmp2/pts:
root@xubuntu:~# mount -o bind /dev/pts tmp2/pts
root@xubuntu:~# ls tmp1/pts tmp2/pts
tmp1/pts:
0  1  2  3  4  5  6  ptmx

tmp2/pts:
0  1  2  3  4  5  6  ptmx
root@xubuntu:~# grep pts /proc/mounts
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
devpts /root/tmp1/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
devpts /mnt/source/root/tmp1/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
devpts /root/tmp2/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
devpts /mnt/source/root/tmp1/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
devpts /root/tmp1/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
devpts /mnt/source/root/tmp2/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0

# now you see: pts got mounted to tmp1 again and even to /mnt/source
from the first test - why???

root@xubuntu:~# umount tmp1/pts

# tmp1/pts should now be empty after unmounting, but it is mounted twice
so the files are still visible. on the other hand: why did tmp2/pts
unmount???:

root@xubuntu:~# ls tmp1/pts tmp2/pts
tmp1/pts:
0  1  2  3  4  5  6  ptmx

tmp2/pts:
root@xubuntu:~# umount tmp1/pts

# umount was possible a second time

root@xubuntu:~# ls tmp1/pts tmp2/pts
tmp1/pts:

tmp2/pts:

root@xubuntu:~#

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/1574514

Title:
  Strange behaviour with mount --bind

Status in linux package in Ubuntu:
  Confirmed

Bug description:
  The following problem appears with Ubuntu wily 15.10 and xenial 16.04:

  I bind-mount my rootfs to a temporary folder. I explicitly use --bind
  and NOT --rbind. The result is as expected: I only see the files which
  are in the rootfs, any other mounts are invisible in this directory.
  But when I mount another directory later, It automatically also gets
  mounted in my temporary directory.

  Example (tested with the Live CD xubuntu-16.04-desktop-amd64.iso):

  root@xubuntu:~# mkdir /mnt/source
  root@xubuntu:~# mkdir /mnt/target
  root@xubuntu:~# mount --bind / /mnt/source
  root@xubuntu:~# ls /mnt/source/mnt/target/
  root@xubuntu:~# mount -t tmpfs none /mnt/target
  root@xubuntu:~# touch /mnt/target/testfile
  root@xubuntu:~# ls /mnt/source/mnt/target/
  testfile

  The testfile in the last line SHOULD NOT APPEAR because
  /mnt/source/mnt/target/ should not be mounted.

  I don't find an explanation for this behaviour.

  I found this because I wanted to run:

  tar cpC /mnt/source/ . | tar xpC /mnt/target/

  The command began to cyclic copy
  /mnt/source/mnt/target/mnt/target/mnt/target/mnt/target/

  This scenario always worked in the past versions of Ubuntu and Debian

  ProblemType: Bug
  DistroRelease: Ubuntu 16.04
  Package: linux-image-4.4.0-21-generic 4.4.0-21.37
  ProcVersionSignature: Ubuntu 4.4.0-21.37-generic 4.4.6
  Uname: Linux 4.4.0-21-generic x86_64
  ApportVersion: 2.20.1-0ubuntu2
  Architecture: amd64
  AudioDevicesInUse:
   USER        PID ACCESS COMMAND
   /dev/snd/controlC0:  xubuntu    1766 F.... pulseaudio
  CasperVersion: 1.376
  Date: Mon Apr 25 08:40:52 2016
  IwConfig:
   enp0s3    no wireless extensions.
   
   lo        no wireless extensions.
  LiveMediaBuild: Xubuntu 16.04 LTS "Xenial Xerus" - Release amd64 (20160420.1)
  Lsusb:
   Bus 001 Device 002: ID 80ee:0021 VirtualBox USB Tablet
   Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
  MachineType: innotek GmbH VirtualBox
  ProcEnviron:
   TERM=xterm
   PATH=(custom, no user)
   LANG=en_US.UTF-8
   SHELL=/bin/bash
  ProcFB:
   
  ProcKernelCmdLine: file=/cdrom/preseed/hostname.seed boot=casper initrd=/casper/initrd.lz quiet splash --- keyboard-configuration/layoutcode=ch
  PulseList: Error: command ['pacmd', 'list'] failed with exit code 1: No PulseAudio daemon running, or not running as session daemon.
  RelatedPackageVersions:
   linux-restricted-modules-4.4.0-21-generic N/A
   linux-backports-modules-4.4.0-21-generic  N/A
   linux-firmware                            1.157
  RfKill:
   
  SourcePackage: linux
  UpgradeStatus: No upgrade log present (probably fresh install)
  dmi.bios.date: 12/01/2006
  dmi.bios.vendor: innotek GmbH
  dmi.bios.version: VirtualBox
  dmi.board.name: VirtualBox
  dmi.board.vendor: Oracle Corporation
  dmi.board.version: 1.2
  dmi.chassis.type: 1
  dmi.chassis.vendor: Oracle Corporation
  dmi.modalias: dmi:bvninnotekGmbH:bvrVirtualBox:bd12/01/2006:svninnotekGmbH:pnVirtualBox:pvr1.2:rvnOracleCorporation:rnVirtualBox:rvr1.2:cvnOracleCorporation:ct1:cvr:
  dmi.product.name: VirtualBox
  dmi.product.version: 1.2
  dmi.sys.vendor: innotek GmbH

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1574514/+subscriptions


References