2014-02-20 16:21:27 +00:00
|
|
|
#!/bin/sh
|
2013-09-16 11:23:55 +00:00
|
|
|
#
|
|
|
|
# Ensure you've loaded the loop module with max_part=15
|
|
|
|
|
2014-02-27 12:41:37 +00:00
|
|
|
if test "$2" = ""; then
|
|
|
|
echo "Usage: $0 <rootdir> <imgfile>"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
root=$1
|
|
|
|
img=$2
|
2013-09-20 10:20:41 +00:00
|
|
|
|
2014-02-27 12:41:37 +00:00
|
|
|
set -e -x
|
2013-09-17 18:04:01 +00:00
|
|
|
|
2014-02-19 19:08:21 +00:00
|
|
|
dd if=/dev/zero of=$img bs=512M count=8
|
2014-02-20 16:21:27 +00:00
|
|
|
(
|
|
|
|
cat << EOF
|
2013-09-16 11:23:55 +00:00
|
|
|
o
|
|
|
|
n
|
|
|
|
p
|
|
|
|
1
|
|
|
|
|
|
|
|
|
|
|
|
a
|
2013-09-16 17:52:05 +00:00
|
|
|
1
|
2014-02-20 16:21:27 +00:00
|
|
|
w
|
|
|
|
EOF
|
|
|
|
) | fdisk $img
|
2013-09-16 11:23:55 +00:00
|
|
|
|
2013-09-17 18:04:01 +00:00
|
|
|
lodev=$(losetup -f --show $img) || exit 1
|
2013-09-16 11:23:55 +00:00
|
|
|
partition="$lodev"p1
|
2013-09-16 18:24:04 +00:00
|
|
|
mkfs.ext2 -L MORPHEUS $partition || exit 1
|
2013-09-16 11:23:55 +00:00
|
|
|
mount $partition /mnt || exit 1
|
2013-09-17 13:19:04 +00:00
|
|
|
rmdir /mnt/lost+found
|
2013-09-16 11:23:55 +00:00
|
|
|
|
2014-02-20 16:29:21 +00:00
|
|
|
fakeroot cp -arP "$root"/* /mnt
|
2013-09-16 12:53:55 +00:00
|
|
|
extlinux --install /mnt/boot || exit 1
|
2013-09-16 11:23:55 +00:00
|
|
|
|
2013-09-16 18:43:29 +00:00
|
|
|
dd if=stuff/mbr.bin of=$lodev conv=notrunc bs=440 count=1
|
2013-09-16 12:58:37 +00:00
|
|
|
sync
|
2013-09-16 11:23:55 +00:00
|
|
|
|
|
|
|
umount /mnt
|
|
|
|
sleep 3
|
|
|
|
losetup -d $lodev
|