[Fedora-livecd-list] Custom initrd

Mads Kiilerich mads at kiilerich.com
Sat Aug 15 09:17:54 UTC 2009


Jeremy Katz wrote, On 08/15/2009 04:45 AM:
> On Saturday, August 15 2009, Mads Kiilerich said:
>    
>> I have figured out that livecd-creator through imgcreate creates a
>> /etc/sysconfig/mkinitrd. When rpms runs mkinitrd from their %post script
>> then it will exec mkliveinitrd and use the configured module list.
>> AFAICS livecd-creator then picks up the initrd from /boot, and the end
>> result after having written the iso to usb with livecd-iso-to-disk is
>> that it ends up in /syslinux/initrd0.img.
>>      
> Correct
>
>    
>> But if I overwrite the /boot/initrd* in %post like this:
>>      /sbin/mkinitrd -f /boot/initrd-$(rpm -q kernel --qf
>> '%{version}-%{release}.%{arch}\n').img $(rpm -q kernel --qf
>> '%{version}-%{release}.%{arch}\n')
>> then it won't be used.
>>
>> What am I doing wrong? When is the initrd picked up? What is the code flow?
>>      
> %post runs after we've set up the boot loader bits.  Otherwise, it
> %wouldn't be the last thing run.

I intuitively expected %post to be the last step in the kickstart 
process, but to come before the "taking a snapshot of the chroot and 
transforming it to something bootable" part. But no one size fits all. 
Ok. Perhaps different %posts could make some things simpler.

> So if you want to do this, you have to
> do something like we did for Fedora 8 on the initial move of initramfs
> stuff into mkinitrd proper.  See commit
> 11dbd0bb5ba4b845e80109e990e4e780ca402218
>    

Oh yeah. livecd-creator thinks (knows) that it is creating a CD, and 
thus the initrd is (has to be) in $LIVE_ROOT/isolinux/initrd0.img.

So
     /sbin/mkinitrd -f $LIVE_ROOT/isolinux/initrd0.img $(rpm -q kernel 
--qf "%{version}-%{release}.%{arch}")
in %post should do the trick? I will try that.

I tried and was looking for $LIVE_ROOT/syslinux/initrd0.img as it can be 
seen on running USB sticks, but that mangling is only done later by 
livecd-iso-to-disk ...

I have had some problems with things copied to $LIVE_ROOT in nonchrooted 
%post not showing up on the final system, but that might be 
livecd-iso-to-disk too - I will try harder.

Thanks!

/Mads




More information about the Fedora-livecd-list mailing list