flash-kernel failed in an armhf lxc container on ARM: /usr/sbin/flash-kernel: 214: /usr/sbin/flash-kernel: mkimage: not found

Bug #1160360 reported by Jean-Baptiste Lallement
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
flash-kernel (Ubuntu)
Fix Released
High
Unassigned

Bug Description

Raring armv7l
lxc: 0.9.0~rc1-0ubuntu1
flash-kernel: 3.0~rc.4ubuntu29
initramfs-tools: 0.103ubuntu0.7

When the kernel is upgraded inside an armhf LXC container running on armv7l, the upgrade fails with:
===
Setting up initramfs-tools (0.103ubuntu0.7) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools ...
update-initramfs: Generating /boot/initrd.img-3.8.0-14-generic
flash-kernel: installing version 3.8.0-14-generic
Generating kernel u-boot image... /usr/sbin/flash-kernel: 214: /usr/sbin/flash-kernel: mkimage: not found
run-parts: /etc/initramfs/post-update.d//flash-kernel exited with return code 127
dpkg: error processing initramfs-tools (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 initramfs-tools
===

TEST CASE:
1. Install an armhf container on an arm host
2. Upgrade initramfs-tools

ProblemType: Bug
DistroRelease: Ubuntu 13.04
Package: lxc 0.9.0~rc1-0ubuntu1
ProcVersionSignature: Ubuntu 3.8.0-13.23-generic 3.8.3
Uname: Linux 3.8.0-13-generic x86_64
ApportVersion: 2.9.2-0ubuntu4
Architecture: amd64
Date: Tue Mar 26 14:09:34 2013
MarkForUpload: True
ProcEnviron:
 TERM=xterm
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: lxc
UpgradeStatus: Upgraded to raring on 2012-01-31 (419 days ago)

Related branches

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :
Revision history for this message
Robie Basak (racb) wrote :

This is interesting - thanks Jean-Baptiste.

So do we need to:

 - Not have a kernel image package installed in the container in the first place?
 - Arrange for flash-kernel not to be run inside a container (kernel postinst? update-initramfs postinst?)?
 - Make flash-kernel depend on u-boot-tools instead of merely suggesting it?

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

It is even more annoying because if you specify "apt_upgrade: true" in a cloud-config script and there is a package that triggers kernel hooks, then it breaks the provisioning of the lxc guest.

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

it breaks even without that directive.

Another test case to run on a day with a package upgrade that will run kernel hooks

1. Create the user-data file with the following content:
====8<========8<========8<========8<========8<====
#cloud-config
locale: en_US.UTF-8

password: ubuntu
chpasswd: { expire: False }
ssh_pwauth: True

ssh_authorized_keys:
 - SOMEPUBKEY

apt_sources:
 - source: deb http://archive.ubuntu.com/ubuntu raring restricted multiverse
 - source: deb-src http://archive.ubuntu.com/ubuntu raring restricted multiverse

byobu_by_default: system

packages:
 - eatmydata
 - autopkgtest
 - dpkg-dev
 - pbuilder
 - bzr

runcmd:
 - [sh, -xc, "echo '127.0.1.1 autopkgtest' >> /etc/hosts" ]
====>8========>8========>8========>8========>8====

2. On an ARM host provision an LXC guest with the command (replace user-data by the path to the user-data file you created above)
  $ sudo lxc-create -n raring-armhf-20130326_094008 -t ubuntu-cloud -- -r raring -a armhf -s daily -u user-data -T https://cloud-images.ubuntu.com/raring/current/raring-server-cloudimg-armhf-root.tar.gz

3. Start the container and wait
  $ sudo lxc-start -n raring-armhf-20130326_09400

Revision history for this message
Stéphane Graber (stgraber) wrote :

@Robie: The right solution here is to do the same hack we have in grub, which is to using "running-in-container" to detect LXC and skip that part of the code.

/etc/kernel/postinst.d/zz-update-grub can be used as an example for that change if you're interested in fixing this issue yourself.

I'm also vaguely surprised that flash-kernel uses mkimage but doesn't depend on it, though that's a separate issue :)

Revision history for this message
Robie Basak (racb) wrote :

Jean-Baptiste kindly tested this attached change, but it didn't work. He said that it still broke in the initramfs-tools postinst as it did before.

But I wonder - why is flash-kernel installed at all in the cloud images? Can we fix this by not including flash-kernel at all?

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Moving to flash-kernel
LXC do not rootfs modifications from the templates. The proposed fix in attached branch do the equivalent of then environment variable FLASH_KERNEL_SKIP and skips flash-kernel run inside LXC container by checking the result of 'running-in-container'

affects: lxc (Ubuntu) → flash-kernel (Ubuntu)
Changed in flash-kernel (Ubuntu):
importance: Undecided → High
status: New → Triaged
Revision history for this message
Loïc Minier (lool) wrote :

Is there a sysvinit equivalent to running-in-container that would be suitable for inclusion in Debian?

Revision history for this message
Loïc Minier (lool) wrote :

(See bug #1160488 for why u-boot-tools shouldn't be a dep)

Generally, it's still a good idea to avoid installing flash-kernel in the container though.

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

I don't know if there is a sysvinit equivalent. For non-upstart systems, we could check the cgroup name in /proc/self/cgroup but I think systemd uses cgroup too so a name there wouldn't guarantee if we are or not in a container. Another solution would be to check if inode number of / is not 2 which would work for chroots and lxc.

Revision history for this message
Brian Murray (brian-murray) wrote :

As the branch fixing this bug already makes this appear on the sponsor's list I'm unsubscribing ubuntu-sponsors from this bug.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package flash-kernel - 3.0~rc.4ubuntu30

---------------
flash-kernel (3.0~rc.4ubuntu30) raring; urgency=low

  * Do not run flash-kernel inside an LXC container (LP: #1160360)
 -- Jean-Baptiste Lallement <email address hidden> Wed, 27 Mar 2013 16:29:20 +0100

Changed in flash-kernel (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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