Hello!<br>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.<br>
Do you know what can be going wrong? Feel free to use it or propose improvements :)<br><br>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 :)<br>
<br>#!/bin/bash<br>#script instalació dexgate:<br><br>if [ $# -eq 0 ];then<br>    echo "Necessitem el disc a on instalar"<br>    exit<br>fi<br>if [ -b $1 ]; then<br>    TARGET_DISK=$1<br>else<br>    echo "$1 no és un disc"<br>
fi<br><br>TARGET_PART="$TARGET_DISK"1<br>TARGET_MOUNT=/mnt/tmp-`echo $TARGET_DISK | cut -d/ -f3`<br>SOURCE_TAR=/home/jordi/dumpalixgw/dumpentar.tgz<br><br>#desmontar partició:<br>umount $TARGET_PART<br><br>#generar taula de particions<br>
SFDISKCMD='0,,L,*\n;\n;\n;'<br>echo -e "$SFDISKCMD" | sfdisk "$TARGET_DISK"<br><br>if [ -d $TARGET_MOUNT ]; then<br>    echo "El directori de montatge ja existeix" <br>else<br>    mkdir $TARGET_MOUNT<br>
    echo "Creant $TARGET_MOUNT"<br>fi<br><br><br>#formatejar partició<br>mkfs.ext2 $TARGET_PART<br>tune2fs -i 28 -c 28 -C -1 $TARGET_PART -L DEXGate<br><br>#montar la nova partició<br>mount $TARGET_PART $TARGET_MOUNT<br>
<br>#copiar la imatge<br>#cd $SOURCE_DIR<br>#dd if=$SOURCE_TAR | pv | tar xf - -C $TARGET_MOUNT<br>pv $SOURCE_TAR | tar xzf - -C $TARGET_MOUNT<br><br>mount -o bind /dev $TARGET_MOUNT/dev<br><br>echo "Writing (hd5) $TARGET_DISK to $TARGET_MOUNT/boot/grub/device.map"<br>
echo "(hd5) $TARGET_DISK" > "$TARGET_MOUNT/boot/grub/device.map"<br><br>echo "Setting up grub under chroot $TARGET_MOUNT"<br>res=`chroot $TARGET_MOUNT /usr/sbin/grub \<br>    --device-map=/boot/grub/device.map  <<EOM<br>
setup (hd5) (hd5,0)<br>quit<br>EOM`<br><br>echo $res<br><br>if [ $? -ne 0 ]; then<br>    err_quit "Trouble running grub - dialog was: $res"<br>fi<br><br>echo "Deleting $TARGET_MOUNT/boot/grub/device.map"<br>
rm "$TARGET_MOUNT/boot/grub/device.map"<br><br>echo "Unmounting $TARGET_MOUNT/dev"<br>umount "$TARGET_MOUNT/dev"<br><br>#desmontar la partició<br>umount "$TARGET_PART"<br>sync<br><br>
<br clear="all"><b>Jordi Soucheiron</b><br>
Software Engineer<br><a style="color: rgb(102, 153, 0);" href="mailto:jsoucheiron@dexmatech.com" target="_blank">jsoucheiron@dexmatech.com</a><br>
<br>
<b>DEXMA</b><br>
Parc Tecnològic Barcelona Nord<br>c/ Marie Curie, 8-14  (Oficina 227)<br>ES-08042, Barcelona<br>t: (+34) 93 181 01 96<br><a href="http://www.dexmatech.com" target="_blank">www.dexmatech.com</a><br><br>Follow us on <a href="http://www.twitter.com/dexma" target="_blank">Twitter</a> and <a href="http://www.linkedin.com/company/247838" target="_blank">Linkedin</a><br>
<br><br>