coastie wrote:
ok, as a group we need to fix this script so that it formats the partition. I was quite surprised when I installed slax yesterday, rebooted into slax on the hd. Then rebooted to fix my mbr so i could load suse too. After fixing the mbr and rebooting and choosing slax to check my grub settings, edubuntu loaded

seems that the installer doesn't format the partition

...
From a quick look at the script, it merely mounts a chosen partition, copies files to it, and installs a lilo bootloader to the mbr of the partition's disk to allow booting into the new slax install............This also saves the original mbr as "/origmbr" in the root of the slax filesystem.........
There is no formatting done here...........I'm not familiar with slax, per se, but I am intimately familiar with Slackware and the Slackware installer does allow you to format the partition.......But it seems that you should format beforehand, while in the slax livecd and then install........
Having said that

, it would be trivial to add formatting capability to the install script by checking for a second argument on the command line, such as 'make_disk.sh /dev/sda1 reiserfs'......
By adding a check, along with a case statement, you could have formatting done, like so:
Code:
if [ "$2" ];then
case $2 in
reiserfs) mkreiserfs $PART
;;
ext3) mke2fs -j $PART
;;
ext2) mke2fs $PART
;;
jfs) jfs_mkfs $PART
;;
xfs) mkfs.xfs $PART
;;
*) echo "'$2' is not recognised as a Linux partition"
exit 1
;;
esac
fi
Combine that with the script and it would look something like this (note - I surrounded the additions with triple asterisks (***))
Code:
#!/bin/bash
# Batch file to create bootable SLAX disk
# usage: make_disk.sh /dev/sda1 # (must be the partition)
# WARNING! boot sector of the device will be OVERWRITTEN!
# author: Tomas M. <http://www.linux-live.org>
if [ "$1" = "" ]; then
echo "usage: $0 partition_device ***[filesystem_type]***"
echo "example: $0 /dev/sda1 ***reiserfs***"
exit 1
fi
PART="$1"
***FSTYPE="$2"***
BOOT="$(sed -r "s/[0-9]+$//" <<<$PART)"
TMPDIR=/mnt/makedisk_mount$$
***
if [ "$FSTYPE" ];then
echo "Formatting the partition..."
case $FSTYPE in
reiserfs) mkreiserfs $PART
;;
ext3) mke2fs -j $PART
;;
ext2) mke2fs $PART
;;
jfs) jfs_mkfs $PART
;;
xfs) mkfs.xfs $PART
;;
*) echo "'$FSTYPE' is not recognised as a Linux partition"
exit 1
;;
esac
fi
***
echo "Mounting $PART to $TMPDIR..."
mkdir -p $TMPDIR
mount "$PART" $TMPDIR || exit 1
echo "Copying files..."
cp -a ./* "$TMPDIR" || exit 1
sync
echo "Setting up boot sector in $BOOT..."
cat<<_LCFG_ >$TMPDIR/lilo.conf
boot=$BOOT
compact
lba32
vga=769
prompt
timeout=20
install=text
image=$TMPDIR/boot/vmlinuz
initrd=$TMPDIR/boot/initrd.gz
label=slax
root=/dev/ram0
append="max_loop=255 init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=4444"
read-write
_LCFG_
lilo -C $TMPDIR/lilo.conf -m $TMPDIR/lilo.map -s $TMPDIR/origmbr 2>&1 | grep -vi warning
test $? -ne 0 && exit 1
umount $TMPDIR
rmdir $TMPDIR
echo "Successfully installed in $1"
You will need to interact with the formatting utility to go ahead with the formatting job..........This could be automated, but that would be a bad idea, IMO, in case you mistyped the partition to install on....
As a side note, I streamlined the script a bit, by removing some "useless use of commands"......
HTH
---thegeekster