[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#756457: initramfs-tools: fails when root filesystem has LABEL=/ (/dev/disk/by-label/\x2f)



Package: initramfs-tools
Version: 0.109.1
Severity: important
Tags: patch

Dear Maintainer,

My root filesystem has label "/". Since creating the filesystem, I have
realized that this is not the best choice of label, for it results in
device names like '/dev/disk/by-label/\x2f'. However, I used to use
labels only for convenience in my partition editor. (I believe this
naming scheme used to be the default in RedHat.[1])

Yesterday, I switched to using labels in my fstab (LABEL=/ for the root
filesystem). However, after rebooting, update-initramfs no longer works:

    $ sudo update-initramfs -u
    update-initramfs: Generating /boot/initrd.img-3.2.0-4-ixp4xx
    /dev/disk/by-label/x2f: No such file or directory
    mkinitramfs: for root /dev/disk/by-label/x2f missing disk/by-label/x
/sys/block/ entry
    mkinitramfs: workaround is MODULES=most
    mkinitramfs: Error please report the bug
    update-initramfs: failed for /boot/initrd.img-3.2.0-4-ixp4xx with 1.
    $

The problem is that the `dep_add_modules` function in
/usr/share/initramfs-tools/hook-functions uses the following routine to
identify the root block device and its filesystem type:

        eval "$( mount | while read dev foo mp foo fs opts rest ; do \
                [ "$mp" = "/" ] && [ "$fs" != "rootfs" ] \
                && printf "root=$dev\nFSTYPE=$fs" \
                && break; done)"

and when presented with the following line from mount,

    /dev/disk/by-label/\x2f on / type ext3
(rw,relatime,errors=remount-ro,barrier=1,data=ordered)

the routine fails for two reasons: 1) the call to read does not use the
-r option, so the backslash is stripped, and 2) the device name is
interpolated into the format string of printf (which turns \x2f into a
literal /).

I propose the following patch, which allows / to be used in disk labels
(enabling me to rebuild my own initrd). However, some other special
characters that could appear in disk labels, like apostrophe and space,
will remain problematic -- a more complete patch might be desirable. I
believe that version 0.115 is also susceptible to this problem, as it
uses the same code to identify the root block device, but I have not
tested it with non-alphanumeric disk labels.

Thanks,
-nandhp

--- hook-functions	2013-04-16 20:19:46.000000000 -0500
+++ hook-functions.patched	2014-07-29 19:24:04.000000000 -0500
@@ -231,9 +231,9 @@
 	fi

 	# findout root block device + fstype
-	eval "$( mount | while read dev foo mp foo fs opts rest ; do \
+	eval "$( mount | while read -r dev foo mp foo fs opts rest ; do \
         	[ "$mp" = "/" ] && [ "$fs" != "rootfs" ] \
-		&& printf "root=$dev\nFSTYPE=$fs" \
+		&& printf "root='%s'\nFSTYPE='%s'" "$dev" "$fs" \
 		&& break; done)"

 	# On failure fallback to /proc/mounts if readable

[1]
http://www.linuxforums.org/forum/red-hat-fedora-linux/root-label-grub-conf-print-23010.html

-- Package-specific info:
-- initramfs sizes
-- /proc/cmdline
console=ttyS0,115200 noirqdebug

-- resume
RESUME=/dev/sda5
-- /proc/filesystems
	ext3
	ext2

