Bug#840372: debootstrap: second-stage fails within systemd-nspawn: proc already mounted

2018-04-24 Thread Raphael Hertzog
On Tue, 24 Apr 2018, Hideki Yamane wrote:
> On Mon, 23 Apr 2018 15:59:31 +0200
> Raphael Hertzog  wrote:
> > I'm saying this because the following lines are left untouched and are
> > called in all cases:
> > umount_on_exit /proc
> > umount_on_exit /proc/bus/usb
> > 
> > (They are in the context of your unified diff)
> > 
> > They should only be called if debootstrap is mounting /proc by itself.
> 
>  Okay, I want to treat it as separate issue (this code is not touched
>  until now), deal with it after next upload.

I don't think that it makes sense to fix one problem to introduce another
one at the same place. debootstrap was broken because the wrapper did
already mount /proc. Now the wrapper will be broken because debootstrap
has already umounted /proc and the wrapper will fail to be able to umount
it.

Cheers,
-- 
Raphaël Hertzog ◈ Debian Developer

Support Debian LTS: https://www.freexian.com/services/debian-lts.html
Learn to master Debian: https://debian-handbook.info/get/



Bug#840372: debootstrap: second-stage fails within systemd-nspawn: proc already mounted

2018-04-24 Thread Hideki Yamane
On Mon, 23 Apr 2018 15:59:31 +0200
Raphael Hertzog  wrote:
> I'm saying this because the following lines are left untouched and are
> called in all cases:
> umount_on_exit /proc
> umount_on_exit /proc/bus/usb
> 
> (They are in the context of your unified diff)
> 
> They should only be called if debootstrap is mounting /proc by itself.

 Okay, I want to treat it as separate issue (this code is not touched
 until now), deal with it after next upload.


-- 
Regards,

 Hideki Yamane henrich @ debian.org/iijmio-mail.jp



Bug#840372: debootstrap: second-stage fails within systemd-nspawn: proc already mounted

2018-04-23 Thread Raphael Hertzog
On Mon, 23 Apr 2018, Hideki Yamane wrote:
> On Thu, 19 Apr 2018 10:06:49 +0200
> Raphael Hertzog  wrote:
> > Your patch will try to umount /proc even if it has not been mounted by
> > debootstrap. That's wrong. If you detect that /proc was handled outside of
> > debootstrap, then you should also not umount it.
> 
> +   if [ ! -n "$(ls -A /proc)" ]; then
> +   in_target mount -t proc proc /proc
> 
>  is when there's no file under /proc, then try to mount /proc - not try
>  to umount it.

I'm saying this because the following lines are left untouched and are
called in all cases:
umount_on_exit /proc
umount_on_exit /proc/bus/usb

(They are in the context of your unified diff)

They should only be called if debootstrap is mounting /proc by itself.

> > And the handling of /sys should be entirely separate from /proc. Even if
> > /proc was already mounted, you want debootstrap to ensure that /sys is
> > mounted too.
> 
>  Okay, it should be that.

Yes, if and only if multiple mounts on /sys do not cause the same problem than 
multiple
mounts on /proc. Otherwise you want to protect the mount call with a check 
ensuring that
/sys is not yet mounted.

Cheers,
-- 
Raphaël Hertzog ◈ Debian Developer

Support Debian LTS: https://www.freexian.com/services/debian-lts.html
Learn to master Debian: https://debian-handbook.info/get/



Bug#840372: debootstrap: second-stage fails within systemd-nspawn: proc already mounted

2018-04-23 Thread Hideki Yamane
On Thu, 19 Apr 2018 10:06:49 +0200
Raphael Hertzog  wrote:
> Your patch will try to umount /proc even if it has not been mounted by
> debootstrap. That's wrong. If you detect that /proc was handled outside of
> debootstrap, then you should also not umount it.

+   if [ ! -n "$(ls -A /proc)" ]; then
+   in_target mount -t proc proc /proc

 is when there's no file under /proc, then try to mount /proc - not try
 to umount it.


> And the handling of /sys should be entirely separate from /proc. Even if
> /proc was already mounted, you want debootstrap to ensure that /sys is
> mounted too.

 Okay, it should be that.


