[Fedora-livecd-list] tools/livecd-iso-to-disk.sh

Jeremy Katz katzj at fedoraproject.org
Fri Apr 18 20:14:11 UTC 2008


 tools/livecd-iso-to-disk.sh |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

New commits:
commit f9e5856f2b30b5c7e70dbc5bdf8ebaf254e911fb
Author: Jeremy Katz <katzj at redhat.com>
Date:   Fri Apr 18 15:53:21 2008 -0400

    Check the available space on the stick (#443046)
    
    To avoid corrupting filesystems, we need to check the available space
    first.  This may end up being off by a little bit, but it will be so by
    overestimating the amount of space needed so should be fine

diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index cc94397..030753a 100644
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -212,6 +212,28 @@ mount $USBDEV $USBMNT || exitclean
 
 trap exitclean SIGINT SIGTERM
 
+# let's try to make sure there's enough room on the stick
+if [ -d $CDMNT/LiveOS ]; then
+  check=$CDMNT/LiveOS
+else
+  check=$CDMNT
+fi
+if [ -d $USBMNT/LiveOS ]; then
+  tbd=$(du -s -B 1M $USBMNT/LiveOS | awk {'print $1;'})
+else
+  tbd=0
+fi
+livesize=$(du -s -B 1M $check | awk {'print $1;'})
+free=$(df  -B1M $USBDEV  |tail -n 1 |awk {'print $4;'})
+
+if [ $(($overlaysizemb + $livesize)) -gt $(($free + $tbd)) ]; then
+  echo "Unable to fit live image + overlay on available space on USB stick"
+  echo "Size of live image: $livesize"
+  echo "Overlay size: $overlaysizemb"
+  echo "Available space: $(($free + $tbd))"
+  exitclean
+fi
+
 if [ -d $USBMNT/LiveOS ]; then
     echo "Already set up as live image.  Deleting old in fifteen seconds..."
     sleep 15





More information about the Fedora-livecd-list mailing list