-- lsmod
Module                  Size  Used by
sha256_generic          8535  0
aes_generic            27588  0
cbc                     2252  0
ppp_async               6465  1
crc_ccitt               1125  1 ppp_async
ppp_generic            21863  5 ppp_async
slhc                    4415  1 ppp_generic
tun                    12349  4
nfsd                  226810  7
nfs                   339373  0
nfs_acl                 2205  2 nfs,nfsd
auth_rpcgss            33749  2 nfs,nfsd
fscache                39451  1 nfs
lockd                  66992  2 nfs,nfsd
sunrpc                182543  20 lockd,auth_rpcgss,nfs_acl,nfs,nfsd
ipv6                  262080  68
ipt_MASQUERADE          1396  3
iptable_nat             3350  1
nf_nat                 13067  2 iptable_nat,ipt_MASQUERADE
nf_conntrack_ipv4       9990  3 nf_nat,iptable_nat
nf_defrag_ipv4          1053  1 nf_conntrack_ipv4
nf_conntrack           53380  4
nf_conntrack_ipv4,nf_nat,iptable_nat,ipt_MASQUERADE
ip_tables               9560  1 iptable_nat
x_tables               11483  3 ip_tables,iptable_nat,ipt_MASQUERADE
ext2                   54932  2
dm_crypt               14122  0
dm_mod                 63271  1 dm_crypt
snd_usb_audio          74605  0
snd_usbmidi_lib        15415  1 snd_usb_audio
snd_hwdep               5165  1 snd_usb_audio
snd_seq_midi            3890  0
snd_seq_midi_event      4426  1 snd_seq_midi
snd_rawmidi            15758  2 snd_seq_midi,snd_usbmidi_lib
snd_pcm                57532  1 snd_usb_audio
snd_page_alloc          4675  1 snd_pcm
snd_seq                41501  2 snd_seq_midi_event,snd_seq_midi
snd_seq_device          4683  3 snd_seq,snd_rawmidi,snd_seq_midi
snd_timer              15155  2 snd_seq,snd_pcm
snd                    44456  8
snd_timer,snd_seq_device,snd_seq,snd_pcm,snd_rawmidi,snd_hwdep,snd_usbmidi_lib,snd_usb_audio
evdev                   7488  0
soundcore               4752  1 snd
gspca_ov519            27772  0
gspca_main             17650  1 gspca_ov519
cdc_ether               3348  0
videodev               69813  1 gspca_main
usbnet                 13267  1 cdc_ether
media                   9171  1 videodev
cdc_acm                13586  2
mii                     3513  1 usbnet
ixp4xx_eth             13722  0
ixp4xx_qmgr             4701  6 ixp4xx_eth
ixp4xx_npe              5630  2 ixp4xx_eth
libphy                 14448  1 ixp4xx_eth
ixp4xx_beeper           1793  0
ohci_hcd               17936  0
ext3                  163483  4
mbcache                 4464  2 ext3,ext2
jbd                    57469  1 ext3
sd_mod                 29032  8
crc_t10dif              1110  1 sd_mod
usb_storage            35325  7
scsi_mod              109660  2 usb_storage,sd_mod
ehci_hcd               39605  0
usbcore               123599  12
ehci_hcd,usb_storage,ohci_hcd,cdc_acm,usbnet,cdc_ether,gspca_main,gspca_ov519,snd_usbmidi_lib,snd_usb_audio
usb_common               648  1 usbcore

-- /etc/initramfs-tools/modules

-- /etc/kernel-img.conf
# Kernel image management overrides
# See kernel-img.conf(5) for details
do_symlinks = yes
relative_links = yes
do_bootloader = no
do_bootfloppy = no
do_initrd = yes
link_in_boot = yes
postinst_hook = flash-kernel

-- /etc/initramfs-tools/initramfs.conf
MODULES=most
BUSYBOX=y
KEYMAP=n
COMPRESS=gzip
DEVICE=
NFSROOT=auto

-- /etc/initramfs-tools/update-initramfs.conf
update_initramfs=yes
backup_initramfs=no

-- /etc/crypttab
# <target name>	<source device>		<key file>	<options>

-- /sys/block
mtdblock0
mtdblock1
mtdblock2
mtdblock3
mtdblock4
mtdblock5
sda
sdb

-- mkinitramfs hooks
/etc/initramfs-tools/hooks/:

/usr/share/initramfs-tools/hooks:
busybox
cryptgnupg
cryptkeyctl
cryptopenct
cryptopensc
cryptpassdev
cryptroot
dmsetup
flash_kernel_set_root
keymap
klibc
kmod
nslu2
thermal
udev


-- System Information:
Debian Release: 7.5
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: armel (armv5tel)

Kernel: Linux 3.2.0-4-ixp4xx
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash

Versions of packages initramfs-tools depends on:
ii  cpio               2.11+dfsg-0.1
ii  klibc-utils        2.0.1-3.1
ii  kmod               9-3
ii  module-init-tools  9-3
ii  udev               175-7.2

Versions of packages initramfs-tools recommends:
ii  busybox-static  1:1.20.0-7

Versions of packages initramfs-tools suggests:
ii  bash-completion  1:2.0-1

-- no debconf information


Reply to: