Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 500170 - INIT script cannot run in busybox on PPC
Summary: INIT script cannot run in busybox on PPC
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: PPC Linux
: Normal normal (vote)
Assignee: Gentoo Linux bug wranglers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-03 11:52 UTC by Hiroshi Takenaka
Modified: 2014-02-03 12:34 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hiroshi Takenaka 2014-02-03 11:52:16 UTC
I have been trying to install gentoo on an iMac DV (an old G3 box).
Since there is not enough space on the internal disk,
I want /usr, /home, and /var to be an external IEEE1394 disk.

In order to boot gentoo with /usr separated from root,
I need an initramfs.
I have been making the initramfs using the gentoo wiki as a reference:
http://wiki.gentoo.org/wiki/Early_Userspace_Mounting

The following is my init script for Early Userspace Mounting:
-----
     1	#!/bin/busybox sh
     2	rescue_shell() {
     3	    echo "$@"
     4	    echo "Something went wrong. Dropping you to a shell."
     5	    busybox --install -s
     6	    exec /bin/sh
     7	}
     8	
     9	check_filesystem() {
    10	    # most of code coming from /etc/init.d/fsck
    11	
    12	    local fsck_opts="" check_extra="" RC_UNAME=$(uname -s)
    13	
    14	    # FIXME : get_bootparam forcefsck
    15	    if [ -e /forcefsck ]; then
    16	        fsck_opts="$fsck_opts -f"
    17	        check_extra="(check forced)"
    18	    fi
    19	
    20	    echo "Checking local filesystem $check_extra : $1"
    21	
    22	    if [ "$RC_UNAME" = Linux ]; then
    23	        fsck_opts="$fsck_opts -C0 -T"
    24	    fi
    25	
    26	    trap 'echo "fsck was interrupted"' INT QUIT
    27	
    28	    # using our own fsck, not the builtin one from busybox
    29	    /sbin/fsck -p $fsck_opts $1
    30	
    31	    case $? in
    32	        0)      return 0;;
    33	        1)      echo "Filesystem repaired"; return 0;;
    34	        2|3)    if [ "$RC_UNAME" = Linux ]; then
    35	                        echo "Filesystem repaired, but reboot needed"
    36	                        reboot -f
    37	                else
    38	                        rescue_shell "Filesystem still have errors; manual fsck required"
    39	                fi;;
    40	        4)      if [ "$RC_UNAME" = Linux ]; then
    41	                        rescue_shell "Fileystem errors left uncorrected, aborting"
    42	                else
    43	                        echo "Filesystem repaired, but reboot needed"
    44	                        reboot
    45	                fi;;
    46	        8)      echo "Operational error"; return 0;;
    47	        12)     echo "fsck interrupted";;
    48	        *)      echo "Filesystem couldn't be fixed";;
    49	    esac
    50	    rescue_shell
    51	}
    52	
    53	uuidlabel_root() {
    54	    for cmd in $(cat /proc/cmdline) ; do
    55	        case $cmd in
    56	        root=*)
    57	            type=$(echo $cmd | cut -d= -f2)
    58	            echo "Mounting rootfs"
    59		    case $type in
    60		    	LABEL)
    61			      label=$(echo $cmd | cut -d= -f3)
    62			      check_filesystem $(findfs LABEL=label)
    63			      mount -o ro $(findfs LABEL=label) /mnt/root ;;
    64			 UUID)
    65			      uuid=$(echo $cmd | cut -d= -f3)
    66			      check_filesystem $(findfs UUID=uuid)
    67			      mount -o ro $(findfs UUID=uuid) /mnt/root ;;
    68			    *)
    69			      check_filesystem $(echo $cmd | cut -d= -f2)
    70			      mount -o ro $(echo $cmd | cut -d= -f2) /mnt/root ;;
    71		    esac ;;
    72	        esac
    73	    done
    74	}
    75	
    76	# temporarily mount proc and sys
    77	mount -t proc none /proc
    78	mount -t sysfs none /sys
    79	mount -t devtmpfs none /dev
    80	
    81	# disable kernel messages from popping onto the screen
    82	echo 0 > /proc/sys/kernel/printk
    83	
    84	# clear the screen
    85	clear
    86	
    87	# mounting rootfs on /mnt/root
    88	uuidlabel_root || rescue_shell "Error with uuidlabel_root"
    89	
    90	# loading vmwfgx
    91	#/sbin/modprobe vmwfgx
    92	
    93	# space separated list of mountpoints that ...
    94	#mountpoints="/var /usr /home"
    95	#mountpoints="/boot"
    96	
    97	# ... we want to find in /etc/fstab ...
    98	#ln -s /mnt/root/etc/fstab /etc/fstab
    99	
   100	# ... to check filesystems and mount our devices.
   101	#for m in $mountpoints ; do
   102	#    check_filesystem $m
   103	#
   104	#    echo "Mounting $m"
   105	#    # mount the device and ...
   106	#    mount $m || rescue_shell "Error while mounting $m"
   107	#
   108	    # ... move the tree to its final location
   109	#    mount --move $m "/mnt/root"$m || rescue_shell "Error while moving $m"
   110	#done
   111	
   112	echo "All done. Switching to real root."
   113	
   114	# clean up. The init process will remount proc sys and dev later
   115	umount /proc
   116	umount /sys
   117	umount /dev
   118	
   119	# switch to the real root and execute init
   120	exec switch_root /mnt/root /sbin/init
-----

This script runs without any complaint
and boots gentoo on an x86 virtual machine.

However, it won't run
complaining "Bad substitute" at the line 53 on the PPC machine.

I am now suspecting a problem of busybox itself on PPC.

Regards,
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2014-02-03 12:34:56 UTC
I doubt it's architecture related.

Please use our forums and/or IRC channels for support, and use this bug tracker to report actual bugs.