Disk setup in our Fedora Core 4 Kickstart environment

August 20, 2005

The problem with working on automatic installers is that testing them is such a slow and tedious process. These days, it takes about 30 minutes to reinstall Fedora Core 4, with patches and local changes, on my test machine. (Then when something looks like it works, I have to do three tests instead of just one: upgrade from Fedora Core 2 (with an extra reinstall to get back to FC2), reinstall Fedora Core 4, and install from a USB memory stick.)

Because of this I got to drum my fingers a lot today as I was nailing down the changes necessary (I think, I haven't been able to test them yet) to make our Kickstart disk setup stuff work on SATA machines as well as IDE ones.

When we Kickstart-install a machine, we want it to have nothing left on its disks except our partitions, created during the install. Essentially, we want to start with a clear partition table: either initialized from scratch or with all the existing partitions deleted. Confusing things, Kickstart has two directives to control this:

  • clearpart will let you delete some or all partitions.
  • the alarmingly named zerombr seems to just cause Kickstart to ignore invalid Master Boot Records on disks and initialize them from scratch.

We need zerombr to deal with new disks straight from the vendor that don't have a valid MBR. We need clearpart to deal with things like new systems that ship pre-partitioned and with Windows installed (as well as reinstalling systems). Thus, our Fedora Core 2 Kickstart config file used both.

Unfortunately, the Fedora Core 4 Anaconda bugs mean that the clearpart half of this is unusable. Our workaround destroys the MBR before Kickstart starts looking at the disk partitions, so the sequence we now have is:

  1. a %pre section that zaps out sector 0 on the first IDE and/or SATA disk. (Using tools mentioned in ModernDiskStoragePains to make sure that we're dealing with a SATA disk instead of a SCSI or a USB one).
  2. zerombr to tell Kickstart that it's OK to touch the disk with the invalid MBR.
  3. regular Kickstart partitioning.

Zeroing out sector 0 is done with a simple

dd if=/dev/zero of=<device> bs=512 count=1

I could avoid specifying zerombr at all if step #1 instead set up a valid but empty partition table, but that would take something more complicated than dd. Since Anaconda already has that code, I figure I'll let it do the work.

And that was my day (apart from the usual of being nibbled to death by moths, and some work on the USB memory stick version of the installer).

(Note: yes, I am sort of using Kickstart and Anaconda interchangeably in this entry. Yes, I know the difference.)

Sidebar: a heuristic for detecting SATA disks

It turns out that the kernel seems to name all of its SATA drivers things starting with sata_. So my disk clearing code works by getting the driver responsible for /dev/sda, if there is one, and clearing sector 0 only if the driver name starts with sata_. Fortunately this is dirt simple in Bourne shell code.

If we find a SATA chipset with a different driver name, I'll have to adjust the heuristic.

Updated: I had to add ata_piix to the list of SATA driver names, since it breaks the pattern of sata_ at the start. Whoops, as they say.

Written on 20 August 2005.
« The March of the Cheap
Mutating Referer Spammers »

Page tools: View Source, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Sat Aug 20 02:13:06 2005
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.