SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2013-04-12 23:36:49

cpoakes
#! CrunchBanger
From: Tucson, Arizona
Registered: 2012-05-19
Posts: 202

Fix df command: eliminate root device by UUID

As noted in this previous post and this Debian bug report the df command in wheezy identifies the root filesystem with a symlink such as "/dev/disk/by-uuid/292a49f9-790a-49fb-9912-383e99287bf8".  This creates two major annoyances: the command output is wider and unreadable on an 80 column terminal and the actual device is no longer identified. 

Furthermore, the handling of devices is inconsistent.  This issue only applies to the root device; other devices specified by UUID in /etc/fstab are NOT displayed by UUID symlinks but utilize actual device names.  The issue originates during boot where the initramfs busybox version of mount behaves differently than the standard version of mount.  The standard version translates devices identified by UUID to actual devices, and actual devices appear in the mount table (/proc/mounts).  The busybox version does NOT translate devices identified by UUID, and the symlink (not the actual device) appears in the mount table. 

In most cases, the kernel boot parameter "root" specifies a device by UUID, and thus the related symlink ends up in the mount table for the root device.  In addition to df, this symlink is also displayed by any program or script that accesses the mount table including the mount command. 

Several unsatisfactory solutions were discussed in the previous forum post:  1) don't use df (install another command), 2) use the actual device as the kernel boot parameter (problematic and not recommended), or 3) use the device nodename not UUID in the kernel boot parameter (nearly as cryptic as UUID and also not recommended). 

The official solution in the Debian bug report is an upstream change to coreutils in which df translates the symlink to the actual device.  However, this change made it into sid not wheezy - so the bug will persist until jessie (not release critical).  Another solution suggested in the bug report translates a root device specified by UUID to an actual device prior to the busybox mount command.  (Editorial note: this should have been the official solution to provide consistency 1) between the two versions of mount, 2) within the mount table, and 3) with historical behaviour.) 

The following script implements this suggestion.  As root, add this initramfs script as /etc/initramfs-tools/scripts/local-premount/rootdevice:

#!/bin/sh
#  Mimic a "normal" mount of root device by translating the device link 
#  (UUID or LABEL) to the actual device.

set -e

[ "$1" = prereqs ] && exit 0

REALROOT=`readlink -f ${ROOT}`
[ "${REALROOT}" ] && echo "ROOT=${REALROOT}" >> /conf/param.conf

exit 0

As root, make sure the script has correct permissions:

chown root:root /etc/initramfs-tools/scripts/local-premount/rootdevice
chmod +x /etc/initramfs-tools/scripts/local-premount/rootdevice 

Update the initramfs (as root):

update-initramfs -u

And reboot.  The df and mount commands now report the actual device, using the shorter device name.  Tested with wheezy/waldorf, but may apply to other distros. 

Technical note:  This script, like all child processes, cannot alter the environment of the parent process (ROOT in initramfs script).  Instead, a mechanism specific to initramfs scripts is employed to alter the parent's environment: the new environment value is written to /conf/param.conf which is sourced in the parent after the child (rootdevice) completes.  Without this facility, it would have been necessary to alter the actual master initramfs script.

Update: modified to indicate actions should be performed as root and file is owner/group root:root.

Last edited by cpoakes (2013-10-05 11:41:46)


programming and administering unix since 1976 (BSD, System III, Xenix, System V, Linux)

Offline

Help fund CrunchBang, donate to the project!

#2 2013-04-14 22:28:06

dura
Bloated Gimp
From: interzone
Registered: 2012-09-15
Posts: 2,108

Re: Fix df command: eliminate root device by UUID

Thanks!

Offline

#3 2013-10-02 18:08:15

falcon7700
New Member
Registered: 2013-10-02
Posts: 2

Re: Fix df command: eliminate root device by UUID

I've been trying to solve the UUID problem for a while, and a long search led me to this post, where I found "hope"....

However, I use Debian (wheezy) and though it's similar, it's not the same ;-(
The script concatenates some stuff on the end of /conf/param.conf . Since Debian doesn't have this, I guess it must be a Crunchbang thing.  Anyone know how to make this work on standard Debian? Is there an analogue to param.conf?

Offline

#4 2013-10-02 19:47:40

falcon7700
New Member
Registered: 2013-10-02
Posts: 2

Re: Fix df command: eliminate root device by UUID

(answering my own question)
For the Debian users out there, it turns out there is an easier way:
In /etc/default/grub, just uncomment the line:
#GRUB_DISABLE_LINUX_UUID=true

Then run update-grub

Offline

#5 2013-10-05 11:21:20

cpoakes
#! CrunchBanger
From: Tucson, Arizona
Registered: 2012-05-19
Posts: 202

Re: Fix df command: eliminate root device by UUID

Sorry this didn't work for you.   Disabling UUIDs in grub is certainly is easier and works fine for most users.  For others considering disabling UUIDs in grub, understand why this is not the default configuration or you may create a system that becomes unbootable. 

The initramfs script is a general solution for all cases, and relevant to root devices identified with UUIDs or LABELs.  It was developed with the first official wheezy release before adding any CB packages or applying to waldorf.  It remains functional after a recent update/upgrade.  Furthermore, I took a look at the files installed from wheezy package initramfs-tools to /usr/share/initramfs-tools used to build an initramfs.  They specifically source /conf/param.conf, so this is definitely a standard feature of wheezy and not a CrunchBangism.


programming and administering unix since 1976 (BSD, System III, Xenix, System V, Linux)

Offline

#6 2013-10-05 11:38:14

cpoakes
#! CrunchBanger
From: Tucson, Arizona
Registered: 2012-05-19
Posts: 202

Re: Fix df command: eliminate root device by UUID

Just removed changes from my wheezy system and rebuilt a normal initramfs; reboot and shows UUID.  Reinstalled from my original directions and text rebuilding initramfs; reboot and df shows device.  No clue why it didn't work for you falcon7700 unless perhaps the file was not owner/group root:root. (Modified instructions to reflect this).


programming and administering unix since 1976 (BSD, System III, Xenix, System V, Linux)

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat

Debian Logo