[Top][All Lists]

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

Use of df in grub-install

From: Han Holl
Subject: Use of df in grub-install
Date: Mon, 11 Feb 2002 13:07:30 +0100


In grub-install df is used to get the devicename for a file or directory.
Because df basically uses /etc/mtab to obtain this information,
it's quite useless in a chrooted environment.
I always used 'chroot /hard-disk-mount lilo' for installation
or restore disks, to avoid version mismatches between the
installation floppy/cd and the lilo and/or shared libraries
on the hard disk.
With grub-install in it's current form, that's impossible.
Maybe grub-install could somehow recognize the fact that
it's chrooted, and then avoid df. /etc/fstab may be the
better choice in this circumstance? I use somehting like this
in a script with roughly the same purpose as grub-install:
if [ -f /proc/mounts ]
        rootdev=$(df /| sed -n \$p | awk '{print $1}')
        bootdev=$(df /boot| sed -n \$p | awk '{print $1}')
        rootdev=$(awk '{if ($2 == "/") print $1}' /etc/fstab)
        bootdev=$(awk '{if ($2 == "/boot") print $1}' /etc/fstab)
        [ "$bootdev" ] || bootdev=$rootdev

but of course there are other possible reasons for /proc
not being mounted. The above works for me though.

Han Holl

(Another case where /etc/mtab becomes unreliable is with a
read-only root filesystem).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]