31st Jul, 2014, 05:58 PM
Hi everybody, I'm here to ask help in doing something I've never had to do before in my past Linux experience: customize the initramfs.
Problem: I want to run XBian on my RPi model B from USB hard drive, but I want to be able to power off my RPi and disconnect the USB disk while still being able to boot my RPi.
To achieve such goal I was initially thinking to just use the recovery shell and have two lines in my cmdline.txt file, one commented out so just a quick edit could do. Sadly my USB Cherry G320 keyboard is not recognized by the kernel modules and I'm back to square one.
I was thinking I can put a simple shell script in the recovery console init sequence: check if the USB disk is connected and if it is not try to switch the cmdline arguments and continue booting.
The problem is I don't know where I can put such script so to see it executed when entering the rescue console. I know I have to alter the initramfs.gz content and I can use the /etc/initramfs-tools folder, but by putting a simple
echo "Testing now!!!!"
inside a test.sh file in the scripts/premount-init and/or scripts/premount-local folder didn't produce any output change in my boot sequence (and yes, I did run the xbian-update-initramfs and I did uncomment the initramfs directive in the config.txt file).
Now I'm questioning myself regarding my comprehension of initramfs...
Should the scripts located in those folders get executed before the root filesystem gets mounted?
What is the difference between those prefixed with init and those with local?
Where those scripts should end up in the newly created initramfs?
Should them be visible from within the rescue console?
My plan for the sd-fallback.sh script is:
1. check for usb disk by LABEL/UUID (blkid)
2. check for /rootfs content (ls)
3. in case one of the above fails and cmdline.txt.usb does not exist
3.1. copy current cmdline.txt onto cmdline.txt.usb
3.2 copy cmdline.txt.sd onto cmdline.txt (force)
3.3 exit rescue mode
I believe this could be useful in many situations....
Any help is appreciated
Problem: I want to run XBian on my RPi model B from USB hard drive, but I want to be able to power off my RPi and disconnect the USB disk while still being able to boot my RPi.
To achieve such goal I was initially thinking to just use the recovery shell and have two lines in my cmdline.txt file, one commented out so just a quick edit could do. Sadly my USB Cherry G320 keyboard is not recognized by the kernel modules and I'm back to square one.
I was thinking I can put a simple shell script in the recovery console init sequence: check if the USB disk is connected and if it is not try to switch the cmdline arguments and continue booting.
The problem is I don't know where I can put such script so to see it executed when entering the rescue console. I know I have to alter the initramfs.gz content and I can use the /etc/initramfs-tools folder, but by putting a simple
echo "Testing now!!!!"
inside a test.sh file in the scripts/premount-init and/or scripts/premount-local folder didn't produce any output change in my boot sequence (and yes, I did run the xbian-update-initramfs and I did uncomment the initramfs directive in the config.txt file).
Now I'm questioning myself regarding my comprehension of initramfs...
Should the scripts located in those folders get executed before the root filesystem gets mounted?
What is the difference between those prefixed with init and those with local?
Where those scripts should end up in the newly created initramfs?
Should them be visible from within the rescue console?
My plan for the sd-fallback.sh script is:
1. check for usb disk by LABEL/UUID (blkid)
2. check for /rootfs content (ls)
3. in case one of the above fails and cmdline.txt.usb does not exist
3.1. copy current cmdline.txt onto cmdline.txt.usb
3.2 copy cmdline.txt.sd onto cmdline.txt (force)
3.3 exit rescue mode
I believe this could be useful in many situations....
Any help is appreciated