summaryrefslogblamecommitdiffstats
path: root/install-usb
blob: cfccfdac2caccf55ca72c7cb1ec03a919d170e93 (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                                     
                                            
 
                             
 
                                                      
 








                                        





                                                           









                                                                              
                                                                            







                                                          
 
                                           
                                                   


                                  
 

                                                                              
 
                                                                   
                  
                                                                        
 

                                                                    
 
                                                             
                                                                                  


                           

                                   
                                                                  
 
#!/bin/bash

ROOT_DIR=$(dirname $(readlink -f $0))

if [ $(whoami) != "root" ]; then
  echo "you should be root"
  exit 1;
fi

OUT_DEV=$1
SYSLINUX=${ROOT_DIR}/contrib/syslinux/latest

PATH="$PATH:${ROOT_DIR}/bin/"

[ ! -f ${SYSLINUX}/Makefile ] && env.setup-syslinux.sh

if [ -z $OUT_DEV ]; then
    echo "no dev"
    exit 1
fi

for i in 1 2 3 4 5 6 7 8 9; do
   umount /dev/${OUT_DEV}$i &> /dev/null
done

# get the total size of the device
DISKSIZE=$(sfdisk -s /dev/${OUT_DEV} 2>/dev/null || echo 0)

# get the size of boot stuff


# create bootable vfat partition with 96cylinders and a ext3 partition for the
# rest of the stick
sfdisk /dev/${OUT_DEV} << EOF
,96,6,*
,,L
EOF

sync

# copy mbr to stick
dd bs=440 count=1 conv=notrunc if=${SYSLINUX}/mbr/mbr.bin of=/dev/${OUT_DEV}

# create filesystems on newly createt partitions
mkfs.vfat -F 16 -n  openslx-stick /dev/${OUT_DEV}1
mkfs.ext2 -L openslx-usrhome /dev/${OUT_DEV}2

mkdir -p /media/openslx-stick /media/openslx-stick-usrhome

sync

mount /dev/${OUT_DEV}1 /media/openslx-stick
mount /dev/${OUT_DEV}2 /media/openslx-stick-usrhome

mkdir -p /media/openslx-stick/boot


[ ! -f ${ROOT_DIR}/build/kernel-preboot-latest ] && build.kernel.sh
cp -v ${ROOT_DIR}/build/kernel-preboot-latest /media/openslx-stick/boot/kernel

#[ ! -f ${ROOT_DIR}/build/initramfs-default ] && build.initramfs.sh
build.initramfs.sh
cp -v ${ROOT_DIR}/build/initramfs-default /media/openslx-stick/boot/init

cp -v ${SYSLINUX}/com32/menu/menu.c32 /media/openslx-stick/boot/
cp -v ${SYSLINUX}/com32/menu/vesamenu.c32 /media/openslx-stick/boot/

cp -v ${ROOT_DIR}/config/extlinux/* /media/openslx-stick/boot
mv /media/openslx-stick/boot/extlinux.conf  /media/openslx-stick/boot/syslinux.cfg

sync
umount /media/openslx-stick
umount /media/openslx-stick-usrhome

${SYSLINUX}/linux/syslinux --install -d /boot -f /dev/${OUT_DEV}1