From 2bd2e11e5aa7f9441dcff5b62d26722391d9c8e0 Mon Sep 17 00:00:00 2001 From: Oliver Grawert Date: Wed, 21 Jul 2010 15:14:52 +0200 Subject: [PATCH] switch ext2 image creation to use loop mounting instead of genext2fs --- debian/changelog | 7 ++++++- debian/control | 2 +- livecd.sh | 19 ++++++++++++++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/debian/changelog b/debian/changelog index cc08038a..b2d58e02 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,13 @@ livecd-rootfs (1.139) UNRELEASED; urgency=low + [ Steve Langasek ] * One more undefined variable fix for set -u - -- Steve Langasek Wed, 21 Jul 2010 11:10:44 +0200 + [ Oliver Grawert ] + * drop genext2fs, it is simply to slow, instead we use a loop munted ext2 + image now. + + -- Oliver Grawert Wed, 21 Jul 2010 15:12:18 +0200 livecd-rootfs (1.138) maverick; urgency=low diff --git a/debian/control b/debian/control index 31e54293..d0d15536 100644 --- a/debian/control +++ b/debian/control @@ -8,7 +8,7 @@ Vcs-Bzr: http://bazaar.launchpad.net/~ubuntu-core-dev/livecd-rootfs/trunk Package: livecd-rootfs Architecture: all -Depends: ${misc:Depends}, debootstrap, rsync, python-minimal | python, procps, squashfs-tools (>= 1:3.3-1), grep-dctrl, fdupes, lsb-release, lzma, genext2fs +Depends: ${misc:Depends}, debootstrap, rsync, python-minimal | python, procps, squashfs-tools (>= 1:3.3-1), grep-dctrl, fdupes, lsb-release, lzma, e2fsprogs Suggests: partimage Description: construction script for the livecd rootfs livecd-rootfs provides the script used to create the root filesystem diff --git a/livecd.sh b/livecd.sh index 8ac76506..0ac3084b 100755 --- a/livecd.sh +++ b/livecd.sh @@ -21,7 +21,7 @@ set -eu # Boston, MA 02110-1301 USA. # ########################################################################## -# Depends: debootstrap, rsync, python-minimal|python, procps, squashfs-tools, ltsp-server [i386], genext2fs +# Depends: debootstrap, rsync, python-minimal|python, procps, squashfs-tools, ltsp-server [i386], e2fsprogs cleanup() { for mnt in ${ROOT}dev/pts ${ROOT}dev/shm ${ROOT}.dev ${ROOT}dev \ @@ -30,7 +30,7 @@ cleanup() { umount $mnt || true done - [ -n "$DEV" ] && losetup -d $DEV || true + [ -n "$DEV" ] && umount $DEV && losetup -d $DEV || true grep ${ROOT} /proc/mounts && return 1 || return 0 } @@ -78,12 +78,25 @@ livefs_ext2() { # Add 10MiB extra free space for first boot + ext3 journal size=$(($(du -ks ${ROOT} | cut -f1) + (10240))) + MOUNTPOINT=$(mktemp -d) + DEV=$(losetup -f) echo "Building ext2 filesystem." # remove any stale filesystem images rm -f livecd.${FSS}.ext? - genext2fs -b $size -d ${ROOT} livecd.${FSS}.ext2 + # create an empty ext2 image and loop mount it + dd if=/dev/zero of=livecd.${FSS}.ext2 bs=1024 count=0 seek=$size + mke2fs livecd.${FSS}.ext2 + mount -o loop=${DEV} livecd.${FSS}.ext2 ${MOUNTPOINT} + + # copy chroot content to image + cp -a ${ROOT} ${MOUNTPOINT} + + # clean up + umount ${MOUNTPOINT} + rm -rf ${MOUNTPOINT} + losetup -d $DEV chmod 644 livecd.${FSS}.ext2 }