simplify mkusb.sh
This commit is contained in:
17
README.md
17
README.md
@ -95,9 +95,9 @@ it is a matter of convenience. In this case omit ``| pv `` in the commands
|
||||
|
||||
|
||||
|
||||
## install image by means of an USB stick
|
||||
## install image by means of the USB stick BOOT_TINY
|
||||
|
||||
The stick has TinyLinux and on it and some additional scripts
|
||||
The stick has TinyLinux on it and some additional scripts
|
||||
|
||||
If you do not have one, you may create it logging to an other box as root
|
||||
|
||||
@ -105,13 +105,11 @@ If you do not have one, you may create it logging to an other box as root
|
||||
|
||||
to verify that /dev/sdb is your stick, use the following command before and after plugging the stick
|
||||
```
|
||||
apu> ls /dev/sdb
|
||||
```
|
||||
apu> cd aputools
|
||||
apu> bash mkusb.sh
|
||||
|
||||
copy the stick image to the stick (32 GB should be enough)
|
||||
... you are asked to give the device name from a list (typically sdb) ...
|
||||
|
||||
```
|
||||
mac> dd if=apuinstall.lz4 bs=512k | pv | ssh root@<ip or hostname> "lz4 -d | dd of=/dev/sdb bs=512k"
|
||||
```
|
||||
|
||||
### b) mount with TinyLinux from USB stick
|
||||
@ -125,7 +123,7 @@ mac> screen /dev/tty.usbserial-130 115200
|
||||
|
||||
Do not yet connect LAN, plug USB stick and start the box, wait for prompt 'tc@box:'
|
||||
```
|
||||
apu> cd /media/CENTOS7_APU (or /media/CENTOS_APU)
|
||||
apu> cd /media/BOOT_TINY (or /media/CENTOS_APU)
|
||||
apu> sh reg
|
||||
```
|
||||
|
||||
@ -145,6 +143,9 @@ Use the displayed ip address for the following step.
|
||||
|
||||
|
||||
### c) Copy Image to APU SSD
|
||||
|
||||
Note that the images are not part of the git repo.
|
||||
|
||||
```
|
||||
mac> cd ~/switchdrive/apu/images
|
||||
mac> dd if=apumaster.lz4 bs=512k | pv | ssh root@192.168.1.43 "lz4 -d | dd of=/dev/sda bs=512k"
|
||||
|
34
mktiny.sh
34
mktiny.sh
@ -1,34 +0,0 @@
|
||||
# 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."
|
36
mkusb.sh
36
mkusb.sh
@ -1,15 +1,13 @@
|
||||
# name of the USB stick to be created
|
||||
NAME=BOOT_TINY
|
||||
|
||||
echo "enter source for tinylinux files, e.g. zolliker@mpc1704:switchdrive/apu/usbboot"
|
||||
echo "enter source for tinylinux files, e.g. zolliker@mpc1704:switchdrive/apu/boot_tiny"
|
||||
read SRC
|
||||
|
||||
scp -r $SRC ./
|
||||
|
||||
cd usbboot
|
||||
|
||||
# create (overwrite) syslinux.cfg
|
||||
cat > files/syslinux.cfg << "EOF"
|
||||
cat > boot_tiny/syslinux.cfg << "EOF"
|
||||
SERIAL 0 115200
|
||||
CONSOLE 0
|
||||
default centos
|
||||
@ -19,9 +17,9 @@ label centos
|
||||
kernel vmlinuz
|
||||
append initrd=core.gz inst.stage2=hd:LABEL=USBNAME quiet console=ttyS0,115200n8
|
||||
EOF
|
||||
sed -i -- "s/USBNAME/$NAME/g" files/syslinux.cfg
|
||||
sed -i -- "s/USBNAME/$NAME/g" boot_tiny/syslinux.cfg
|
||||
|
||||
ls files
|
||||
ls boot_tiny
|
||||
|
||||
# list removeable disks
|
||||
DISKS=()
|
||||
@ -43,7 +41,31 @@ read DEVICE
|
||||
|
||||
if [[ " ${DISKS[@]} " =~ " $DEVICE " ]]; then
|
||||
echo "create TinyLinux"
|
||||
sudo bash ../mktiny.sh $DEVICE $NAME
|
||||
|
||||
if [[ $(cat /sys/block/$DEVICE/removable) != "1" ]]; then
|
||||
echo "/dev/$DEVICE is not a removable disk"
|
||||
exit
|
||||
fi
|
||||
|
||||
DEVICE=/dev/$DEVICE
|
||||
|
||||
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 boot_tiny/* /mnt/apusb/
|
||||
umount /mnt/apusb
|
||||
|
||||
rm -rf boot_tiny
|
||||
echo "done."
|
||||
else
|
||||
echo "/dev/$DEVICE is not a removeable disk"
|
||||
fi
|
||||
|
Reference in New Issue
Block a user