/
liwixi
executable file
·42 lines (35 loc) · 1.36 KB
/
liwixi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh -e
# linux where i can see it
#
# See https://github.com/jbrzusto/liwixi for details.
#
# This script fragment sets up /dev/loop0 on the image file
# /dev/mmcblk0p1/@@LIWIXI_IMAGE_FILENAME@@, so the kernel can use the
# image as its root filesystem. This script will become part of the
# initramfs's init script, run after the kernel boots but before it
# mounts its rootfs. The image is also mounted on /dev/sdcard,
# which survives the switchover to the root filesystem.
#
# /dev/mmcblk0p1 can be an SD card with a single, vfat-formatted
# partition (the whole point of liwixi).
#
# See the accompanying script 'pliwixi' for how to build an archive
# containing an appropriate image from a running system.
## @@REMOVE@@ <-- lines with this string are to prevent me from accidentally running
## @@REMOVE@@ this script fragment instead of pliwixi. They are removed when
## @@REMOVE@@ this script fragment is copied into /etc/initramfs-tools/...
echo "This isn't the script you're looking for. Run pliwixi instead." ## @@REMOVE@@
exit ## @@REMOVE@@
PREREQS=""
prereqs() { echo "$PREREQS"; }
case "$1" in
prereqs)
prereqs
exit 0
;;
esac
# mount /dev/mmcblk0p1 on the rootfs at /dev/sdcard
mkdir /dev/sdcard
mount -o flush,dirsync /dev/mmcblk0p1 /dev/sdcard
# set up the loopback device on the image
losetup /dev/loop0 /dev/sdcard/@@LIWIXI_IMAGE_FILENAME@@