Pejman Moghadam / Slackware

Slackware 12.2 - Syslinux

Public domain


df -hT

Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda2 reiserfs     19G   17G  2.5G  87% /
/dev/sda4 reiserfs     23G  1.4G   22G   6% /storage
/dev/sda3     ext3     14G  509M   13G   4% /mnt/lfs
/dev/sdb1     vfat    3.8G  9.1M  3.8G   1% /mnt/usb

tree /mnt/usb/

/mnt/usb/
|-- boot
|   |-- vmlinuz-huge-smp-2.6.21.5-smp
|   `-- vmlinuz-huge-smp-2.6.27.7-smp
|-- install.sh
`-- syslinux
    |-- ldlinux.sys
    |-- lilo
    |-- mbr.bin
    |-- menu.c32
    |-- syslinux
    |-- syslinux.cfg
    `-- vesamenu.c32

2 directories, 10 files

/mnt/usb/syslinux/syslinux.cfg

PROMPT 0
TIMEOUT 100
DEFAULT /syslinux/menu.c32
MENU TITLE SysLinux Bootloader

LABEL S120
MENU LABEL Slackware 12.0 
MENU DEFAULT
KERNEL /boot/vmlinuz-huge-smp-2.6.21.5-smp
APPEND ro root=/dev/sda2

LABEL S122
MENU LABEL Slackware 12.2
KERNEL /boot/vmlinuz-huge-smp-2.6.27.7-smp
APPEND ro root=/dev/sda2

/mnt/usb/install.sh

#!/bin/bash

set -e
TARGET=""
MBR=""

# Find out which partition or disk are we using
MYMNT=$(cd -P $(dirname $0) ; pwd)
while [ "$MYMNT" != "" -a "$MYMNT" != "." -a "$MYMNT" != "/" ]; do
   TARGET=$(egrep "[^[:space:]]+[[:space:]]+$MYMNT[[:space:]]+" /proc/mounts | cut -d " " -f 1)
   if [ "$TARGET" != "" ]; then break; fi
   MYMNT=$(dirname "$MYMNT")
done

if [ "$TARGET" = "" ]; then
   echo "Can't find device to install to."
   echo "Make sure you run this script from a mounted device."
   exit 1
fi

if [ "$(cat /proc/mounts | grep "^$TARGET" | grep noexec)" ]; then
   echo "The disk $TARGET is mounted with noexec parameter, trying to remount..."
   mount -o remount,exec "$TARGET"
fi

MBR=$(echo "$TARGET" | sed -r "s/[0-9]+\$//g")
NUM=${TARGET:${#MBR}}
cd "$MYMNT"

clear
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
echo "                        Welcome to Slax boot installer                         "
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
echo
echo "This installer will setup disk $TARGET to boot only Slax."
if [ "$MBR" != "$TARGET" ]; then
   echo
   echo "Warning! Master boot record (MBR) of $MBR will be overwritten."
   echo "If you use $MBR to boot any existing operating system, it will not work"
   echo "anymore. Only Slax will boot from this device. Be careful!"
fi
echo
echo "Press any key to continue, or Ctrl+C to abort..."
read junk
clear

echo "Flushing filesystem buffers, this may take a while..."
sync

# setup MBR if the device is not in superfloppy format
if [ "$MBR" != "$TARGET" ]; then
   echo "Setting up MBR on $MBR..."
   ./syslinux/lilo -S /dev/null -M $MBR ext # this must be here to support -A for extended partitions
   echo "Activating partition $TARGET..."
   ./syslinux/lilo -S /dev/null -A $MBR $NUM
   echo "Updating MBR on $MBR..." # this must be here because LILO mbr is bad. mbr.bin is from syslinux
   cat ./syslinux/mbr.bin > $MBR
fi

echo "Setting up boot record for $TARGET..."
./syslinux/syslinux -d syslinux $TARGET

echo "Disk $TARGET should be bootable now. Installation finished."

echo
echo "Read the information above and then press any key to exit..."
read junk

Resources

http://syslinux.zytor.com/
http://www.slax.org/

BY: Pejman Moghadam
TAG: syslinux
DATE: 2010-07-20 14:45:35


Pejman Moghadam / Slackware [ TXT ]