Bug 111631 - Non-standard fstab causes kernel update to silently be done incorrectly
Non-standard fstab causes kernel update to silently be done incorrectly
Status: CLOSED CANTFIX
Product: Red Hat Linux
Classification: Retired
Component: up2date (Show other bugs)
8.0
athlon Linux
medium Severity medium
: ---
: ---
Assigned To: Bret McMillan
Fanny Augustin
:
Depends On:
Blocks: 120092
  Show dependency treegraph
 
Reported: 2003-12-06 21:54 EST by Dale R. Worley
Modified: 2007-04-18 12:59 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-10-18 13:07:52 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Output from "rpm -vv --install". (125.20 KB, text/plain)
2003-12-06 21:55 EST, Dale R. Worley
no flags Details
Output from "new-kernel-pkg -x". (2.29 KB, text/plain)
2003-12-06 21:56 EST, Dale R. Worley
no flags Details

  None (edit)
Description Dale R. Worley 2003-12-06 21:54:19 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1)
Gecko/20030225

Description of problem:
Unfortunately, this is a rather messy problem, but I've tracked down
the mechanics of it, and included them here.  At the bottom I
summarize the core of the bug, that /sbin/new-kernel-pkg doesn't
gracefully handle the case when /etc/fstab has more than one line
listing a partition to be mounted as '/'.

The ultimate symptom was that I attempted to update my RH 8.0 system
using up2date.  It seemed to update everything OK, including
installing kernel-2.4.20-24.8 into the Grub configuration.  But when I
attempted to boot 2.4.20, the boot process halted, complaining that it
could not find 'init', I think.  (I did not write down the error
message.)  There was also a message about pivotroot.  (The messages
resemble what is reported in bug 91622.)

Backing up, I will add that there was a strange message during the
install of the kernel package:

  40:iproute               
########################################### [100%]
  41:kernel                
########################################### [100%]
awk: cmd. line:1: $2 == "Root
awk: cmd. line:1:       ^ unterminated string
  42:kernel-doc            
########################################### [100%]

I did some poking around, and discovered that the RPM database marked
kernel-2.4.20 as installed.  (Attempting to rpm --install -p
.../kernel-2.4.20-24.8.athlon.rpm failed with the message that
kernel-2.4.20-24.8 was already installed.)  But up2date hadn't removed
the rpm file from /var/spool/up2date, suggesting that up2date had
discovered some sort of problem.

Repeated 'rpm --erase kernel-2.4.20-24.8' and 'rpm --install -p
/var/spool/up2date/kernel-2.4.20-24.8.athon.rpm' generated the two
lines starting with 'awk:' on every install.

So I did the install with -vv (very verbose).  The full output is in
an attachment marked "rpm -vv --install".  The crucial lines are the
ones that precede the "awk:" lines:

+ '[' -x /sbin/new-kernel-pkg ']'
+ /sbin/new-kernel-pkg --mkinitrd --depmod --install 2.4.20-24.8
awk: cmd. line:1: $2 == "Root
awk: cmd. line:1:       ^ unterminated string
D:   install: waitpid(15570) rc 15570 status 0

This suggested that new-kernel-pkg was invoking awk, which was
generating the messages.

I then put 'set -x' at the top of /sbin/new-kernel-pkg and did the
install again.  By comparison with the first attachment, you can see
exactly what the script new-kernel-pkg outputs, which is in the
attachment labeled "new-kernel-pkg -x".  The crucial lines are:

++ awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab
+ rootdevice=LABEL=Root
/dev/hda7
++ echo LABEL=Root /dev/hda7
++ cut -d= -f1
+ short=LABEL
+ '[' LABEL == LABEL ']'
++ echo LABEL=Root /dev/hda7
++ cut -d= -f2
+ label=Root /dev/hda7
++ echo showlabels
++ /sbin/nash --force --quiet
++ awk '$2 == "Root' '/dev/hda7" {print $1}'
awk: cmd. line:1: $2 == "Root
awk: cmd. line:1:       ^ unterminated string
+ device=

