4 # initramfs /init (busybox ash)
7 # color codes and some predefined texts
14 OK
="${BOLD}${GREEN}OK${NORM}"
15 FAILED
="${BOLD}${RED}FAILED${NORM}"
19 # check an exit value and print a colored status
29 # search for and mount the crux media, populate a tmpfs from it,
30 # and prepare /newroot for switch_root at the end of the script
31 find_and_mount_media
() {
32 echo -e " ${BOLD}${BLUE}*${NORM} Searching for the CRUX media..."
34 MMC_DEVICES
="`grep -E 'mmcblk0p' /proc/partitions | awk '{ print $4 }'`"
35 BLOCK_DEVICES
="`grep -E '[sh]d' /proc/partitions | awk '{ print $4 }'`"
36 for DEV
in $MMC_DEVICES $BLOCK_DEVICES
39 mount
-r $DEV /media
2> /dev
/null
42 echo -e -n " ${BOLD}${GREEN}*${NORM} Found media on $DEV"
43 if [ -e /media
/crux-media
]
49 echo ", but it's not the CRUX media."
53 echo -e " ${BOLD}${YELLOW}*${NORM} No media found on $DEV."
57 # check if the media was mounted properly. if not, spawn a shell
58 if [ ! -e /media
/crux-media
]
61 echo -e " ${BOLD}${RED}*${NORM} The CRUX media was not properly mounted!"
62 echo " Spawning a shell for you to attempt to fix this problem. If"
63 echo " you are able to find the correct device, mount it at"
64 echo " /media and then log out of this shell to continue."
65 echo " If you are NOT able to fix the problem, installation will"
66 echo " not be possible."
71 # check again and stop if it's still not there
72 if [ ! -e /media
/crux-media
]
75 echo -e " ${BOLD}${RED}*${NORM} The CRUX media still appears not to be"
76 echo " found and installation will not continue."
80 MODULES
="`find /media/crux/kernel -type f -name 'modules-*.tar.*' 2>/dev/null`"
81 if [ ! -z "$MODULES" ]; then
82 tar -C /tmp
-xf $MODULES
83 cd /lib
&& ln -s /tmp
/lib
/* .
87 PKGUTILS
="`find /media/crux/core -type f -name 'pkgutils#*.pkg.tar.*' 2>/dev/null`"
88 if [ ! -z "$PKGUTILS" ]; then
89 tar -C /tmp
-xf $PKGUTILS
90 cd /usr
/bin
&& ln -s /tmp
/usr
/bin
/* .
91 cd /etc
&& ln -s /tmp
/etc
/* .
101 echo -e "${BOLD}CRUX-ARM 3.3 - ${BLUE}http://crux-arm.nu/${NORM}"
104 exec >/dev
/console
</dev
/console
2>&1
106 # premature mount /proc since we need some rw operations
107 echo -e -n " ${BOLD}${BLUE}*${NORM} Mounting "
108 echo -e -n "${BOLD}${GREEN}/proc${NORM}"
109 mount
-t proc proc
/proc
111 if grep -q "debug" /proc
/cmdline
116 # dont show kernel printk messages
117 PRINTK
="`cat /proc/sys/kernel/printk`"
120 echo "0" > /proc
/sys
/kernel
/printk
123 echo -e ", ${BOLD}${GREEN}/sys${NORM}."
124 mount
-t sysfs sysfs
/sys
126 echo -e -n " ${BOLD}${BLUE}*${NORM} Mounting filesystems... "
128 mount
-o remount
,rw
/
131 echo -e -n " ${BOLD}${BLUE}*${NORM} Populating /dev via mdev... "
135 echo -e -n " ${BOLD}${BLUE}*${NORM} Registering mdev as hotplug agent... "
136 echo "/bin/mdev" > /proc
/sys
/kernel
/hotplug
139 echo -e -n " ${BOLD}${BLUE}*${NORM} Creating and mounting /dev/pts... "
141 mount
-t devpts devpts
/dev
/pts
144 echo -e -n " ${BOLD}${BLUE}*${NORM} Starting kernel log daemon... "
148 echo -e -n " ${BOLD}${BLUE}*${NORM} Setting hostname... "
152 echo -e -n " ${BOLD}${BLUE}*${NORM} Loading network loopback device... "
153 ip addr add
127.0.0.1/8 dev lo broadcast
+ scope
host && \
154 ip link
set lo up
&& \
155 echo "127.0.0.1 localhost crux" > /etc
/hosts
158 echo -e -n " ${BOLD}${BLUE}*${NORM} Saving boot messages... "
159 dmesg
> /var
/log
/boot
162 # run mdev again to fix issues with mmc devices. yeah, it is weird but worked
165 echo -e " ${BOLD}${BLUE}*${NORM} Trying to find and mount the media installer..."
168 # debug could be necessary when are working with a new device and/or features
169 # and for a weird reason you can't see any output message on the console.
170 # You can create a debug.sh script at topdir of your install media and redirect
171 # the output to a file to inspect later
174 echo -e -n " ${BOLD}${BLUE}*${NORM} Loading debug script..."
180 echo "The system is coming up. Please wait."
183 # restore kernel printk status
184 echo "$PRINTK" > /proc
/sys
/kernel
/printk