1

So, I have a weird laptop that won't correctly boot from my USB3.0 stick. Grub and initramfs load up, but then miraculously the stick is not mounted. If I just wait, the machine drops to the busybox shell. blkid doesn't list my stick. But if I before that happens, at the correct time, replug that stick, Ubuntu boots up correctly.

So I thought, let's automate that. I got myself a restart_usb shell script, put it in /etc/initramfs-tools/scripts/init-premount, and ran update-initramfs -u.

Now comes the funny part: the script is executed while generating the new initramfs, thus resetting usb and by that, leaving a running linux with no access to any of its partitions. Only hard reset helps there.

So my question is: how do I put a script that runs before we try to mount / into the initramfs without it being executed by update-initramfs?

Cheers.

Edit: I'm running a fresh install (not updated) of Ubuntu 14.04.

3

I had a similar problem, so I poked around in other scripts included in initramfs. Apparently, the "trick" is in a script header which should look like this:

 #!/bin/sh

 set -e

 case $1 in
 prereqs)
     prereqs
     exit 0
     ;;
 esac

The case statement is the important part.

It is mentioned in this documentation, but it doesn't state that you have to include this header even if you do not require precise ordering.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.