Debian-based machines and the (initramfs) prompt

There are a million pages devoted to initramfs so I won’t go in to what it is, but if you have a Dell 1655 or other machine with serial-attached-SCSI and use Debian or a Debian-derived Linux distribution such as Ubuntu or Kbuntu, you may have run in to an issue booting after installing a kernel update.

Common errors are:

Target filesystem doesn’t have sbin/init
BusyBox v.1.1.3
/bin/sh: can’t access tty; job control turned off
(initramfs)

or

mount: Mounting /root/dev on /dev/.static/dev failed: No such file or directory
Done.
Target filesystem doesn’t have /sbin/init

or

Mounting root file system…
Running /scripts/local-top…Done.
Running /scripts/local-premount…Done.
kjournald starting. Commit interval 5 seconds.
Running /scripts/log-bottom…Done.
Running /scripts/init-bottom…
Mounting /root/dev on /dev/.static/dev failed: No such file or directory…Done.
Mounting /sys on /root/sys filed: No such file or directory
Mounting /proc on /root/proc filed: No such file or directory
Target filesystem doesn’t have /sbin/init

A common reason for this is simple. Your GRUB menu is messed up and you swear you didn’t touch it!

There is a bug somewhere in Debian that changes your filesystem from /dev/sd<something> to /dev/sd<something else>. Of course changing that will make the system mount root from the wrong partition and BOOM! No boot for you.

In my case it constantly changes my boot partition from /dev/sda1 to /dev/sdb1 which is really annoying. If I don’t update /boot/grub/menu.lst before I reboot, my system will not come back.

Lucky for you Debian has BusyBox and initramfs with the 2.6 kernel.

You will have to be on the console for this, but here is how to get up and running:

  • Boot up your broken system.
  • (initramfs) is actually a prompt, so:
    • (initramfs) cd /
  • (initramfs) mkdir /mnt Make a directory in the RAM filesystem.
  • (initramfs) mount /dev/sda1 /mnt Mount your REAL root partition there.
  • (initramfs) vi /mnt/boot/grub/menu.lst Edit your menu.lst file to load the correct partition (toward the bottom)
  • (initramfs) reboot

In my most recent case, the line:

kernel /boot/vmlinuz-2.6.18-4-686 root=/dev/sda1 ro

Was changed to

kernel /boot/vmlinuz-2.6.18-4-686 root=/dev/sdb1 ro

If I change it back before I reboot, I don’t have an issue.

This entry was posted in Debian, grub, How Tos, linux. Bookmark the permalink.

7 Responses to Debian-based machines and the (initramfs) prompt

  1. tony says:

    I tried to edit my menu.lst file but tve vi editor is not available in the initramfs prompt.

  2. admin says:

    Vi should be available if your Debian + Initramfs environment is new enough. If it isn’t, you should be able to mount a disk and use a binary located there for editing. If all else fails, you can echo the line on to the menu.lst file, but be sure to use the double carrot >> and don’t screw it up. It will be hard to get your changes back out. The current version of busybox should have at least these commands available:
    ash, awk, basename, blkid, cat, clear, cp, cttyhack, cut, depmod, echo, egrep, fgrep, grep, halt, init, insmod, ln, ls, lsmod, mdev, mkdir, mknod, modprobe, mount, mv, poweroff, reboot, rm, rmdir, rmmod, seq, sh, sleep, switch_root, touch, um

  3. tony says:

    Thanks admin for you urgent help. I will try that.

  4. cabanur says:

    Hi!

    I had this same “initramfs” prompt, and for a while i have been trying to find the problem: i finally got it.

    My hard disk configuration:

    sda : 120 GB
    sda1: /boot
    sda2: /
    sda3: /home
    sda4: swap

    sdb: 2 TB
    sdc: 2 TB

    I installed mdadm to use sdb and sdc as RAID1. the problem was, it only added sdb to the array, so I had a single-device RAID1 configuration, and that was why i got this initramfs prompt.

    surprisingly, all I had to do to get back to normal boot was typing “exit” on the initramfs prompt. It would continue booting without any trouble at all.

    To solve the array problem, all I did is (while on kubuntu) “sudo mdadm –manage –add /dev/md0 /dev/sdc”

    Right now it’s copying sdb to sdc (building the raid1 array), i think this will solve it all.

    By the way, while on initramfs, there’s a lot of things I could do, mostly creating a random dir in /, lets say /blah, then mounting sda2 in /blah/, sda1 in /blah/boot, and sda3 in /blah/home. then i chroot’ed to /blah.

    Next, i executed /bin/bash, to get a normal prompt. From there, i could use most of my binaries, some things like shutdown didn’t work, anyway. I used this to check /boot/grub/grub.cfg was OK, and /etc/fstab was also fine.

    I hope this helps anyone =)

  5. Goden says:

    I got mount failed invalid argument, when trying to mount sda1 to /mnt.

    I did “ls /dev/sd*” the partition is there and I’m sure this was the boot partition.
    any ideas?

  6. admin says:

    @Goden are you using LVM for /boot? You may have to mount /dev/mapper/

    I’m not sure how you landed at the prompt, but if you are using grub you can boot from a rescue CD, mount the disk from there and tell grub to re-install the boot block to /dev/sda1 if you know that’s where it belongs.

  7. Goden says:

    problem is I don’t have CD Rom with the machine – all installed with HDs (6 in total) – I may need to switch a CD Rom in.

    no idea for LVM though.

Leave a Reply

Your email address will not be published.