[xenial][initramfs-tools] support uppercase and lowercase uuids

Bug #1548120 reported by Manoj Iyer
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
initramfs-tools (Ubuntu)
Fix Released
High
Manoj Iyer

Bug Description

Initramfs tools does not support uppercase UUIDs. Initramfs-tools script/functions uses blkid to determine the device name from UUID/PARTUUID but if either of those are in uppercase blkid fails to return the name.

Tags: patch
Revision history for this message
Manoj Iyer (manjo) wrote :

This patch fixes this issue. I tested the functionality of this function by creating a script invoking this function as standalone.

$ sudo ./test.sh
+ resolve_device PARTUUID=275f782b-3c55-4b3f-acb2-c17db0eaee8d
+ DEV=PARTUUID=275f782b-3c55-4b3f-acb2-c17db0eaee8d
+ case "$DEV" in
+ case "$DEV" in
++ echo PARTUUID=275f782b-3c55-4b3f-acb2-c17db0eaee8d
++ cut -f 1 -d =
+ local type=PARTUUID
++ echo PARTUUID=275f782b-3c55-4b3f-acb2-c17db0eaee8d
++ tr '[:upper:]' '[:lower:]'
++ cut -f 2 -d =
+ local value=275f782b-3c55-4b3f-acb2-c17db0eaee8d
+ DEV=PARTUUID=275f782b-3c55-4b3f-acb2-c17db0eaee8d
+ command -v blkid
++ blkid -l -t PARTUUID=275f782b-3c55-4b3f-acb2-c17db0eaee8d -o device
+ DEV=/dev/sda2
+ '[' -e /dev/sda2 ']'
+ echo /dev/sda2
/dev/sda2
+ resolve_device PARTUUID=275F782B-3C55-4B3F-ACB2-C17DB0EAEE8D
+ DEV=PARTUUID=275F782B-3C55-4B3F-ACB2-C17DB0EAEE8D
+ case "$DEV" in
+ case "$DEV" in
++ echo PARTUUID=275F782B-3C55-4B3F-ACB2-C17DB0EAEE8D
++ cut -f 1 -d =
+ local type=PARTUUID
++ echo PARTUUID=275F782B-3C55-4B3F-ACB2-C17DB0EAEE8D
++ cut -f 2 -d =
++ tr '[:upper:]' '[:lower:]'
+ local value=275f782b-3c55-4b3f-acb2-c17db0eaee8d
+ DEV=PARTUUID=275f782b-3c55-4b3f-acb2-c17db0eaee8d
+ command -v blkid
++ blkid -l -t PARTUUID=275f782b-3c55-4b3f-acb2-c17db0eaee8d -o device
+ DEV=/dev/sda2
+ '[' -e /dev/sda2 ']'
+ echo /dev/sda2
/dev/sda2

Changed in initramfs-tools (Ubuntu):
assignee: nobody → Manoj Iyer (manjo)
importance: Undecided → High
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "Patch to support uppercase and lowercase uuids" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
dino99 (9d9) wrote :

initramfs-tools (0.122ubuntu4) xenial; urgency=medium

  [ Manoj Iyer ]
  * Add support for uppercase and lowercase uuids. (LP: #1548120)

 -- Andy Whitcroft <email address hidden> Sun, 21 Feb 2016 22:12:36 +0000

Changed in initramfs-tools (Ubuntu):
status: New → Fix Released
Revision history for this message
Manoj Iyer (manjo) wrote :

tr trick does not work in the initramfs environement.

(initramfs) echo "81780AD9-068C-4A80-A795-56856973B8F9" | cut -f 2 -d = | tr '[
:upper:]' '[:lower:]'

81780AD9-068C-4A80-A795-56856973B8F9

But awk works:
(initramfs) echo "81780ad9-068c-4a80-a795-56856973b8f9" | awk '{print tolower($0)}'

81780ad9-068c-4a80-a795-56856973b8f9

I will resubmit the patch using awk instead.

Revision history for this message
Manoj Iyer (manjo) wrote :

Sorry here is what does not work:

(initramfs) echo "81780AD9-068C-4A80-A795-56856973B8F9" | tr '[:upper:]' '[:lower:]'

81780AD9-068C-4A80-A795-56856973B8F9

Manoj Iyer (manjo)
Changed in initramfs-tools (Ubuntu):
status: Fix Released → In Progress
Revision history for this message
Manoj Iyer (manjo) wrote :

With the attached patch I was able to boot with root=PARUUID=<PARUUID>

$ cat /proc/cmdline
BOOT_IMAGE=/EFI/BOOT/vmlinuz-4.3.0-8-generic boot=local earlycon=pl011,0x3ced1000 console=ttyAMA1 debug user_debug=31 loglevel=9 uefi_debug e1000e.IntMode=1 pci=pcie_bus_safe acpi=force cpuidle.off=1 usb-storage.delay_use=1 rootwait rw root=PARTUUID=81780AD9-068C-4A80-A795-56856973B8F9 rootfstype=ext4

Andy Whitcroft (apw)
tags: added: block-proposed
Revision history for this message
Andy Whitcroft (apw) wrote :

Hmm, that on the surface of things makes no sense as mini-tr exists in busybox and in theory at least supports those constructs. Blocking this in proposed while we get to the bottom of this.

Revision history for this message
Andy Whitcroft (apw) wrote :

