Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.

Bug 4072

Summary: mkbootdisk does not respect comment indicators in /etc/fstab
Product: [Retired] Red Hat Linux Reporter: R P Herrold <herrold>
Component: mkbootdiskAssignee: Matt Wilson <msw>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.0   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
URL: http://www.owlriver.com
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 1999-09-25 04:03:13 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description R P Herrold 1999-07-16 14:06:44 UTC
Summary: The created /etc/lilo.conf on the bootdisk is not
correctly created.  FIX listed at end of text.

Steps to recreate:

[root@pokey etc]# grep  sda1 /etc/fstab
#/dev/sda1               /                       ext2
defaults        1 1
/dev/sda1               /               ext2    defaults
  2 2

(fstab has a commented entry for the boot drive and part'n
listed before the effective entry)

-------------------------------

By not respecting the comment indicator, mkbootdisk tries
to use the commented out drive:

[root@pokey /root]# mkbootdisk 2.2.5-22
/sbin/mkbootdisk: [: too many arguments
Insert a disk in /dev/fd0. Any information on the disk will
be lost.
Press <Enter> to continue or ^C to abort:
cp: #/dev/sda1: No such file or directory
cp: #: No such file or directory

------------------------------------
(mounted the created floppy)
Note that it tries to boot, therefore, off the 'commented'
drive, first listed
[root@pokey etc]# pwd
/mnt/floppy/etc
[root@pokey etc]# cat lilo.conf
boot=/dev/fd0
timeout=100
message=/boot/message
prompt
image=/vmlinuz-2.2.5-22
        label=linux
        root=#/dev/sda1
/dev/sda1
#
        initrd=/initrd.img
image=/vmlinuz-2.2.5-22
        label=rescue
        append="load_ramdisk=2 prompt_ramdisk=1"
        root=/dev/fd0
        initrd=/initrd.img


FIX:

Current code is:

rootdev=`awk '/[ \t]\/[ \t]/ { print $1}' /etc/fstab`
[ -z $rootdev ] && {
    echo 'Cannot find root partition in /etc/fstab.' >&2
    exit 1
}

... change the first line to only consider non-commented
lines in /etc/fstab:

grep -v ^# /etc/fstab > /tmp/fstab
rootdev=`awk '/[ \t]\/[ \t]/ { print $1}' /tmp/fstab`
rm /tmp/fstab

Comment 1 Michael K. Johnson 1999-09-25 04:03:59 UTC
Fixed in mkbootdisk-1.2.2-1 by making fstab parsing generally more
robust.