[Voyage-linux] Custom install script
Jordi Soucheiron
(spam-protected)
Fri Nov 25 20:40:19 HKT 2011
Hello!
I've been using dd to replicate my voyage installations for a while. Now
I'm trying a new way of installing using the script below. I'm using a alix
board with a 4GB flash card. The problem is that most of the time the
script works. But some images don't load grub.
Do you know what can be going wrong? Feel free to use it or propose
improvements :)
PD: If I run two copies of the script in parallel sfdisk locks until the
first one exits. Any help on this will be appreciated too :)
#!/bin/bash
#script instalació dexgate:
if [ $# -eq 0 ];then
echo "Necessitem el disc a on instalar"
exit
fi
if [ -b $1 ]; then
TARGET_DISK=$1
else
echo "$1 no és un disc"
fi
TARGET_PART="$TARGET_DISK"1
TARGET_MOUNT=/mnt/tmp-`echo $TARGET_DISK | cut -d/ -f3`
SOURCE_TAR=/home/jordi/dumpalixgw/dumpentar.tgz
#desmontar partició:
umount $TARGET_PART
#generar taula de particions
SFDISKCMD='0,,L,*\n;\n;\n;'
echo -e "$SFDISKCMD" | sfdisk "$TARGET_DISK"
if [ -d $TARGET_MOUNT ]; then
echo "El directori de montatge ja existeix"
else
mkdir $TARGET_MOUNT
echo "Creant $TARGET_MOUNT"
fi
#formatejar partició
mkfs.ext2 $TARGET_PART
tune2fs -i 28 -c 28 -C -1 $TARGET_PART -L DEXGate
#montar la nova partició
mount $TARGET_PART $TARGET_MOUNT
#copiar la imatge
#cd $SOURCE_DIR
#dd if=$SOURCE_TAR | pv | tar xf - -C $TARGET_MOUNT
pv $SOURCE_TAR | tar xzf - -C $TARGET_MOUNT
mount -o bind /dev $TARGET_MOUNT/dev
echo "Writing (hd5) $TARGET_DISK to $TARGET_MOUNT/boot/grub/device.map"
echo "(hd5) $TARGET_DISK" > "$TARGET_MOUNT/boot/grub/device.map"
echo "Setting up grub under chroot $TARGET_MOUNT"
res=`chroot $TARGET_MOUNT /usr/sbin/grub \
--device-map=/boot/grub/device.map <<EOM
setup (hd5) (hd5,0)
quit
EOM`
echo $res
if [ $? -ne 0 ]; then
err_quit "Trouble running grub - dialog was: $res"
fi
echo "Deleting $TARGET_MOUNT/boot/grub/device.map"
rm "$TARGET_MOUNT/boot/grub/device.map"
echo "Unmounting $TARGET_MOUNT/dev"
umount "$TARGET_MOUNT/dev"
#desmontar la partició
umount "$TARGET_PART"
sync
*Jordi Soucheiron*
Software Engineer
jsoucheiron at dexmatech.com
*DEXMA*
Parc Tecnològic Barcelona Nord
c/ Marie Curie, 8-14 (Oficina 227)
ES-08042, Barcelona
t: (+34) 93 181 01 96
www.dexmatech.com
Follow us on Twitter <http://www.twitter.com/dexma> and
Linkedin<http://www.linkedin.com/company/247838>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.voyage.hk/pipermail/voyage-linux/attachments/20111125/cb055fcb/attachment-0002.html>
More information about the Voyage-linux
mailing list