Ok, it seems that busybox tr does not actually support symbolic ranges. Rather than add a first user of awk it seems simpler to manually expand the character ranges. Specifically as the specification says the following:

    "The hexadecimal values "a" through "f" are output as lower case characters and are case insensitive on input."

we can simply map A-F to a-f and cover all valid cases.

@manjo -- I have uploaded this fix to my ppa:apw/ubuntu/initramfs-tools-test for testing. Could you do one final test with that one before I break the archive again.

Revision history for this message
Manoj Iyer (manjo) wrote :

@apw can you pls fix these dependencies in your packge?

initramfs-tools : Depends: initramfs-tools-core (= 0.122ubuntu5~rc1) but it is not going to be installed
initramfs-tools-core : Depends: initramfs-tools-bin (= 0.122ubuntu5~rc1) but 0.122ubuntu4 is to be installed
initramfs-tools-bin is already the newest version (0.122ubuntu4).

Revision history for this message
Manoj Iyer (manjo) wrote :

I was able to boot with the package/patch in your PPA. root=PARTUUID=<PARTUUID>

$ cat /proc/cmdline
BOOT_IMAGE=/EFI/BOOT/vmlinuz-4.3.0-8-generic boot=local earlycon=pl011,0x3ced1000 console=ttyAMA1 debug user_debug=31 loglevel=9 uefi_debug e1000e.IntMode=1 pci=pcie_bus_safe acpi=force cpuidle.off=1 usb-storage.delay_use=1 rootwait rw root=PARTUUID=81780AD9-068C-4A80-A795-56856973B8F9 rootfstype=ext4
ubuntu@bandera:~$

Revision history for this message
Manoj Iyer (manjo) wrote :

and lower case also works.
$ cat /proc/cmdline
BOOT_IMAGE=/EFI/BOOT/vmlinuz-4.3.0-8-generic boot=local earlycon=pl011,0x3ced1000 console=ttyAMA1 debug user_debug=31 loglevel=9 uefi_debug e1000e.IntMode=1 pci=pcie_bus_safe acpi=force cpuidle.off=1 usb-storage.delay_use=1 rootwait rw root=PARTUUID=81780ad9-068c-4a80-a795-56856973b8f9 rootfstype=ext4

Revision history for this message
Manoj Iyer (manjo) wrote :

$ apt-cache policy initramfs-tools
initramfs-tools:
  Installed: 0.122ubuntu5~rc2
  Candidate: 0.122ubuntu5~rc2
  Version table:
 *** 0.122ubuntu5~rc2 500
        500 http://ppa.launchpad.net/apw/initramfs-tools-test/ubuntu xenial/main arm64 Packages
        100 /var/lib/dpkg/status
     0.122ubuntu3 500
        500 http://ports.ubuntu.com/ubuntu-ports xenial/main arm64 Packages

Revision history for this message
Andy Whitcroft (apw) wrote :

Ok applied and uploaded. Sorting some dependancies on other packages right now.

Changed in initramfs-tools (Ubuntu):
status: In Progress → Fix Committed
Revision history for this message
hakuna_matata (hakuna-matata) wrote :

The fix doesn't work for UUIDs of a Windows file system. blkid uses always UUIDs in upper case for these file systems. So it fails because the fix converts all UUIDs in lower case.

IMHO short UUIDs (length <= 16) should be always converted in upper case because short UUIDs are only UUIDs of a Windows file systems.

It can affect also systems without Windows because the EFI partition has a Windows file system (vfat).

In my case it fails booting into a loopback device(ext4) on a Windows file system (ntfs).

Please fix your patch. Thanks.

dino99 (9d9)
Changed in initramfs-tools (Ubuntu):
status: Fix Committed → New
Revision history for this message
Andy Whitcroft (apw) wrote :

@hakuna_matata -- thanks for the report there, testing here confirms your findings that they are upper case on NTFS and only match with upper case. Properly the fix for this whole mess should be in util-linux in blkid as the individual formats have specific forms and only it knows what is appropriate to do to that UUID such that we do not lose information in the transformation. I am filing a new bug for that isssue so we track it clearly. See Bug #1553107.

Andy Whitcroft (apw)
tags: removed: block-proposed
tags: added: block-proposed
Andy Whitcroft (apw)
tags: removed: block-proposed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package initramfs-tools - 0.122ubuntu6

---------------
initramfs-tools (0.122ubuntu6) xenial; urgency=medium

  [ Andy Whitcroft ]
  * uuids: only apply case mapping to RFC#4122 format uuids (LP: #1553107,
    #1548120)

  [ Timo Aaltonen ]
  * hooks/framebuffer: Copy kernel/ubuntu/i915 backport driver too. (LP:
    #1500751)

initramfs-tools (0.122ubuntu5) xenial; urgency=medium

  [ Andy Whitcroft ]
  * uuids: busybox tr does not support symbolic ranges expand manually
    (LP: #1548120)

  [ Martin Pitt ]
  * wait-for-root.c: Drop check if device is queued in udev (LP: #1539195)

initramfs-tools (0.122ubuntu4) xenial; urgency=medium

  [ Manoj Iyer ]
  * Add support for uppercase and lowercase uuids. (LP: #1548120)

 -- Andy Whitcroft <email address hidden> Fri, 04 Mar 2016 10:12:42 +0000

Changed in initramfs-tools (Ubuntu):
status: New → Fix Released
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.