-1

I have access to a Ubuntu system which is like this:

$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT [...] sda 8:0 0 1.8T 0 disk └─sda1 8:1 0 1.8T 0 part /mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 nvme0n1 259:0 0 477G 0 disk ├─nvme0n1p1 259:1 0 650M 0 part /boot/efi └─nvme0n1p2 259:2 0 372.5G 0 part / 

I have setup a Debian/sid schroot like this:

$ cat /etc/schroot/chroot.d/sid64 [sid64] description=Contains the SPICE program aliases=sid type=directory directory=/home/malat/schroots/sid-root users=malat root-groups=root profile=desktop personality=linux preserve-environment=true 

I have not changed anything to /etc/schroot/default/fstab, and when going inside my schroot sid64 here is what I see:

$ schroot -c sid (sid64)$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT [...] sda 8:0 0 1.8T 0 disk └─sda1 8:1 0 1.8T 0 part nvme0n1 259:0 0 477G 0 disk ├─nvme0n1p1 259:1 0 650M 0 part └─nvme0n1p2 259:2 0 372.5G 0 part /var/lib/dbus 

If I manually do:

$ sudo mount /dev/sda1 /mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 $ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 1.8T 0 disk └─sda1 8:1 0 1.8T 0 part /mnt/bdc64c37-340a-49e5-8184-a69e01e5e231 nvme0n1 259:0 0 477G 0 disk ├─nvme0n1p1 259:1 0 650M 0 part └─nvme0n1p2 259:2 0 372.5G 0 part /var/lib/dbus 

How can I automatically mount /mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 under my schroot (this is my main disk where my data is located) ?


So far I tried a naive:

$ sudo mkdir /home/malat/schroots/sid-root/mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 $ tail -1 /etc/schroot/default/fstab /dev/disk/by-uuid/dbc64c37-340a-49e5-8184-a69e01e5e231 /mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 none rw,bind 0 0 $ schroot -c sid (sid64)$ ls -al /dev/disk/by-uuid/dbc64c37-340a-49e5-8184-a69e01e5e231 lrwxrwxrwx 1 root root 10 Jan 8 01:00 /dev/disk/by-uuid/dbc64c37-340a-49e5-8184-a69e01e5e231 -> ../../sda1 

as well as:

$ tail -1 /etc/schroot/default/fstab /mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 /mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 none rw,bind 0 0 

Both did not work for me.


I also tried a naive:

$ sudo mount --rbind /mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 /home/malat/schroots/sid-root/mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 $ mount | grep dbc64c37 /dev/sda1 on /mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 type ext4 (rw,nosuid,nodev,relatime,x-gvfs-show) /dev/sda1 on /home/malat/schroots/sid-root/mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 type ext4 (rw,nosuid,nodev,relatime) $ schroot -c sid (sid64)$ ls -al /mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 -> empty ! 
1
  • I'm not sure if I got your problem, but if this is what you want? mount /dev/sda1 /home/malat/debian/sid-root/mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 (with root from your normal environment) Commented Mar 3, 2020 at 15:03

2 Answers 2

2
+50
1. Your root fs is on the pt : "nvme0n1p2" 2. The device `sda1` is mounted on: "/mnt/dbc64c37-340a-49e5-8184-a69e01e5e231" 3. Your chroot is created under : "/home/malat/debian/sid-root/" 4. The schroot mnt-pnt shall be : "/mnt/dbc64c37-340a-49e5-8184-a69e01e5e231" (in chroot) 

Your first mistake on your first try:

You tried to auto-mount the partition sda1, instead of giving the mount-point of the already mounted filesystem:

/dev/disk/by-uuid/dbc64c37-340a-49e5-8184-a69e01e5e231 /mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 none rw,bind 0 

Instead it should look like this:

/mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 /mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 none rw,bind 0 0 

Partitions are never mounted via bind, already mounted directories or even files are. The correct configuration for the /etc/fstab within your chroot would look like this:

 /dev/disk/by-uuid/dbc64c37-340a-49e5-8184-a69e01e5e231 /mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 ext4 rw,nosuid,nodev,relatime,x-gvfs-show 0 0 

You do NOT do that - unless you unmounted sda1 outside of the chroot! You effectively would double mount sda1 TWICE and corrupt the fs therefore, if possible after all.

Your second try outside of the chroot should have worked:

sudo mount --rbind /mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 

But the output of mount doesn't fit:

/dev/sda1 on /mnt/dbc64c37-340a-49e5-8184-a69e01e5e231/malat/debian/sid-root/mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 type ext4 (rw,nosuid,nodev,relatime) 

The first output of lsblk told us, that there is no partition for the home tree! So why does mount state the bind mountpoint to be on /mnt/dbc64c37-340a-49e5-8184-a69e01e5e231/malat/debian/sid-root/mnt/dbc64c37-340a-49e5-8184-a69e01e5e231? The correct path should be /home/malat/debian/sid-root/mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 on nvme0n1p2!

Try:

Don't chroot, yet! Try bind mounting with full paths: sudo mount --rbind "/mnt/dbc64c37-340a-49e5-8184-a69e01e5e231" "/home/malat/debian/sid-root/mnt/dbc64c37-340a-49e5-8184-a69e01e5e231" 

If it is a success, you can automate this without schrootoutside of your chroot in the fstab with:

/mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 /home/malat/debian/sid-root/mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 none bind 0 0 

Since a chroot prevents access to the "host" file-hierarchy and you mentioned to not having altered /etc/schroot/default/fstab, the bind mount within the schroot should fail. That is because /mnt is not included in the schroot fstab. And if it was, it would already have been "bind mounted".

This question provoked me and took me 2hrs to answer. I Hope it works. Btw, i have been remembered about schroot and got me a basic understanding about the mounting, now. ;)

PS The output of lsblk within the chroot can't be correct! It states that sda1 mounted outside of the chroot under /mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 would be the root (/) within the chroot. This is false! The root of the chroot is /home/malat/debian/sid-root/on the partition nvme0n1p2!

0
-1

So the solution was simply to read properly my schroot config file. It stated:

$ cat /etc/schroot/chroot.d/sid64 [...] profile=desktop 

So I need to edit the file: /etc/schroot/desktop/fstab and not /etc/schroot/default/fstab (desktop != default).

I used :

$ tail -1 /etc/schroot/desktop/fstab /mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 /mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 none rw,bind 0 0 

And now I have:

$ schroot -c sid (sid64)$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 1.8T 0 disk └─sda1 8:1 0 1.8T 0 part /mnt/dbc64c37-340a-49e5-8184-a69e01e5e231 nvme0n1 259:0 0 477G 0 disk ├─nvme0n1p1 259:1 0 650M 0 part └─nvme0n1p2 259:2 0 372.5G 0 part /var/lib/dbus 
1
  • I'm glad you were able to correct your bind mount syntax after my post to get it working and post it as elaborate own answer in a bounty question. Hopefully you will get all the deserved attention in next questions. Commented Mar 9, 2020 at 10:33

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.