Quantcast
Channel: TechCenter
Viewing all articles
Browse latest Browse all 2350

Hacking Fedora install ISOs

$
0
0
Revision 2 posted to OS and Applications - Wiki by D. Jared Dominguez on 11/27/2012 4:33:38 PM

Hacking Fedora install ISOs

install, operating system, red hat, deployment, Linux Distributions, Red Hat Linux Distribution, Dell PowerEdge Linux, linux dell, linux projects, KVM, developers

While working on testing some minor installer changes, I found myself wanting a simple way to modify the Fedora install media without having to rebuild the install ISO from scratch each time. I found some guides for doing this on older versions of Fedora and on live ISOs, but none really worked for the way that Fedora now handles the installer's root filesystem. Hopefully this quick script will help save someone else some time. It's likely also useful for some deployment scenarios, but I recommend trying other deployment methods first. :-)

Of course, upon final testing, rebuilding the install media from scratch is a good final sanity check, but this quick hack really saves some time during development under certain circumstances. Instead of taking hours to regenerate an install ISO, this takes me a few minutes. My development environment involves VMs and some fairly small changes to my ISO, so I have not tested whether this maintains all the booting features of a pristine Fedora install ISO, including EFI booting and hybrid ISO functionality (for booting from a USB stick). Modifications to improve the usefulness of this wiki entry are welcome. GeneralizingthisscripttoinstallmediaforotherLinuxdistributionswouldbeniceaswell.

#!/bin/bash
set -e
set -x

### This lets you modify a Fedora installer ISO for testing without having to
### build it from scratch. Make sure you're running the same kernel version as
### the installer uses if changes affect the initrd. You'll need to run some
### of these steps as root. We just do it all as root since we are running
### everything on an ad hoc dev vm.

##############################################################################
### variables to customize
##############################################################################

ISO=original.iso
version=beta
TMPDIR=~/$version/tmp
CHANGES_DIR=~/$version/changes
NEWISO_NAME=new.iso

##############################################################################





##############################################################################
### setup all mount points and working directories
##############################################################################

## mount the media and root squashfs
ISO=`readlink -n -f ${ISO}`
ISO_MNT=$TMPDIR/media/isofs/
SQUASH_MNT=$TMPDIR/media/squashfs/
mkdir -p $ISO_MNT $SQUASH_MNT
mount -o loop,ro -t iso9660 $ISO $ISO_MNT
mount -o loop -t squashfs $ISO_MNT/LiveOS/squashfs.img $SQUASH_MNT

## copy over the ISO and rootfs contents so we can modify them in the next step
NEWISO_DIR=$TMPDIR/new/isodir
NEWSQUASH_DIR=$TMPDIR/new/squashdir
mkdir -p $NEWISO_DIR $NEWSQUASH_DIR
rsync --exclude=/LiveOS/squashfs.img -a $ISO_MNT $NEWISO_DIR
rsync -a $SQUASH_MNT $NEWSQUASH_DIR
umount $SQUASH_MNT $ISO_MNT
rmdir $SQUASH_MNT $ISO_MNT

## mount the rootfs and tweak it
NEWROOTFS_MNT=$TMPDIR/new/rootfs
mkdir $NEWROOTFS_MNT
mount -o loop -t ext4 $NEWSQUASH_DIR/LiveOS/rootfs.img $NEWROOTFS_MNT

##############################################################################





##############################################################################
### YOUR CHANGES HERE:
##############################################################################
## Vars you most care about are $CHANGES_DIR, $NEWROOTFS_MNT and $NEWISO_DIR

#cp -a $CHANGES_DIR/sbin/* $NEWROOTFS_MNT/

##############################################################################





##############################################################################
### finish up and write ISO
##############################################################################

## unmount the tweaked rootfs and dump it into a new squashfs
umount $NEWROOTFS_MNT
mksquashfs $NEWSQUASH_DIR $NEWISO_DIR/LiveOS/squashfs.img -comp xz

## if we need to regenerate the initrd, we'd want something like this. make
## sure you're running the same kernel version as the installer uses:
# dracut $NEWISO_DIR/isolinux/initrd.img $(uname -r)


## we're done. just regenerate the ISO
cd $NEWISO_DIR
VOLUME_ID=`isoinfo -d -i $ISO | grep "Volume id" | awk -F ": " '{print $2 }'`
mkisofs -quiet -J -r -hide-rr-moved -hide-joliet-trans-tbl -V "${VOLUME_ID}" \
-o $TMPDIR/$NEWISO_NAME -b isolinux/isolinux.bin -c isolinux/boot.cat \
-no-emul-boot -boot-info-table -boot-load-size 4 $NEWISO_DIR

##############################################################################

Viewing all articles
Browse latest Browse all 2350


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>