bootinst linux boot installer

pull/5/head
Tomas M 2012-10-09 14:47:46 -05:00
parent 39335c407f
commit 796a925a5f
3 changed files with 40 additions and 7 deletions

View File

@ -0,0 +1,32 @@
#!/bin/sh
# Setup booting from disk (USB or harddrive)
# Requires: extlinux, fdisk, df, tail, tr, cut, cat, sed
set -e
# change working directory to dir from which we are started
CWD="$(pwd)"
BOOT="$(dirname "$0")"
cd "$BOOT"
# find out device and mountpoint
PART="$(df . | tail -n 1 | tr -s " " | cut -d " " -f 1)"
DEV="$(echo "$PART" | sed -r "s:[0-9]+\$::" | sed -r "s:([0-9])[a-z]+\$:\\1:i")" #"
# install syslinux bootloader
extlinux --install $BOOT
if [ "$DEV" != "$PART" ]; then
# Setup MBR on the first block
cat "$BOOT/mbr.bin" > "$DEV"
# Toggle a bootable flag
PART="$(echo "$PART" | sed -r "s:.*[^0-9]::")"
(
fdisk -l "$DEV" | fgrep "*" | fgrep "$DEV" | cut -d " " -f 1 \
| sed -r "s:.*[^0-9]::" | xargs -I '{}' echo -ne "a\n{}\n"
echo -ne "a\n$PART\nw\n"
) | fdisk $DEV >/dev/null 2>&1
fi
echo "Boot installation finished."
cd "$CWD"

View File

@ -11,6 +11,7 @@
# - make # - make
# - find static binaries in /usr/src/buildroot-sources/output/target/bin/ etc # - find static binaries in /usr/src/buildroot-sources/output/target/bin/ etc
# #
# - all sources can be found at http://ftp.slax.org/Slax-7.0-development/sources/Slax-7.0-sources
# Automatically determine the architecture we're building on: # Automatically determine the architecture we're building on:
if [ -z "$MYARCH" ]; then if [ -z "$MYARCH" ]; then

View File

@ -324,29 +324,29 @@ persistent_changes()
# if not, simply return back # if not, simply return back
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "* Persistent changes not writable or not used" >&2 echo "* Persistent changes not writable or not used"
return return
fi fi
echo "* Testing persistent changes for posix compatibility" >&2 echo_green_star
echo "Testing persistent changes for posix compatibility"
touch "$T1" && ln -sf "$T1" "$T2" 2>/dev/null && \ touch "$T1" && ln -sf "$T1" "$T2" 2>/dev/null && \
chmod +x "$T1" 2>/dev/null && test -x "$T1" && \ chmod +x "$T1" 2>/dev/null && test -x "$T1" && \
chmod -x "$T1" 2>/dev/null && test ! -x "$T1" && \ chmod -x "$T1" 2>/dev/null && test ! -x "$T1" && \
rm "$T1" "$T2" 2>/dev/null rm "$T1" "$T2" 2>/dev/null
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo_green_star echo "* Activating dynamic sized storage for persistent changes"
echo "Activating dynamic sized storage for persistent changes" >&2
rm "$T1" "$T2" 2>/dev/null rm "$T1" "$T2" 2>/dev/null
mount.dynsizefs "$CHANGES/changes.idx" "$CHANGES/changes.dat" "$2"
mount.dynsizefs "$CHANGES/changes.idx" "$CHANGES/changes.dat" 4096 "$2"
if [ "$(device_bestfs "$2/dynsize.fs" | tr -d " ")" = "-t" ]; then if [ "$(device_bestfs "$2/dynsize.fs" | tr -d " ")" = "-t" ]; then
mke2fs -F "$2/dynsize.fs" >/dev/null mke2fs -F "$2/dynsize.fs" >/dev/null
fi fi
mount -o loop "$2/dynsize.fs" "$2" mount -o loop "$2/dynsize.fs" "$2"
rmdir "$2/lost+found" rmdir "$2/lost+found"
else else
echo_green_star echo "* Activating native persistent changes"
echo "Activating native persistent changes" >&2
mount --bind "$CHANGES" "$2" mount --bind "$CHANGES" "$2"
fi fi
} }