== Disk setup in our Fedora Core 4 Kickstart environment 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|FC4BuggyAnaconda]] 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: # 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). # _zerombr_ to tell Kickstart that it's OK to touch the disk with the invalid MBR. # regular Kickstart partitioning. Zeroing out sector 0 is done with a simple > dd if=/dev/zero of= 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.