[Fedora-livecd-list] [PATCH] Make USB disk into full DVD installer
This patch allows livecd-iso-to-disk.sh to detect if the specified .iso image is an Anaconda DVD installer. If so, it copies it to the USB disk and configures syslinux to boot it. Anaconda will automatically find the DVD iso on the USB stick and install from it. Requires Fedora 11 Preview DVD iso and later. * This was tested to with Fedora 11 Preview DVD iso, without breaking standard LiveCD iso install. * Code is intentionally not "clean" in order to minimize the size of the git diff to make it easy to visually understand and confirm the changes. If this patch is acceptable, it will be followed by another patch that cleans up the code. Comments? Warren Togami wtog...@redhat.com diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh index 4effb3e..f2873f4 100755 --- a/tools/livecd-iso-to-disk.sh +++ b/tools/livecd-iso-to-disk.sh @@ -275,11 +275,25 @@ if [ $(id -u) != 0 ]; then exit 1 fi +detectisotype() { +if [ -e $CDMNT/LiveOS/squashfs.img ]; then +isotype=live +return +fi +if [ -e $CDMNT/images/install.img ]; then +isotype=installer +return +fi +echo "ERROR: $ISO does not appear to be a Live image or DVD installer." +exitclean +} + cryptedhome=1 keephome=1 homesizemb=0 swapsizemb=0 overlaysizemb=0 +isotype= LIVEOS=LiveOS HOMEFILE="home.img" @@ -436,6 +450,8 @@ mount $mountopts $USBDEV $USBMNT || exitclean trap exitclean SIGINT SIGTERM +detectisotype + if [ -f "$USBMNT/$LIVEOS/$HOMEFILE" -a -n "$keephome" -a "$homesizemb" -gt 0 ]; then echo "ERROR: Requested keeping existing /home and specified a size for /home" echo "Please either don't specify a size or specify --delete-home" @@ -476,6 +492,7 @@ if [ -n "$skipcompress" ]; then fi free=$(df -B1M $USBDEV |tail -n 1 |awk {'print $4;'}) +if [ "$isotype" = "live" ]; then if [ $(($overlaysizemb + $homesizemb + $livesize + $swapsizemb)) -gt $(($free + $tbd)) ]; then echo "Unable to fit live image + overlay on available space on USB stick" echo "Size of live image: $livesize" @@ -485,8 +502,29 @@ if [ $(($overlaysizemb + $homesizemb + $livesize + $swapsizemb)) -gt $(($free + echo "Available space: $(($free + $tbd))" exitclean fi +fi -if [ -z "$skipcopy" ];then +# Verify available space for DVD installer +if [ "$isotype" = "installer" ]; then + isosize=$(du -s -B 1M $ISO | awk {'print $1;'}) + installimgsize=$(du -s -B 1M $CDMNT/images/install.img | awk {'print $1;'}) + tbd=0 + if [ -e $USBMNT/images/install.img ]; then +tbd=$(du -s -B 1M $USBMNT/images/install.img | awk {'print $1;'}) + fi + if [ -e $USBMNT/$(basename $ISO) ]; then +tbd=$(($tbd + $(du -s -B 1M $USBMNT/$(basename $ISO) | awk {'print $1;'}))) + fi + echo "Size of DVD image: $isosize" + echo "Size of install.img: $installimgsize" + echo "Available space: $(($free + $tbd))" + if [ $(($isosize + $installimgsize)) -gt $(($free + $tbd)) ]; then +echo "ERROR: Unable to fit DVD image + install.img on available space on USB stick" +exitclean + fi +fi + +if [ -z "$skipcopy" ] && [ "$isotype" = "live" ];then if [ -d $USBMNT/$LIVEOS -a -z "$force" ]; then echo "Already set up as live image." if [ -z "$keephome" -a -e $USBMNT/$LIVEOS/$HOMEFILE ]; then @@ -508,7 +546,8 @@ fi [ ! -d $USBMNT/$SYSLINUXPATH ] && mkdir -p $USBMNT/$SYSLINUXPATH [ -n "$efi" -a ! -d $USBMNT/EFI/boot ] && mkdir -p $USBMNT/EFI/boot -if [ -z "$skipcopy" ];then +# Live image copy +if [ "$isotype" = "live" ] && [ -z "$skipcopy" ];then echo "Copying live image to USB stick" [ ! -d $USBMNT/$LIVEOS ] && mkdir $USBMNT/$LIVEOS [ -n "$keephome" -a -f "$USBMNT/$HOMEFILE" ] && mv $USBMNT/$HOMEFILE $USBMNT/$LIVEOS/$HOMEFILE @@ -526,6 +565,14 @@ if [ -z "$skipcopy" ];then fi fi +# DVD installer copy +if [ "$isotype" = "installer" ] && [ -z "$skipcopy" ]; then + echo "Copying DVD image to USB stick" + mkdir -p $USBMNT/images/ + cp $CDMNT/images/install.img $USBMNT/images/install.img || exitclean + cp $ISO $USBMNT/ +fi + cp $CDMNT/isolinux/* $USBMNT/$SYSLINUXPATH BOOTCONFIG=$USBMNT/$SYSLINUXPATH/isolinux.cfg # Set this to nothing so sed doesn't care @@ -543,6 +590,10 @@ echo "Updating boot config file" sed -i -e "s/CDLABEL=[^ ]*/$USBLABEL/" -e "s/rootfstype=[^ ]*/rootfstype=$USBFS/" $BOOTCONFIG $BOOTCONFIG_EFI if [ -n "$kernelargs" ]; then sed -i -e "s/liveimg/liveimg ${kernelargs}/" $BOOTCONFIG $BOOTCONFIG_EFI ; fi if [ "$LIVEOS" != "LiveOS" ]; then sed -i -e "s;liveimg;liveimg live_dir=$LIVEOS;" $BOOTCONFIG $BOOTCONFIG_EFI ; fi +# DVD Installer +if [ "$isotype" = "installer" ]; then + sed -i -e "s;initrd=initrd.img;initrd=initrd.img repo=hd:$USBLABEL:/;g" $BOOTCONFIG $BOOTCONFIG_EFI +fi if [ "$overlaysizemb" -gt 0 ]; then echo "Initializing persistent overlay file" -- Fedora-livecd-list mailing list Fedora-livecd-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-livecd-list
Re: [Fedora-livecd-list] [PATCH] Make USB disk into full DVD installer
On Wed, Apr 29, 2009 at 4:47 AM, Warren Togami wrote: > > This patch allows livecd-iso-to-disk.sh to detect if the specified .iso > image is an Anaconda DVD installer. If so, it copies it to the USB disk and > configures syslinux to boot it. Anaconda will automatically find the DVD > iso on the USB stick and install from it. > > Requires Fedora 11 Preview DVD iso and later. > > Wouldn't Anaconda project be a better place for this functionality? I think it's confusing to run *livecd*-iso-to-disk against non-livecd iso :) -- Fedora-livecd-list mailing list Fedora-livecd-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-livecd-list
Re: [Fedora-livecd-list] [PATCH] Make USB disk into full DVD installer
Alan Pevec wrote: > On Wed, Apr 29, 2009 at 4:47 AM, Warren Togami wrote: > >> >> This patch allows livecd-iso-to-disk.sh to detect if the specified .iso >> image is an Anaconda DVD installer. If so, it copies it to the USB disk and >> configures syslinux to boot it. Anaconda will automatically find the DVD >> iso on the USB stick and install from it. >> >> Requires Fedora 11 Preview DVD iso and later. >> >> > > Wouldn't Anaconda project be a better place for this functionality? I think > it's confusing to run *livecd*-iso-to-disk against non-livecd iso :) Interesting question, I wish I read this before posting above about livecd-to-pxeboot. What I would like to do is use livecd-to-pxeboot script to set up pxe trees from a non-live-iso. Although these tools are designed for livecd's I can see other uses outside of this scenario. It may be nice to even split the package up further, like they did with imgcreate, for generic livecd-tools-iso-utils %files iso-utils %{_bindir}/livecd-iso-to-disk %{_bindir}/livecd-iso-to-pxeboot comments -D -- Fedora-livecd-list mailing list Fedora-livecd-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-livecd-list
Re: [Fedora-livecd-list] [PATCH] Make USB disk into full DVD installer
On Tuesday, April 28 2009, Warren Togami said: > This patch allows livecd-iso-to-disk.sh to detect if the specified .iso > image is an Anaconda DVD installer. If so, it copies it to the USB disk > and configures syslinux to boot it. Anaconda will automatically find > the DVD iso on the USB stick and install from it. > > Requires Fedora 11 Preview DVD iso and later. So I've been thinking about this all day and I really don't know that it makes sense. The script is explicitly for *live* images (it's in the name! :-) and making it support more than that is just going to complicate things. What happens when someone then wants it to support Ubuntu images or something else? Also, I'm hoping to stop adding functionality to the shell script at some point as liveusb-creator really should be preferred for most cases, although it's command line mode needs some work Jeremy -- Fedora-livecd-list mailing list Fedora-livecd-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-livecd-list
Re: [Fedora-livecd-list] [PATCH] Make USB disk into full DVD installer
On 04/29/2009 10:15 PM, Jeremy Katz wrote: On Tuesday, April 28 2009, Warren Togami said: This patch allows livecd-iso-to-disk.sh to detect if the specified .iso image is an Anaconda DVD installer. If so, it copies it to the USB disk and configures syslinux to boot it. Anaconda will automatically find the DVD iso on the USB stick and install from it. Requires Fedora 11 Preview DVD iso and later. So I've been thinking about this all day and I really don't know that it makes sense. The script is explicitly for *live* images (it's in the name! :-) and making it support more than that is just going to complicate things. What happens when someone then wants it to support Ubuntu images or something else? Also, I'm hoping to stop adding functionality to the shell script at some point as liveusb-creator really should be preferred for most cases, although it's command line mode needs some work liveusb-creator has live in its name too! OK, I'll write a separate script dedicated to this and a patch for liveusb-creator too. Warren Togami wtog...@redhat.com -- Fedora-livecd-list mailing list Fedora-livecd-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-livecd-list
Re: [Fedora-livecd-list] [PATCH] Make USB disk into full DVD installer
On Wednesday, April 29 2009, Warren Togami said: > On 04/29/2009 10:15 PM, Jeremy Katz wrote: >> On Tuesday, April 28 2009, Warren Togami said: >>> This patch allows livecd-iso-to-disk.sh to detect if the specified .iso >>> image is an Anaconda DVD installer. If so, it copies it to the USB disk >>> and configures syslinux to boot it. Anaconda will automatically find >>> the DVD iso on the USB stick and install from it. >>> >>> Requires Fedora 11 Preview DVD iso and later. >> >> So I've been thinking about this all day and I really don't know that it >> makes sense. The script is explicitly for *live* images (it's in the >> name! :-) and making it support more than that is just going to >> complicate things. What happens when someone then wants it to support >> Ubuntu images or something else? >> >> Also, I'm hoping to stop adding functionality to the shell script at >> some point as liveusb-creator really should be preferred for most cases, >> although it's command line mode needs some work > > liveusb-creator has live in its name too! Yes, but at least it's written in python so that things can be abstracted nicely rather than the horrors of shell :-) At which point, maybe it should have a rename. But I'll leave that for Luke ;-) Jeremy -- Fedora-livecd-list mailing list Fedora-livecd-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-livecd-list
Re: [Fedora-livecd-list] [PATCH] Make USB disk into full DVD installer
On 04/29/2009 11:03 PM, Jeremy Katz wrote: Yes, but at least it's written in python so that things can be abstracted nicely rather than the horrors of shell :-) At which point, maybe it should have a rename. But I'll leave that for Luke ;-) Jeremy Would you accept a patch for livecd-iso-to-disk.sh that detects if the ISO is an anaconda installer and prints a helpful message? Otherwise it appears to succeed like it does now, while being not useful. Warren -- Fedora-livecd-list mailing list Fedora-livecd-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-livecd-list
Re: [Fedora-livecd-list] [PATCH] Make USB disk into full DVD installer
On Thursday, April 30 2009, Warren Togami said: > On 04/29/2009 11:03 PM, Jeremy Katz wrote: >> Yes, but at least it's written in python so that things can be >> abstracted nicely rather than the horrors of shell :-) At which point, >> maybe it should have a rename. But I'll leave that for Luke ;-) > > Would you accept a patch for livecd-iso-to-disk.sh that detects if the > ISO is an anaconda installer and prints a helpful message? Otherwise it > appears to succeed like it does now, while being not useful. Better to check that the image is "supported" (ie, is a live image) rather than the converse. But then I'd be okay with it Jeremy -- Fedora-livecd-list mailing list Fedora-livecd-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-livecd-list