2014-04-25 04:39:54 +00:00
|
|
|
#!/usr/bin/ash
|
|
|
|
|
2014-05-12 20:42:06 +00:00
|
|
|
# You can set these variables manually inside their respective functions if
|
|
|
|
# you do not wish to boot using MultiROM:
|
|
|
|
#
|
|
|
|
# To boot using a loop-mounted image stored in /data as the root FS:
|
|
|
|
# loop=/path/to/arch.img
|
|
|
|
# loopfstype=ext4
|
|
|
|
#
|
|
|
|
# To boot using a bind-mounted subdirectory of /data as the root FS:
|
|
|
|
# rootsubdir=/local/arch
|
|
|
|
#
|
|
|
|
# loop= and rootsubdir= are relative to /data on Android, not /.
|
|
|
|
|
|
|
|
|
2014-04-25 04:39:54 +00:00
|
|
|
run_hook () {
|
2014-05-12 20:42:06 +00:00
|
|
|
if [ -z "$rootsubdir" ]; then
|
|
|
|
if [ -z "$loop" ]; then
|
|
|
|
error "no loop= or rootsubdir= provided on cmdline"
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
msg "root is an image at: $loop"
|
|
|
|
mount_handler="img_mount_handler"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
msg "root is a subdirectory at: $rootsubdir"
|
|
|
|
mount_handler="dir_mount_handler"
|
|
|
|
fi
|
2014-04-25 04:39:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
img_mount_handler() {
|
2014-05-12 20:42:06 +00:00
|
|
|
mkdir /host
|
|
|
|
mount -t $rootfstype $root /host
|
2014-04-25 04:39:54 +00:00
|
|
|
mknod /dev/loop256 b 7 256
|
2014-05-12 20:42:06 +00:00
|
|
|
losetup /dev/loop256 /host/$loop
|
|
|
|
mount -t $loopfstype -o rw,noatime /dev/loop256 /new_root
|
|
|
|
}
|
|
|
|
|
|
|
|
dir_mount_handler() {
|
|
|
|
mkdir /host
|
|
|
|
mount -t $rootfstype $root /host
|
|
|
|
mount --bind /host/$rootsubdir /new_root
|
2014-04-25 04:39:54 +00:00
|
|
|
}
|