Author: alexander
Date: 2007-07-08 01:37:15 -0600 (Sun, 08 Jul 2007)
New Revision: 1950
Modified:
trunk/packages/initramfs/Makefile
trunk/packages/initramfs/init.in
trunk/scripts/shutdown-helper
Log:
Made it possible to store the LiveCD ISO file on a partition and boot it.
Modified: trunk/packages/initramfs/Makefile
===================================================================
--- trunk/packages/initramfs/Makefile 2007-07-06 16:52:21 UTC (rev 1949)
+++ trunk/packages/initramfs/Makefile 2007-07-08 07:37:15 UTC (rev 1950)
@@ -41,7 +41,7 @@
cp /usr/bin/stat $(WDIR)/bin
cp /usr/sbin/dmsetup $(WDIR)/sbin
find
/lib/modules/*/kernel/drivers/{ata,base,block,cdrom,ide,message,scsi,pcmcia,usb/{core,host,storage,input}}
\
-
/lib/modules/*/kernel/fs/{mbcache.ko,ext2,ext3,ext4,reiserfs,xfs,fat,vfat,ntfs,isofs,udf,nls}
\
+
/lib/modules/*/kernel/fs/{mbcache.ko,ext2,ext3,ext4,jbd,reiserfs,xfs,fat,vfat,ntfs,isofs,udf,nls}
\
/lib/modules/*/kernel/lib -type f | cpio --make-directories -p
$(WDIR)
for a in /lib/modules/* ; do ver=$${a##*/} ; depmod -b $(WDIR) $$ver ;
done
cd $(WDIR); find . | cpio -o -H newc | gzip -9 >
../initramfs_data.cpio.gz
Modified: trunk/packages/initramfs/init.in
===================================================================
--- trunk/packages/initramfs/init.in 2007-07-06 16:52:21 UTC (rev 1949)
+++ trunk/packages/initramfs/init.in 2007-07-08 07:37:15 UTC (rev 1950)
@@ -8,7 +8,7 @@
init=/sbin/init
root=
rootdelay=
-rootfstype=ext3,ext2,auto
+rootfstype=auto
ro="ro"
noresume=0
resume=
@@ -80,6 +80,10 @@
bs=1 count=1 skip=8 seek=47482 conv=notrunc 2>/dev/null
umount -n /.tmpfs/.cdrom
/sbin/losetup /dev/loop2 /.tmpfs/.fakecd.iso
+ if [ -d /.tmpfs/.partition ] ; then
+ /sbin/losetup -d /dev/loop3
+ umount -n /.tmpfs/.partition && rm -rf /.tmpfs/.partition
+ fi
ln -sf /dev/loop2 /dev/lfs-cd
}
@@ -97,7 +101,6 @@
umount -n /.tmpfs/.cdrom
}
-
do_mount_cd() {
i=1
while [ ! -L /dev/lfs-cd ] ; do
@@ -134,8 +137,6 @@
sh
fi
done
- mkdir /.tmpfs
- mount -n -t tmpfs -o size=90% tmpfs /.tmpfs
mkdir /.tmpfs/.cdrom
detect_cd_type
if [ "$toram" = 1 ] ; then copy_cd_to_ram ; fi
@@ -149,8 +150,10 @@
echo "0 $SIZE snapshot /dev/loop0 /dev/loop1 p 8" | /sbin/dmsetup
create lfs-cd
mount -n -t ext2 /dev/mapper/lfs-cd /.root
mount -n --move /.tmpfs /.root/dev/shm
+ if [ "$toram" != 1 ] && [ ! -d /.root/dev/shm/.partition ] ; then
+ cp -a /dev/lfs-cd /.root/dev/lfs-cd
+ fi
if [ "$toram" != 1 ] ; then
- cp -a /dev/lfs-cd /.root/dev/lfs-cd
ln -sf /dev/shm/.cdrom/drivers /.root/drivers
fi
cat /etc/modprobe.conf >>/.root/etc/modprobe.conf
@@ -163,11 +166,27 @@
fi
}
+do_mount_iso() {
+ DEVICE=${root#iso:}
+ FILE=${DEVICE#*:}
+ DEVICE=${DEVICE%%:*}
+ mkdir /.tmpfs/.partition
+ mount -n -t "$rootfstype" -o "$rootflags" "$DEVICE" /.tmpfs/.partition
+ /sbin/losetup /dev/loop3 "/.tmpfs/.partition/$FILE"
+ ln -sf /dev/loop3 /dev/lfs-cd
+ do_mount_cd
+}
+
do_mount_root() {
mkdir /.root
[ -n "$rootflags" ] && rootflags="$rootflags,"
rootflags="$rootflags$ro"
case "$root" in
+ iso:*)
+ mkdir /.tmpfs
+ mount -n -t tmpfs -o size=90% tmpfs /.tmpfs
+ do_mount_iso
+ ;;
*:*)
( IFS=":" ; mknod /dev/root b $root )
mount -n -t "$rootfstype" -o "$rootflags" /dev/root /.root
@@ -176,6 +195,8 @@
mount -n -t "$rootfstype" -o "$rootflags" "$root" /.root
;;
"")
+ mkdir /.tmpfs
+ mount -n -t tmpfs -o size=90% tmpfs /.tmpfs
do_mount_cd
;;
esac
Modified: trunk/scripts/shutdown-helper
===================================================================
--- trunk/scripts/shutdown-helper 2007-07-06 16:52:21 UTC (rev 1949)
+++ trunk/scripts/shutdown-helper 2007-07-08 07:37:15 UTC (rev 1950)
@@ -23,8 +23,8 @@
/lib/libpthread.so.0
/dev/console
/dev/null
-/dev/lfs-cd
/dev/loop0
+/dev/loop3
/dev/mapper/control"
case "$RUNLEVEL" in
@@ -36,7 +36,7 @@
;;
esac
-if [ ! -b /dev/lfs-cd ] ; then
+if [ ! -b /dev/lfs-cd ] && [ ! -d /.tmpfs/.partition ] ; then
# The CD has been loaded into RAM
$HALT
while true ; do sleep 1 ; done
@@ -45,6 +45,8 @@
mkdir /dev/shm/old /dev/shm/proc /dev/shm/etc
ln -s /proc/mounts /dev/shm/etc/mtab
echo "$FILES" | cpio -pLd --quiet /dev/shm
+if [ -b /dev/lfs-cd ] ; then cp -a /dev/lfs-cd /dev/shm/dev/lfs-cd ; fi
+
cat >/dev/shm/sbin/init <<EOF
#!/bin/sh
@@ -66,13 +68,22 @@
TIMEOUT=".\$TIMEOUT"
done
[ "\$TIMEOUT" = "....." ] && fail
+
dmsetup remove_all || fail
losetup -d /dev/loop0 || fail
umount -n /.cdrom || fail
-eject -r /dev/lfs-cd
-echo -n "Take the CD, close the CD-ROM tray and press Enter..."
-( sleep 30 ; halt ) &
-read ENTER
+
+if [ -d /.partition ] ; then
+ losetup -d /dev/loop3 || fail
+ umount -n /.partition || fail
+fi
+
+if [ -b /dev/lfs-cd ] ; then
+ eject -r /dev/lfs-cd
+ echo -n "Take the CD, close the CD-ROM tray and press Enter..."
+ ( sleep 30 ; halt ) &
+ read ENTER
+fi
halt
EOF
chmod 755 /dev/shm/sbin/init
--
http://linuxfromscratch.org/mailman/listinfo/livecd
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page