morpheus/stuff/create-bootable

56 lines
658 B
Plaintext
Raw Permalink Normal View History

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
usage() {
2014-02-27 12:41:37 +00:00
echo "Usage: $0 <rootdir> <imgfile>"
exit
}
if test "$1" = ""; then
usage
fi
if test "$2" = ""; then
usage
2014-02-27 12:41:37 +00:00
fi
2014-03-06 10:26:54 +00:00
set -e -x
2014-02-27 12:41:37 +00:00
root=$1
img=$2
mnt="/mnt/morpheus"
2013-09-20 10:20:41 +00:00
fallocate -l 2G $img || dd if=/dev/zero of=$img bs=512M count=4
2014-02-20 16:21:27 +00:00
(
cat << EOF
2013-09-16 11:23:55 +00:00
o
n
p
1
a
1
2014-02-20 16:21:27 +00:00
w
EOF
) | fdisk $img
2013-09-16 11:23:55 +00:00
lodev=$(losetup -f)
losetup "$lodev" "$img"
2013-09-16 11:23:55 +00:00
partition="$lodev"p1
mkfs.ext4 -L MORPHEUS $partition
mkdir -p "$mnt"
mount $partition "$mnt"
rmdir "$mnt/lost+found"
2013-09-16 11:23:55 +00:00
fakeroot cp -arP "$root"/* "$mnt"
extlinux --install "$mnt/boot"
2013-09-16 11:23:55 +00:00
2014-03-25 14:26:33 +00:00
cat stuff/mbr.bin > $lodev
2013-09-16 12:58:37 +00:00
sync
2013-09-16 11:23:55 +00:00
umount "$mnt"
2013-09-16 11:23:55 +00:00
sleep 3
losetup -d $lodev