Bug#772416: initrd: support booting from chroot
On Sat, Dec 06, 2014 at 05:44:02PM +0100, Geert Stappers wrote:
> On Sat, Dec 06, 2014 at 04:49:10PM +0100, lemonsqueeze wrote:
> >
> > Patch and details can be found here:
> > https://github.com/lemonsqueeze/boot_chroot
> > https://github.com/lemonsqueeze/boot_chroot/blob/master/initrd.patch
> >
>
> $ wget https://github.com/lemonsqueeze/boot_chroot/blob/master/initrd.patch
> Length: unspecified [text/html]
Real patch is https://raw.githubusercontent.com/lemonsqueeze/boot_chroot/master/initrd.patch
Here inline (and also attached)
diff -Nru orig/init new/init
--- orig/init 2014-12-04 11:42:27.000000000 +0100
+++ new/init 2014-12-04 17:24:18.000000000 +0100
@@ -149,6 +149,9 @@
ip=*)
IP="${x#ip=}"
;;
+ chroot=*)
+ CHROOT="${x#chroot=}"
+ ;;
boot=*)
BOOT=${x#boot=}
;;
diff -Nru orig/scripts/local new/scripts/local
--- orig/scripts/local 2014-12-04 11:42:27.000000000 +0100
+++ new/scripts/local 2014-12-04 11:45:23.000000000 +0100
@@ -150,6 +150,37 @@
fi
fi
+ if [ "$CHROOT" ]; then
+ if [ "$mountroot_status" != 0 ]; then
+ if [ ${FSTYPE} = ntfs ] || [ ${FSTYPE} = vfat ]; then
+ panic "
+Could not mount the partition ${ROOT}.
+This could also happen if the file system is not clean because of an operating
+system crash, an interrupted boot process, an improper shutdown, or unplugging
+of a removable device without first unmounting or ejecting it. To fix this,
+simply reboot into Windows, let it fully start, log in, run 'chkdsk /r', then
+gracefully shut down and reboot back into Windows. After this you should be
+able to reboot again and resume the installation.
+(filesystem = ${FSTYPE}, error code = $mountroot_status)
+"
+ fi
+ fi
+
+ mkdir -p /host
+ mount -o move ${rootmnt} /host
+
+ if [ ! -d "/host/${CHROOT}" ]; then
+ panic "ALERT! /host/${CHROOT} does not exist. Dropping to a shell!"
+ fi
+
+ # FIXME This has no error checking
+ mount --bind "/host/${CHROOT}" ${rootmnt}
+
+ if [ -d ${rootmnt}/host ]; then
+ mount -o move /host ${rootmnt}/host
+ fi
+ fi
+
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-bottom"
run_scripts /scripts/local-bottom
[ "$quiet" != "y" ] && log_end_msg
Thanks for the patch
Groeten
Geert Stappers
--
Leven en laten leven
diff -Nru orig/init new/init
--- orig/init 2014-12-04 11:42:27.000000000 +0100
+++ new/init 2014-12-04 17:24:18.000000000 +0100
@@ -149,6 +149,9 @@
ip=*)
IP="${x#ip=}"
;;
+ chroot=*)
+ CHROOT="${x#chroot=}"
+ ;;
boot=*)
BOOT=${x#boot=}
;;
diff -Nru orig/scripts/local new/scripts/local
--- orig/scripts/local 2014-12-04 11:42:27.000000000 +0100
+++ new/scripts/local 2014-12-04 11:45:23.000000000 +0100
@@ -150,6 +150,37 @@
fi
fi
+ if [ "$CHROOT" ]; then
+ if [ "$mountroot_status" != 0 ]; then
+ if [ ${FSTYPE} = ntfs ] || [ ${FSTYPE} = vfat ]; then
+ panic "
+Could not mount the partition ${ROOT}.
+This could also happen if the file system is not clean because of an operating
+system crash, an interrupted boot process, an improper shutdown, or unplugging
+of a removable device without first unmounting or ejecting it. To fix this,
+simply reboot into Windows, let it fully start, log in, run 'chkdsk /r', then
+gracefully shut down and reboot back into Windows. After this you should be
+able to reboot again and resume the installation.
+(filesystem = ${FSTYPE}, error code = $mountroot_status)
+"
+ fi
+ fi
+
+ mkdir -p /host
+ mount -o move ${rootmnt} /host
+
+ if [ ! -d "/host/${CHROOT}" ]; then
+ panic "ALERT! /host/${CHROOT} does not exist. Dropping to a shell!"
+ fi
+
+ # FIXME This has no error checking
+ mount --bind "/host/${CHROOT}" ${rootmnt}
+
+ if [ -d ${rootmnt}/host ]; then
+ mount -o move /host ${rootmnt}/host
+ fi
+ fi
+
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-bottom"
run_scripts /scripts/local-bottom
[ "$quiet" != "y" ] && log_end_msg
Reply to: