Bug 54352 - cannot partition /tmp/sdb in %post
Summary: cannot partition /tmp/sdb in %post
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: anaconda   
(Show other bugs)
Version: 7.3
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Jeremy Katz
QA Contact: Mike McLean
Depends On:
TreeView+ depends on / blocked
Reported: 2001-10-04 17:30 UTC by Michael E Brown
Modified: 2007-04-18 16:37 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2003-07-28 22:40:45 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
kickstart %post section (4.41 KB, text/plain)
2001-10-04 17:31 UTC, Michael E Brown
no flags Details
dmesg output (after first 'fdisk' attempt). Note the last line. (8.61 KB, text/plain)
2001-10-04 17:32 UTC, Michael E Brown
no flags Details
lsof output, from before any partitioning (fdisk) takes place. Note "/tmp/sdb (deleted)" entry. (8.16 KB, text/plain)
2001-10-04 17:33 UTC, Michael E Brown
no flags Details
ps aux output (1.46 KB, text/plain)
2001-10-04 17:34 UTC, Michael E Brown
no flags Details
stderr output from kickstart file. (1.33 KB, text/plain)
2001-10-04 17:34 UTC, Michael E Brown
no flags Details
stdout output from kickstart file. (1.70 KB, text/plain)
2001-10-04 17:35 UTC, Michael E Brown
no flags Details
script that fails in %post (2.42 KB, text/plain)
2002-09-24 18:51 UTC, Michael E Brown
no flags Details
updated script to work around bug. (2.25 KB, text/plain)
2002-09-24 19:59 UTC, Michael E Brown
no flags Details

Description Michael E Brown 2001-10-04 17:30:56 UTC
Description of Problem:

