morpheus

suckless linux distro
git clone git://git.2f30.org/morpheus.git
Log | Files | Refs | Submodules | README | LICENSE

create-bootable (658B)


      1 #!/bin/sh
      2 #
      3 # Ensure you've loaded the loop module with max_part=15
      4 
      5 usage() {
      6 	echo "Usage: $0 <rootdir> <imgfile>"
      7 	exit
      8 }
      9 
     10 if test "$1" = ""; then
     11 	usage
     12 fi
     13 
     14 if test "$2" = ""; then
     15 	usage
     16 fi
     17 
     18 set -e -x
     19 
     20 root=$1
     21 img=$2
     22 mnt="/mnt/morpheus"
     23 
     24 fallocate -l 2G $img || dd if=/dev/zero of=$img bs=512M count=4
     25 (
     26 cat << EOF
     27 o
     28 n
     29 p
     30 1
     31 
     32 
     33 a
     34 1
     35 w
     36 EOF
     37 ) | fdisk $img
     38 
     39 lodev=$(losetup -f)
     40 losetup "$lodev" "$img"
     41 partition="$lodev"p1
     42 mkfs.ext4 -L MORPHEUS $partition
     43 mkdir -p "$mnt"
     44 mount $partition "$mnt"
     45 rmdir "$mnt/lost+found"
     46 
     47 fakeroot cp -arP "$root"/* "$mnt"
     48 extlinux --install "$mnt/boot"
     49 
     50 cat stuff/mbr.bin > $lodev
     51 sync
     52 
     53 umount "$mnt"
     54 sleep 3
     55 losetup -d $lodev