These lines are generated by the following lines of /sbin/new-kernel-pkg:

    # get the root filesystem to use; if it's on a label make sure it's
    # been configured. if not, get the root device from mount
    rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1;
}}' /etc/fstab)
    short=$(echo $rootdevice | cut -d= -f1)
    if [ $short == "LABEL" ]; then
	label=$(echo $rootdevice | cut -d= -f2)
	device=$(echo "showlabels" | /sbin/nash  --force --quiet | 
			awk '$2 == "'$label'" {print $1}')

As you can see by looking at these lines, they extract some
information from /etc/fstab.  The awk error message is generated by
the invocation of awk in the line that defines $device, and as you can
see by the -x listing, that is because the value of $label is
incorrect.  (I haven't figured out what $label is supposed to do, but
clearly, it is not supposed to contain spaces.)

Extracting these lines from new-kernel-pkg and playing with them a bit
shows that it is trying to discover the device containing the root
partition by looking in /etc/fstab.  A quick look at my /etc/fstab
shows that it contains *two* such lines:

LABEL=Root		/			ext3	defaults	1 1

/dev/hda7		/			ext3	noauto		0 0

I probably shouldn't do that, but as long as the second one is marked
'noauto', it runs correctly.

I changed the second line to:

/dev/hda7		none			ext3	noauto		0 0

Then I re-installed kernel-2.4.20-24.8.  The 'awk:' messages did not
appear.  And I could then boot the Grub entry for kernel-2.4.20-24.8.

In summary, I think the proper description of the bug is:

If multiple '/' partitions are listed in /etc/fstab, new-kernel-pkg
needs to be able to detect this and fail cleanly.  As it is, it
produces strange messages, installs at least some of the files, and
creates a Grub entry which will not work.

I also suspect that new-kernel-pkg will also fail if there are zero
/etc/fstab entries, or if those entries contain shell-special characters.

And perhaps people should be warned not to have multiple '/'
partitions listed in /etc/fstab, though I don't know what the correct
way of doing this would be.


Version-Release number of selected component (if applicable):
kernel-2.4.20-24.8.athlon.rpm

How reproducible:
Always

Steps to Reproduce:
1. Add a new line to /etc/fstab listing an additional disk parition to
be mounted as '/'.  Make sure to mark it 'noauto', so the system works
OK anyway.

2. Install an upgraded kernel, using up2date, or directly with 'rpm
--inistall -p ...'.
   

Actual Results:  1. Produces the error messages:

awk: cmd. line:1: $2 == "Root
awk: cmd. line:1:       ^ unterminated string

2. Adds an entry to /boot/grub/grub.conf, but the entry cannot be used
to boot the system.

3. When using up2date, leaves the kernel RPM file in /var/spool/up2date.


Expected Results:  Either process (up2date or rpm) should (1) figure
out what the real root partition is and update it appropriately, or
(2) discover the problem, produce a user-comprehensible error message,
and leave the system unchanged.


Additional info:
Comment 1 Dale R. Worley 2003-12-06 21:55:30 EST
Created attachment 96386 [details]
Output from "rpm -vv --install".
Comment 2 Dale R. Worley 2003-12-06 21:56:03 EST
Created attachment 96387 [details]
Output from "new-kernel-pkg -x".
Comment 3 Bill Nottingham 2006-08-07 15:49:41 EDT
Red Hat Linux is no longer supported by Red Hat, Inc. If you are still
running Red Hat Linux, you are strongly advised to upgrade to a
current Fedora Core release or Red Hat Enterprise Linux or comparable.
Some information on which option may be right for you is available at
http://www.redhat.com/rhel/migrate/redhatlinux/.

Red Hat apologizes that these issues have not been resolved yet. We do
want to make sure that no important bugs slip through the cracks.
Please check if this issue is still present in a current Fedora Core
release. If so, please change the product and version to match, and
check the box indicating that the requested information has been
provided. Note that any bug still open against Red Hat Linux on will be
closed as 'CANTFIX' on September 30, 2006. Thanks again for your help.
Comment 4 Bill Nottingham 2006-10-18 13:07:52 EDT
Red Hat Linux is no longer supported by Red Hat, Inc. If you are still
running Red Hat Linux, you are strongly advised to upgrade to a
current Fedora Core release or Red Hat Enterprise Linux or comparable.
Some information on which option may be right for you is available at
http://www.redhat.com/rhel/migrate/redhatlinux/.

Closing as CANTFIX.

Note You need to log in before you can comment on or make changes to this bug.