In our install, we install the OS to sda, and we have a section in %post
that will automatically partition and mke2fs on any remaining disks. This
does not work when you have an uninitialized partition table (eg. 'dd
if=/dev/zero of=/dev/sdb bs=512 count=100' ). Fdisk returns with the error:

Calling ioctl() to re-read partition table.
Re-read table failed with error 16: Device or resource busy.
Reboot your system to ensure the partition table is updated.

And, in the system 'dmesg' output, I see this error: 

Device busy for revalidation (usage=2)

When our 'mke2fs' runs, we get this error:

/sbin/mke2fs: No such device or address while trying to determine
filesystem size

I believe that these errors are due to this (lsof output):

sh      720 root   14u   BLK    8,0              148 /tmp/sda (deleted)
sh      720 root   15u   BLK   8,16              149 /tmp/sdb (deleted)

which corresponds to this 'ps aux' output:

root         1  1.4  0.0     0    0 ?        SW   06:11   0:03 [swapper]
root         2  0.0  0.0     0    0 ?        SW   06:11   0:00 [keventd]
root         3  0.0  0.0     0    0 ?        SWN  06:11   0:00 [ksoftirqd_CPU0]
root         4  0.1  0.0     0    0 ?        SW   06:11   0:00 [kswapd]
root         5  0.0  0.0     0    0 ?        SW   06:11   0:00 [kreclaimd]
root         6  0.1  0.0     0    0 ?        SW   06:11   0:00 [bdflush]
root         7  0.1  0.0     0    0 ?        SW   06:11   0:00 [kupdated]
root         8  0.0  0.0     0    0 ?        SW<  06:11   0:00 [mdrecoveryd]
root         9  0.0  0.0    20   20 tty1     S    06:11   0:00 linuxrc
root        10  0.0  0.0    20   20 tty1     S    06:11   0:00 linuxrc
root        11  0.9  2.1  8072 5372 tty1     S    06:11   0:02
/usr/bin/python /
root        24  0.0  0.0     0    0 tty1     SW   06:11   0:00 [khubd]
root        46  0.0  0.0     0    0 tty1     SW<  06:11   0:00 [loop0]
root        47  0.0  0.4  2020 1084 tty2     S    06:11   0:00 -/bin/sh
root        75  6.6  0.8 15440 2088 tty1     S    06:11   0:15
root        77 31.3 17.1 48552 43908 tty1    S    06:11   1:09
/usr/bin/python /
root       106  0.0  0.7  3480 2000 tty1     S    06:12   0:00
/usr/bin/python /
root       720  0.0  0.4  2420 1156 tty1     S    06:15   0:00 /bin/sh
root       736  0.0  0.2  2632  720 tty1     R    06:15   0:00 ps aux

Note that process ID 720 is the '/bin/sh' process running %post. I am
attaching our kickstart %post section, as well as the lsof, and ps listing.

Please note that this process works perfectly on any disk, except one that
has zeros in the partition table.

Version-Release number of selected component (if applicable): 
Red Hat Linux 7.2 (gold)

How Reproducible:
Use the attached kickstart file on a two-disk scsi system. write zeros to
the partition table of the second disk.

Comment 1 Michael E Brown 2001-10-04 17:31:36 UTC
Created attachment 33378 [details]
kickstart %post section

Comment 2 Michael E Brown 2001-10-04 17:32:35 UTC
Created attachment 33379 [details]
dmesg output (after first 'fdisk' attempt). Note the last line.

Comment 3 Michael E Brown 2001-10-04 17:33:34 UTC
Created attachment 33380 [details]
lsof output, from before any partitioning (fdisk) takes place. Note "/tmp/sdb (deleted)" entry.

Comment 4 Michael E Brown 2001-10-04 17:34:02 UTC
Created attachment 33381 [details]
ps aux output

Comment 5 Michael E Brown 2001-10-04 17:34:42 UTC
Created attachment 33382 [details]
stderr output from kickstart file.

Comment 6 Michael E Brown 2001-10-04 17:35:05 UTC
Created attachment 33383 [details]
stdout output from kickstart file.

Comment 7 Michael E Brown 2001-10-04 18:11:19 UTC
In addition, anaconda gives the following error on VT3 during partitioning (from
memory, may be slightly off):

zeroMBA specified but invalid partition table specified on sdb

I would like to postulate that anaconda is missing a "close" in the error-path,
and all of it's children are inheriting this open file descriptor.

Comment 8 Michael Fulbright 2001-10-11 15:09:02 UTC
Jeremy please look at this report.

Comment 9 Jeremy Katz 2001-10-11 19:26:59 UTC
Yes, the diskset is not getting closed prior to the end of the installation... 
testing a small update to fix this now

Comment 10 Brent Fox 2001-10-18 14:57:54 UTC
katzj, any progress with this?

Comment 11 Jeremy Katz 2001-10-18 15:20:36 UTC
Working on this and a few other things at once.  Original patch still leaves
something with a dangling reference to the disk.

Comment 12 Brent Fox 2001-11-05 15:14:32 UTC
Is the patch working now?

Comment 13 Jeremy Katz 2001-11-05 17:35:05 UTC
Nope, and still not sure what's holding the reference

Comment 14 Matt Domsch 2001-12-11 16:32:36 UTC
Any update on this?

Comment 15 Jeremy Katz 2001-12-12 20:51:36 UTC
Nope, still looking off and on when I'm not being pulled in ten other directions

Comment 16 Jeremy Katz 2002-02-13 20:07:51 UTC
We're currently hitting other areas where partition tables aren't being reread
properly in Hampton, so hopefully cleaning some of those up will help with this
one too.  If not, it should at least be easier to figure out at least where it's
leaking with some of the other cleanups.

Comment 17 Jeremy Katz 2002-03-15 00:31:09 UTC
Still doesn't seem to get it.  Matt -- when there's a parted exception, are the
disk references being closed properly?

Comment 18 Michael Fulbright 2002-03-26 17:46:33 UTC
Deferring to future release.

Comment 19 Michael E Brown 2002-09-24 18:45:43 UTC
I am hitting this in RH 8.0 -Final-.

Comment 20 Michael E Brown 2002-09-24 18:51:24 UTC
Created attachment 77065 [details]
script that fails in %post

Comment 21 Michael E Brown 2002-09-24 19:58:26 UTC
just created a workaround for this issue. It doesn't address the underlying bug,
but it does work around it nicely.

Instead of using /dev/sdb1 as the PV for the VG, I am just using /dev/sdb directly.

New script will be attached. Please let me know if you know of anything that
will break because of this.

Comment 22 Michael E Brown 2002-09-24 19:59:45 UTC
Created attachment 77067 [details]
updated script to work around bug.

Comment 23 Michael Fulbright 2002-09-24 20:09:40 UTC
There have been no guarantees made about what commands can be run in the %post,
other than the installed system will be available as /mnt/sysimage.

Your only option is to change the way you create your partitions so that you
decide which drives will be used for what filesystems in the %pre, then write
out the appropriate kickstart partitioning commands to a temporary file, and
finally include that temporary file using the kickstart %include mechanism we
added in 7.3 to address this exact type of on-the-fly dynamic kickstart
situations.  This way you don't have to worry about catching this kind of
side-effect as you are now experiencing during the beta cycle when we could do
something about it.

Anyhow, to do this in a %pre you would just have something very similar to your
%post script that would run and detect the available block devices. You then can
write out ks 'part' rules for swap, '/', '/boot', etc as well as rules for the
remaining devices to go into the '/data' LVM mount.

Comment 24 Michael Fulbright 2002-10-24 17:58:35 UTC
This issue report has been quiet for some time and I wanted to check if there
was any further comments before I close it.

Comment 25 Jeremy Katz 2003-07-28 22:40:45 UTC
Assuming based on the lack of response to msf's comment that this isn't a
problem any more.  Please reopen if it is.

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