<div dir="ltr"><div dir="auto">this seems to work in simple trials. i'm unsure tho if udev and kernel modules will be working from the right hierarchy, no doubt some of you will know..<br><br></div><div><span style="color:rgb(39,78,19)"><span style="font-family:monospace,monospace"><font size="1">>#!/bin/bash -f<br>>#set a subdirectory as root directory (with no change to initrd)(multiple installs don't need partitions)<br>>#simply specify on the kernel commandline:<br>># init=pat pathname from partition root to this script (chmod 744)<br>># subroot=foo pathname to become root directory<br>># partroot=par mountpoint within subroot where partition root will be left mounted<br>>#menuentry "subroot foo" { #copy /etc/grub.d/40_custom to /etc/grub.d/07_custom and add menuentries like this example<br>># echo "subroot foo"<br>># set sub=foo<br>># search --no-floppy --fs-uuid --set=root 22e7c84a-a416-43e9-ae9d-ee0119fc3894 #use your partition's uuid<br>># linux /$sub/vmlinuz ro root=UUID=22e7c84a-a416-43e9-ae9d-ee0119fc3894 init=pat subroot=foo partroot=par<br>># echo "initrd /$sub/initrd.img"<br>># initrd /$sub/initrd.img #works in recent releases where this link is relative<br>>#}<br>>subroot(){ for a in $(<proc/cmdline)<br>> do [[ $a = subroot=* ]]&& subroot=${a#*=}<br>> [[ $a = partroot=* ]]&&partroot=${a#*=}<br>> done<br>> [[ $subroot ]]||{ echo no subroot on kernel cmdline;return 1;}<br>> [[ $partroot ]]||{ echo no partroot on kernel cmdline;return 1;}<br>> (set -x;mount --bind $subroot mnt)||return<br>> for m in $(while read -r r;do r=($r)<br>> [[ ${r[1]} = /?(mnt) ]]||echo ${r[1]} #excluding / and /mnt<br>> done<proc/mounts)<br>> do (set -x;mount --bind $m mnt$m)||return #--bind whatever's already mounted<br>> done<br>> set -x<br>> cd mnt||return<br>> pivot_root . $partroot<br>>}<br>>subroot&&exec chroot . init "$@"||exec bash</font></span></span><br></div>
</div>