add scripts to create an bootable USB stick with TinyLinux

This commit is contained in:
2024-01-16 17:52:04 +01:00
parent ca6c4f25cb
commit c354a0076b
2 changed files with 84 additions and 0 deletions

34
mktiny.sh Normal file
View File

@@ -0,0 +1,34 @@
# create a bootable USB stick for APU
# this part of the script needs root priv
if [ $# -ne 2 ] || [ $EUID != 0 ]
then
echo "Usage: sudo bash mktiny.sh <device name> <usb stick name>"
exit
fi
if [[ $(cat /sys/block/$1/removable) != "1" ]]; then
echo "/dev/$1 is not a removable disk"
exit
fi
DEVICE=/dev/$1
NAME=$2
umount ${DEVICE}1
dd if=/dev/zero of=${DEVICE} count=1 conv=notrunc
echo -e "o\nn\np\n1\n\n\nw" | fdisk ${DEVICE}
mkfs.vfat -n $NAME -I ${DEVICE}1
syslinux -i ${DEVICE}1
dd conv=notrunc bs=440 count=1 if=mbr.bin of=${DEVICE}
parted ${DEVICE} set 1 boot on
mkdir -p /mnt/apusb
mount ${DEVICE}1 /mnt/apusb
echo "copy files ..."
cp files/* /mnt/apusb/
umount /mnt/apusb
rm -rf usbboot
echo "done."