Boot fails if /sbin/init (or init= arg) is an absolute symlink

Bug #1351295 reported by Martin Pitt
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
initramfs-tools (Ubuntu)
Fix Released
Undecided
Dimitri John Ledkov

Bug Description

Booting current Utopic with init=/bin/systemd fails., or installing systemd-sysv fails. In both cases we are dealing with an absolute symlink "/bin/systemd -> /lib/systemd/systemd" or "/sbin/init -> /lib/systemd/systemd". I see:

/init: line 307: readlink: not found
Target filesystem doesn't have requested /bin/systemd
and then a kernel panic.

Tags: systemd-boot
Martin Pitt (pitti)
Changed in initramfs-tools (Ubuntu):
assignee: nobody → Martin Pitt (pitti)
status: New → In Progress
Martin Pitt (pitti)
tags: added: systemd-boot
Revision history for this message
Martin Pitt (pitti) wrote :

This is coming from "init" line284:

                 case $(readlink "${rootmnt}${checktarget}") in /*)

That's the readlink that isn't found (not the chrooted one in the next line). I added a few debugging steps, and "type readlink" says "readlink is readlink". I cannot reproduce this in break=bottom, in the interactive shell readlink /root/bin/systemd works just fine. But as soon as I Ctrl+D, readlink doesn't work any more. Some subtle busybox difference between interactive and shell script mode?

It works if I replace this with

                 case $(/bin/busybox readlink "${rootmnt}${checktarget}") in /*)

but that's not a proper solution but a workaround.

summary: - Boot fails if /sbin/init is an absolute symlink
+ Boot fails if /sbin/init (or init= arg) is an absolute symlink
Revision history for this message
Martin Pitt (pitti) wrote :

Moreover, this obviously works in Debian, but between Ubuntu's and Debian's initramfs initd there is no obvious difference for readlink.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

I would prefer that /sbin/init is shipped as a real file by systemd-sysv, instead of a symlink of any kind. (E.g. a copy of /lib/systemd/systemd).

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Actually, i take that back. To support running upstart user sessions under systemd-sysv, we'd need to split upstart package. In that case upstart will ship /sbin/init which would be a symlink as well. Similar to how systemd-sysv is packaged.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

 for execvp("readlink"...) to work, there must be /bin/readlink present. I still don't understand why we simply not generate symlinks for all busybox applets present in the initramfs. Anyway, readlink added.

Changed in initramfs-tools (Ubuntu):
status: In Progress → Fix Committed
assignee: Martin Pitt (pitti) → Dimitri John Ledkov (xnox)
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package initramfs-tools - 0.103ubuntu8

---------------
initramfs-tools (0.103ubuntu8) utopic; urgency=medium

  * Add readlink symlink for busybox in the busybox hook, needed to
    support /sbin/init as a readlink (LP: #1351295).
 -- Dimitri John Ledkov <email address hidden> Fri, 01 Aug 2014 16:46:35 +0100

Changed in initramfs-tools (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
A. Eibach (andi3) wrote :

Strange.

I still got the "line 307: readlink: not found" error on bootup although I do have initramfs-tools 0.103ubuntu8.

Revision history for this message
Dimitri John Ledkov (xnox) wrote : Re: [Bug 1351295] Re: Boot fails if /sbin/init (or init= arg) is an absolute symlink

On 7 August 2014 03:03, A. Eibach <email address hidden> wrote:
> Strange.
>
> I still got the "line 307: readlink: not found" error on bootup although
> I do have initramfs-tools 0.103ubuntu8.
>

It's not just initramfs-tools package, one also needs to regenerate
initramfs with that tools package for all kernels you wish to boot.

Reboot to latest kernel; $ sudo update-initramfs -u; reboot again
should do the trick.

--
Regards,

Dimitri.

Revision history for this message
A. Eibach (andi3) wrote :

Thank you!
Hmm..."Latest kernel"...that's another interesting thing...always got nothing but black screens in 3.16, hence I had to go back to the 3.13 series (patch levels 30 +) and --- no more problems.

Revision history for this message
A. Eibach (andi3) wrote :

$ sudo update-initramfs -k 3.13.0-32-generic -u

voila !! thanks again for leading me in the right direction.
I've decided to post this too here; maybe it will help some more users new to Ubuntu.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.