123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- #!/bin/sh
- PWD="`pwd`"
- SOURCE_TREE="$PWD/initrd-tree"
- OUTPUT_IMAGE="$PWD/initrd.gz"
- KERNEL_VERSION="$(uname -r)"
- PUPPYVERSION="`cat $SOURCE_TREE/PUPPYVERSION`"
- SIZE=`du -s -k $SOURCE_TREE | tr "\t" " " | cut -f 1 -d ' '`
- PAD=900
- TRIMOFF=800
- if [ -f $SOURCE_TREE/pup_$PUPPYVERSION.sfs ];then
-
- PAD=3100
- TRIMOFF=0
- fi
- SIZE=`expr $SIZE + $PAD`
- TMPSIZE=`expr $SIZE \* 3`
- mkdir /tmp/tmpfs
- mount tmpfs /tmp/tmpfs -t tmpfs -o size=${TMPSIZE}k
- mkdir /tmp/tmpfs/mntpt
- echo "Size of ext2 filesystem is ${SIZE}KB"
- dd if=/dev/zero of=/tmp/tmpfs/initrd-tmp bs=1k count=$SIZE
- sync
- mke2fs -m 0 -F /tmp/tmpfs/initrd-tmp
- sync
- tune2fs -c 0 -i 0 -m 0 /tmp/tmpfs/initrd-tmp
- sync
- losetup /dev/loop2 /tmp/tmpfs/initrd-tmp
- mount -t ext2 /dev/loop2 /tmp/tmpfs/mntpt
-
- ( cd $SOURCE_TREE
- cp -a * /tmp/tmpfs/mntpt
- )
-
- rm -f /tmp/tmpfs/mntpt/init
- ln -s sbin/init /tmp/tmpfs/mntpt/linuxrc
- if [ -d /tmp/tmpfs/mntpt/dev0 ];then
- rmdir /tmp/tmpfs/mntpt/dev
- mv /tmp/tmpfs/mntpt/dev0 /tmp/tmpfs/mntpt/dev
- fi
-
-
-
-
-
-
-
-
-
-
-
- sync
- umount /dev/loop2
- rmdir /tmp/tmpfs/mntpt
-
-
-
- sync
- rm -f initrd
- rm -f initrd.gz
- DOWNSIZE=`expr $SIZE \- $TRIMOFF`
- sync
- resize2fs -pf /tmp/tmpfs/initrd-tmp $DOWNSIZE
- sync
- dd if=/tmp/tmpfs/initrd-tmp of=initrd bs=1k count=$DOWNSIZE
- sync
- e2fsck -y -f initrd
- sync
- rm -f /tmp/tmpfs/initrd-tmp
- gzip -9 initrd
- sync
- umount /tmp/tmpfs
- rmdir /tmp/tmpfs
- echo -n "$SIZE" > /tmp/initrdsize.txt
- sync
|