cynix

x86 UNIX-like OS
git clone git://git.2f30.org/cynix
Log | Files | Refs | README | LICENSE

mkcreateimg.sh (866B)


      1 #!/bin/bash
      2 
      3 MNT_PATH=./mnt
      4 
      5 function notfound() {
      6 	echo "[+] $1 can't be located!" 1>&2
      7 	umount /dev/loop0
      8 	exit
      9 }
     10 
     11 if [ ! "$UID" == "0" ]; then
     12 	echo "[+] you need to be root!" 1>&2
     13 	exit
     14 fi
     15 [ -d $MNT_PATH ] || mkdir $MNT_PATH
     16 lsmod | grep loop
     17 [ $? -eq 0 ] || modprobe loop &>/dev/null
     18 [ $? -eq 0 ] || echo "[+] loop can't be loaded!"
     19 dd if=/dev/zero of=image.img bs=512 count=2880
     20 losetup /dev/loop0 image.img
     21 mkfs -t ext2 /dev/loop0
     22 mount -t ext2 /dev/loop0 $MNT_PATH/
     23 mkdir -p $MNT_PATH/grub
     24 [ -f stage1 ] || notfound "stage1"
     25 [ -f stage2 ] || notfound "stage2"
     26 cp stage[12] $MNT_PATH/grub
     27 echo "timeout 1;default 0;title cynix;root (fd0);kernel /kernel;module (fd0)/initrd" | \
     28 	sed 's/;/\n/g' > $MNT_PATH/grub/menu.lst
     29 grub --batch --device-map=/dev/null << EOF
     30 device (fd0) /dev/loop0
     31 root (fd0)
     32 setup (fd0)
     33 quit
     34 EOF
     35 umount /dev/loop0
     36 losetup -d /dev/loop0