diff --git a/functions b/functions
index 1e41862..cb2c1d9 100644
--- a/functions
+++ b/functions
@@ -1137,10 +1137,12 @@ setup_proc () {
# and also fix failure on lxc environment
if [ ! -n "$(ls -A /proc)" ]; then
in_target mount -t proc proc /proc
-   if [ -d "$TARGET/sys" ] && \
-  grep -q '[[:space:]]sysfs' /proc/filesystems 
2>/dev/null; then
-   umount_on_exit /sys
-   umount "$TARGET/sys" 2>/dev/null || true
+   fi
+   if [ -d "$TARGET/sys" ] && \
+  grep -q '[[:space:]]sysfs' /proc/filesystems 2>/dev/null; 
then
+   umount_on_exit /sys
+   umount "$TARGET/sys" 2>/dev/null || true
+   if [ ! -n "$(ls -A /sys)" ]; then
in_target mount -t sysfs sysfs /sys
fi
fi



Bug#840372: debootstrap: second-stage fails within systemd-nspawn: proc already mounted

2018-04-19 Thread Raphael Hertzog
On Tue, 17 Apr 2018, Hideki Yamane wrote:
> > So it looks like systemd-nspawn already took care of mounting /proc and
> > debootstrap fails when trying to do the same? Maybe debootstrap could
> > just skip mounting /proc if this mount is already present?
> 
>  Here's a proposed patch.

Your patch will try to umount /proc even if it has not been mounted by
debootstrap. That's wrong. If you detect that /proc was handled outside of
debootstrap, then you should also not umount it.

And the handling of /sys should be entirely separate from /proc. Even if
/proc was already mounted, you want debootstrap to ensure that /sys is
mounted too.

Cheers,
-- 
Raphaël Hertzog ◈ Debian Developer

Support Debian LTS: https://www.freexian.com/services/debian-lts.html
Learn to master Debian: https://debian-handbook.info/get/



Bug#840372: debootstrap: second-stage fails within systemd-nspawn: proc already mounted

2018-04-17 Thread Hideki Yamane
control: tags -1 +confirm
control: tags -1 +patch

On Tue, 11 Oct 2016 03:50:51 +0200 linus.luess...@c0d3.blue wrote:
> $ sudo systemd-nspawn --bind /usr/bin/qemu-x86_64-static -D "./.amd64/" 
> /bin/bash -c "mkdir /tmp/proc; mount --move /proc /tmp/proc; 
> /debootstrap/debootstrap --second-stage"
> 
> 
> So it looks like systemd-nspawn already took care of mounting /proc and
> debootstrap fails when trying to do the same? Maybe debootstrap could
> just skip mounting /proc if this mount is already present?

 Here's a proposed patch.


diff --git a/functions b/functions
index 005b007..10938fe 100644
--- a/functions
+++ b/functions
@@ -1133,12 +1133,15 @@ setup_proc () {
umount_on_exit /proc
umount_on_exit /proc/bus/usb
umount "$TARGET/proc" 2>/dev/null || true
-   in_target mount -t proc proc /proc
-   if [ -d "$TARGET/sys" ] && \
-  grep -q '[[:space:]]sysfs' /proc/filesystems 2>/dev/null; 
then
-   umount_on_exit /sys
-   umount "$TARGET/sys" 2>/dev/null || true
-   in_target mount -t sysfs sysfs /sys
+   # if systemd-nspawn is used at second-stage, it already treats 
/proc and so on
+   if [ ! -n "$(ls -A /proc)" ]; then
+   in_target mount -t proc proc /proc
+   if [ -d "$TARGET/sys" ] && \
+  grep -q '[[:space:]]sysfs' /proc/filesystems 
2>/dev/null; then
+   umount_on_exit /sys
+   umount "$TARGET/sys" 2>/dev/null || true
+   in_target mount -t sysfs sysfs /sys
+   fi
fi
on_exit clear_mtab
;;



Bug#840372: debootstrap: second-stage fails within systemd-nspawn: proc already mounted

2016-10-10 Thread linus . luessing
Package: debootstrap
Version: 1.0.81~bpo8+1
Severity: normal

Dear Maintainer,

I'm currently trying to first debootstrap with --foreign
("$ sudo debootstrap --foreign sid ./"). And then I'm trying to perform the 
second stage
with qemu-user-static + systemd-nspawn, which fails, unfortunately:


$ sudo systemd-nspawn --bind /usr/bin/qemu-x86_64-static -D ./ 
/debootstrap/debootstrap --second-stage
Spawning container amd64 on /srv/nfs/debian-sid-test/.amd64.
Press ^] three times within 1s to kill container.
/etc/localtime is not a symlink, not updating container timezone.
I: Keyring file not available at 
/usr/share/keyrings/debian-archive-keyring.gpg; switching to https mirror 
https://mirrors.kernel.org/debian
W: Failure trying to run:  mount -t proc proc /proc
W: See //debootstrap/debootstrap.log for details
~

The following workaround helps though:


$ sudo systemd-nspawn --bind /usr/bin/qemu-x86_64-static -D "./.amd64/" 
/bin/bash -c "mkdir /tmp/proc; mount --move /proc /tmp/proc; 
/debootstrap/debootstrap --second-stage"


So it looks like systemd-nspawn already took care of mounting /proc and
debootstrap fails when trying to do the same? Maybe debootstrap could
just skip mounting /proc if this mount is already present?

Regards, Linus


-- System Information:
Debian Release: 8.6
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.7.0-0.bpo.1-amd64 (SMP w/1 CPU core)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages debootstrap depends on:
ii  wget  1.16-1+deb8u1

Versions of packages debootstrap recommends:
ii  debian-archive-keyring  2014.3
ii  gnupg   1.4.18-7+deb8u3

debootstrap suggests no packages.

-- no debconf information