Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- rescue_shell() {
- echo "$@"
- echo "Dropping to a shell."
- exec /bin/sh
- }
- mount_boot() {
- mount -o rw /dev/mmcblk0p1 /mnt/boot
- }
- mount_root() {
- for cmd in $(cat /proc/cmdline) ; do
- case $cmd in
- root=*)
- type=$(echo $cmd | cut -d= -f2)
- echo "Mounting rootfs"
- if [ $type == "LABEL" ] || [ $type == "UUID" ]; then # PARTUUID ?
- uuid=$(echo $cmd | cut -d= -f3)
- mount -o rw $(findfs "$type"="$uuid") /mnt/root
- else # mount like /dev/sda1
- mount -o rw $(echo $cmd | cut -d= -f2) /mnt/root
- fi
- ;;
- esac
- done
- }
- load_network() {
- ifup -a
- ip=`ifconfig eth0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*'`
- echo "IP: $ip"
- }
- # temporarily mount proc and sys
- mount -t proc none /proc
- mount -t sysfs none /sys
- mount -t devtmpfs none /dev
- # disable kernel messages from popping onto the screen
- echo 0 > /proc/sys/kernel/printk
- # clear the screen
- clear
- echo "Recovery Mode"
- echo "Waiting for disks..."
- sleep 5
- echo "Disks ready!"
- load_network
- /bin/hello_try
- # mounting boot on /mnt/boot
- mount_boot || rescue_shell "Error while boot mounting!"
- # mounting rootfs on /mnt/root
- mount_root || rescue_shell "Error while root mounting!"
- #ln -s /mnt/root/etc/fstab /etc/fstab
- echo "All done. Trying to boot..."
- rescue_shell # debug only
- # clean up. The init process will remount proc sys and dev later
- umount /proc
- umount /sys
- umount /dev
- # switch to the real root and execute init
- exec switch_root /mnt/root /sbin/init
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement