Making bootable USB keys

2009-09-03 Thread Samuel Martín Moro
Hello

I'm having some troubles, trying to create bootable USB keys.
I found (freebsd-hackers ML archives) a script, supposed to create the
bootable image from my iso file.
But, it still don't boot... (I may do it wrong)

In details:
-We distribute a FreeBSD (4.7, 5.4, 6.2 and 7.2) "custom" server.
-We burn our install CD (and, in a few, our USB sticks) on a Ferdora 9
(sorry...)
-USB sticks must contain a FAT32 partition (we'ld like to provide doc for
windows users)

Well, my english isn't so great... so I'll post my code (more
understandable)

--maker.sh--
#!/bin/sh
ISO_DIR=/r00t
ISO_PFIX=r00t
VERSION=5.9.3.0
ISO_FILE=$ISO_DIR/$ISO_PFIX-$VERSION.img
DEVICE=
TMPDOC=/mnt/tmpdoc
DOCDIR=/root/samuel/docdir
ERR=
SFX=
MBR=/root/samuel/mbr
BT1=/root/samuel/boot1
BT2=/root/samuel/boot2

if [ -e "$1" ]; then
DEVICE=$1
elif [ "$1" -a -e "/dev/$1" ]; then
DEVICE=/dev/$1
elif [ "$1" ]; then
echo "$0: incorrect device specified" >&2
exit
else
echo "$0: must specify device" >&2
exit
fi
for i in `mount | cut -d ' ' -f 1`
do
if [ "`echo $i | grep $DEVICE`" ]; then
echo "$0: $i already mounted" >&2
echo "umount it manually or choose an other drive" >&2
exit
fi
done

if [ -e "$TMPDOC" -a -d "$TMPDOC" ]; then
echo "$0: removing $TMPDOC directory" >&2
rm -rf $TMPDOC
elif [ -e "$TMPDOC" ]; then
mv $TMPDOC $TMPDOC.old
echo "$0: moved $TMPDOC to $TMPDOC.old" >&2
fi
mkdir $TMPDOC

if [ "$2" ]; then
echo $2 | grep "\.img$" >/dev/null || SFX=".img"
fi

if [ -e "$2$SFX" ]; then
ISO_FILE=$2$SFX
elif [ "$2" -a -e "$ISO_DIR/$2$SFX" ]; then
ISO_FILE=$ISO_DIR/$2
elif [ "$2" -a -e "$ISO_DIR/$ISO_PFIX-$2$SFX" ]; then
ISO_FILE="$ISO_DIR/$ISO_PFX-$2$SFX"
else
echo "$0: will use default file \`$ISO_FILE'" >&2
echo " as system image source" >&2
fi
if [ -e "$ISO_FILE" ]; then
MSize=`ls -l $ISO_FILE | awk '{print $5}'`
else
echo "$0: $ISO_FILE doesn't exist!" >&2
rm -rf $TMPDOC
exit
fi
if [ -z "$MSize" -o "$MSize" -lt 1 ]; then
echo "$0: bad image size (size=$MSize)" >&2
rm -rf $TMPDOC
exit
fi

while :
do
echo " [ Working on $DEVICE ]"

echo -n "determining device geometry  "
infos=`fdisk -l $DEVICE 2>/dev/null | grep "[0-9]* heads"`
ident=`fdisk -l $DEVICE 2>/dev/null | awk '/Disk identifier/{print $3}'`
csz=`fdisk -l $DEVICE 2>/dev/null | awk '/Units = cylinders /{print
$7}'`
eval `echo $infos | awk '{print "hpc=" $1 " sec=" $3 " cyl=" $5}'`
if [ -z "$hpc" -o -z "$sec" -o -z "$cyl" -o -z "$csz" ]; then
echo " [ FAIL ]"
echo "$0: can't get infos for device $DEVICE" >&2
rm -rf $TMPDOC
exit
fi
echo " [ OK ]"

echo -n "initializing partition table "
#dd if=/dev/zero of=$DEVICE bs=$csz count=1 >/dev/null 2>&1
dd if=$BT1 of=$DEVICE >/dev/null 2>&1
round=128
tocyl=`expr $hpc '*' $sec '*' $csz`
ret=`expr $MSize % $tocyl`
MSize=`expr $MSize / $tocyl`
test "$ret" -eq "0" || MSize=`expr $MSize + 1`
s2len=$MSize
s2off=`expr $cyl - $s2len - 1`
s1len=`expr $s2off - 1`
s1off=1
sfdisk -DLqf $DEVICE >/dev/null 2>&1 &1
mkdosfs -i 42424242 -n "Docs" -F 32 ${DEVICE}1 >/dev/null 2>&1
mount -t vfat ${DEVICE}1 $TMPDOC || ERR=1
if [ "$ERR" ]; then
echo " [ FAIL ]"
echo "$0: unable to mount ${DEVICE}1 on $TMPDOC"
rm -rf $TMPDOC
exit
fi
echo " [ OK ]"

echo -n "copying documentation files  "
cp -rp $DOCDIR/* $TMPDOC/ >/dev/null 2>&1 || ERR=2
if [ "$ERR" ]; then
echo " [ FAIL ]"
echo "$0: unable to copy doc files"
ERR=
fi
umount ${DEVICE}1
echo " [ OK ]"

echo -n "copying system   "
dd if=$ISO_FILE of=${DEVICE}2 status=noxfer >/dev/null 2>&1
echo " [ OK ]"

mbrsig $DEVICE 2>&1 | awk '{print "marking device with serial " $3
}'
echo " [ Device ready! ]"
echo ""
echo -n " Create new USB key ?  [Y/N] : " && read i
test "$i" = "Y" -o "$i" = "y" -o "$i" = "O" -o "$i" = "o" || i=
test -z "$i" && echo " [ leaving ]" && break
echo " Please, remove current USB key, insert new one and press enter"
read i
done
rmdir $TMPDOC
--EOF--

So, this is a "USB stick generator" I'm working on.
It seems to work. (I've not tested everything, but the basis is OK)
The stick is correctly parted.
The documentation is copied.
My only problem is that it still don't wan't to boot...

At the beginning, I was trying to paste my ISO file directly in ${DEVICE}2
Then, I found the following shell script, which is supposed to make my
bootable image from my ISO file
I changed 2/3 things, but some of you may recognize it anyway:

--ISOtoIMG.sh--
#!/bin/sh
MAKEFS=makefs
MKLABEL=bsdlabel
BSDTAR=tar
DD="dd status=noxfer"

make_freebsd_image()
{
  local tree=$1
  local imagefile=$2
  local boot1=${tree}/boot/boot1
  local boot2=${tree}/boot/boot2

  echo "convert tree $tr

Re: Making bootable USB keys

2009-09-03 Thread Samuel Martín Moro
hello.
again.

btw: my .img file is 0-filled in its 512 first bytes...

i downloaded the 8-0-BETA3-???.img, it starts with EB3C.
and I think each .img file start like that, right ?



thanks

Samuel Martín Moro
CamTrace
{EPITECH.} tek4



On Thu, Sep 3, 2009 at 5:35 PM, Samuel Martín Moro wrote:

>
> Hello
>
> I'm having some troubles, trying to create bootable USB keys.
> I found (freebsd-hackers ML archives) a script, supposed to create the
> bootable image from my iso file.
> But, it still don't boot... (I may do it wrong)
>
> In details:
> -We distribute a FreeBSD (4.7, 5.4, 6.2 and 7.2) "custom" server.
> -We burn our install CD (and, in a few, our USB sticks) on a Ferdora 9
> (sorry...)
> -USB sticks must contain a FAT32 partition (we'ld like to provide doc for
> windows users)
>
> Well, my english isn't so great... so I'll post my code (more
> understandable)
>
> --maker.sh--
> #!/bin/sh
> ISO_DIR=/r00t
> ISO_PFIX=r00t
> VERSION=5.9.3.0
> ISO_FILE=$ISO_DIR/$ISO_PFIX-$VERSION.img
> DEVICE=
> TMPDOC=/mnt/tmpdoc
> DOCDIR=/root/samuel/docdir
> ERR=
> SFX=
> MBR=/root/samuel/mbr
> BT1=/root/samuel/boot1
> BT2=/root/samuel/boot2
>
> if [ -e "$1" ]; then
> DEVICE=$1
> elif [ "$1" -a -e "/dev/$1" ]; then
> DEVICE=/dev/$1
> elif [ "$1" ]; then
> echo "$0: incorrect device specified" >&2
> exit
> else
> echo "$0: must specify device" >&2
> exit
> fi
> for i in `mount | cut -d ' ' -f 1`
> do
> if [ "`echo $i | grep $DEVICE`" ]; then
> echo "$0: $i already mounted" >&2
> echo "umount it manually or choose an other drive" >&2
> exit
> fi
> done
>
> if [ -e "$TMPDOC" -a -d "$TMPDOC" ]; then
> echo "$0: removing $TMPDOC directory" >&2
> rm -rf $TMPDOC
> elif [ -e "$TMPDOC" ]; then
> mv $TMPDOC $TMPDOC.old
> echo "$0: moved $TMPDOC to $TMPDOC.old" >&2
> fi
> mkdir $TMPDOC
>
> if [ "$2" ]; then
> echo $2 | grep "\.img$" >/dev/null || SFX=".img"
> fi
>
> if [ -e "$2$SFX" ]; then
> ISO_FILE=$2$SFX
> elif [ "$2" -a -e "$ISO_DIR/$2$SFX" ]; then
> ISO_FILE=$ISO_DIR/$2
> elif [ "$2" -a -e "$ISO_DIR/$ISO_PFIX-$2$SFX" ]; then
> ISO_FILE="$ISO_DIR/$ISO_PFX-$2$SFX"
> else
> echo "$0: will use default file \`$ISO_FILE'" >&2
> echo " as system image source" >&2
> fi
> if [ -e "$ISO_FILE" ]; then
> MSize=`ls -l $ISO_FILE | awk '{print $5}'`
> else
> echo "$0: $ISO_FILE doesn't exist!" >&2
> rm -rf $TMPDOC
> exit
> fi
> if [ -z "$MSize" -o "$MSize" -lt 1 ]; then
> echo "$0: bad image size (size=$MSize)" >&2
> rm -rf $TMPDOC
> exit
> fi
>
> while :
> do
> echo " [ Working on $DEVICE ]"
>
> echo -n "determining device geometry  "
> infos=`fdisk -l $DEVICE 2>/dev/null | grep "[0-9]* heads"`
> ident=`fdisk -l $DEVICE 2>/dev/null | awk '/Disk identifier/{print
> $3}'`
> csz=`fdisk -l $DEVICE 2>/dev/null | awk '/Units = cylinders /{print
> $7}'`
> eval `echo $infos | awk '{print "hpc=" $1 " sec=" $3 " cyl=" $5}'`
> if [ -z "$hpc" -o -z "$sec" -o -z "$cyl" -o -z "$csz" ]; then
> echo " [ FAIL ]"
> echo "$0: can't get infos for device $DEVICE" >&2
> rm -rf $TMPDOC
> exit
> fi
> echo " [ OK ]"
>
> echo -n "initializing partition table "
> #dd if=/dev/zero of=$DEVICE bs=$csz count=1 >/dev/null 2>&1
> dd if=$BT1 of=$DEVICE >/dev/null 2>&1
> round=128
> tocyl=`expr $hpc '*' $sec '*' $csz`
> ret=`expr $MSize % $tocyl`
> MSize=`expr $MSize / $tocyl`
> test "$ret" -eq "0" || MSize=`expr $MSize + 1`
> s2len=$MSize
> s2off=`expr $cyl - $s2len - 1`
> s1len=`expr $s2off - 1`
> s1off=1
> sfdisk -DLqf $DEVICE >/dev/null 2>&1 < $s1off $s1len b
> $s2off $s2len a5 *
> EOF
> echo " [ OK ]"
>
> echo -n "formatting FAT32 partition   "
> dd if=/dev/zero of=${DEVICE}1 bs=$csz count=1 >/dev/null 2>&1
> mkdosfs -i 42424242 -n "Docs" -F 32 ${DEVICE}1 >/dev/null 2>&1
> mount -t vfat ${DEVICE}1 $TMPDOC || ERR=1
> if [ "$ERR" ]; then
> echo " [ FAIL ]"
> echo "$0: unable to mount ${DEVICE}1 on $TMPDOC"
> rm -rf $TMPDOC
> exit
> fi
> echo " [ OK ]"
>
> echo -n "copying documentation files  "
> cp -rp $DOCDIR/* $TMPDOC/ >/dev/null 2>&1 || ERR=2
> if [ "$ERR" ]; then
> echo " [ FAIL ]"
> echo "$0: unable to copy doc files"
> ERR=
> fi
> umount ${DEVICE}1
> echo " [ OK ]"
>
> echo -n "copying system   "
> dd if=$ISO_FILE of=${DEVICE}2 status=noxfer >/dev/null 2>&1
> echo " [ OK ]"
>
> mbrsig $DEVICE 2>&1 | awk '{print "marking device with serial " $3
> }'
> echo " [ Device ready! ]"
> echo ""
> echo -n " Create new USB key ?  [Y/N] : " && read i
> test "$i" = "Y" -o "$i" = "y" -o "$i" = "O" -o "$i" = "o" || i=
> test -z "$i" && echo " [ leaving ]" && break
> echo " Please, remove current USB key, insert new one and press enter"

Re: Making bootable USB keys

2009-09-03 Thread Dimitri Yioulos
On Thursday 03 September 2009 11:35:34 am Samuel 
Martín Moro wrote:
> Hello
>
> I'm having some troubles, trying to create
> bootable USB keys. I found (freebsd-hackers ML
> archives) a script, supposed to create the
> bootable image from my iso file.
> But, it still don't boot... (I may do it wrong)
>
> In details:
> -We distribute a FreeBSD (4.7, 5.4, 6.2 and
> 7.2) "custom" server. -We burn our install CD
> (and, in a few, our USB sticks) on a Ferdora 9
> (sorry...)
> -USB sticks must contain a FAT32 partition
> (we'ld like to provide doc for windows users)
>
> Well, my english isn't so great... so I'll post
> my code (more understandable)
>
> --maker.sh--
> #!/bin/sh
> ISO_DIR=/r00t
> ISO_PFIX=r00t
> VERSION=5.9.3.0
> ISO_FILE=$ISO_DIR/$ISO_PFIX-$VERSION.img
> DEVICE=
> TMPDOC=/mnt/tmpdoc
> DOCDIR=/root/samuel/docdir
> ERR=
> SFX=
> MBR=/root/samuel/mbr
> BT1=/root/samuel/boot1
> BT2=/root/samuel/boot2
>
> if [ -e "$1" ]; then
> DEVICE=$1
> elif [ "$1" -a -e "/dev/$1" ]; then
> DEVICE=/dev/$1
> elif [ "$1" ]; then
> echo "$0: incorrect device specified" >&2
> exit
> else
> echo "$0: must specify device" >&2
> exit
> fi
> for i in `mount | cut -d ' ' -f 1`
> do
> if [ "`echo $i | grep $DEVICE`" ]; then
> echo "$0: $i already mounted" >&2
> echo "umount it manually or
> choose an other drive" >&2 exit
> fi
> done
>
> if [ -e "$TMPDOC" -a -d "$TMPDOC" ]; then
> echo "$0: removing $TMPDOC directory" >&2
> rm -rf $TMPDOC
> elif [ -e "$TMPDOC" ]; then
> mv $TMPDOC $TMPDOC.old
> echo "$0: moved $TMPDOC to $TMPDOC.old" >&2
> fi
> mkdir $TMPDOC
>
> if [ "$2" ]; then
> echo $2 | grep "\.img$" >/dev/null ||
> SFX=".img" fi
>
> if [ -e "$2$SFX" ]; then
> ISO_FILE=$2$SFX
> elif [ "$2" -a -e "$ISO_DIR/$2$SFX" ]; then
> ISO_FILE=$ISO_DIR/$2
> elif [ "$2" -a -e "$ISO_DIR/$ISO_PFIX-$2$SFX"
> ]; then ISO_FILE="$ISO_DIR/$ISO_PFX-$2$SFX"
> else
> echo "$0: will use default file
> \`$ISO_FILE'" >&2 echo " as system
> image source" >&2 fi
> if [ -e "$ISO_FILE" ]; then
> MSize=`ls -l $ISO_FILE | awk '{print $5}'`
> else
> echo "$0: $ISO_FILE doesn't exist!" >&2
> rm -rf $TMPDOC
> exit
> fi
> if [ -z "$MSize" -o "$MSize" -lt 1 ]; then
> echo "$0: bad image size (size=$MSize)" >&2
> rm -rf $TMPDOC
> exit
> fi
>
> while :
> do
> echo " [ Working on $DEVICE ]"
>
> echo -n "determining device geometry  "
> infos=`fdisk -l $DEVICE 2>/dev/null | grep
> "[0-9]* heads"` ident=`fdisk -l $DEVICE
> 2>/dev/null | awk '/Disk identifier/{print
> $3}'` csz=`fdisk -l $DEVICE 2>/dev/null | awk
> '/Units = cylinders /{print $7}'`
> eval `echo $infos | awk '{print "hpc=" $1 "
> sec=" $3 " cyl=" $5}'` if [ -z "$hpc" -o -z
> "$sec" -o -z "$cyl" -o -z "$csz" ]; then echo "
> [ FAIL ]"
> echo "$0: can't get infos for device
> $DEVICE" >&2 rm -rf $TMPDOC
> exit
> fi
> echo " [ OK ]"
>
> echo -n "initializing partition table "
> #dd if=/dev/zero of=$DEVICE bs=$csz count=1
> >/dev/null 2>&1 dd if=$BT1 of=$DEVICE
> >/dev/null 2>&1 round=128
> tocyl=`expr $hpc '*' $sec '*' $csz`
> ret=`expr $MSize % $tocyl`
> MSize=`expr $MSize / $tocyl`
> test "$ret" -eq "0" || MSize=`expr $MSize +
> 1` s2len=$MSize
> s2off=`expr $cyl - $s2len - 1`
> s1len=`expr $s2off - 1`
> s1off=1
> sfdisk -DLqf $DEVICE >/dev/null 2>&1 < $s1off $s1len b
> $s2off $s2len a5 *
> EOF
> echo " [ OK ]"
>
> echo -n "formatting FAT32 partition   "
> dd if=/dev/zero of=${DEVICE}1 bs=$csz
> count=1 >/dev/null 2>&1 mkdosfs -i 42424242 -n
> "Docs" -F 32 ${DEVICE}1 >/dev/null 2>&1 mount
> -t vfat ${DEVICE}1 $TMPDOC || ERR=1 if [ "$ERR"
> ]; then
> echo " [ FAIL ]"
> echo "$0: unable to mount ${DEVICE}1 on
> $TMPDOC" rm -rf $TMPDOC
> exit
> fi
> echo " [ OK ]"
>
> echo -n "copying documentation files  "
> cp -rp $DOCDIR/* $TMPDOC/ >/dev/null 2>&1
> || ERR=2 if [ "$ERR" ]; then
> echo " [ FAIL ]"
> echo "$0: unable to copy doc files"
> ERR=
> fi
> umount ${DEVICE}1
> echo " [ OK ]"
>
> echo -n "copying system   "
> dd if=$ISO_FILE of=${DEVICE}2 status=noxfer
> >/dev/null 2>&1 echo " [ OK ]"
>
> mbrsig $DEVICE 2>&1 | awk '{print "   
> marking device with serial " $3 }'
> echo " [ Device ready! ]"
> echo ""
> echo -n " Create new USB key ?  [Y/N] :
> " && read i test "$i" = "Y" -o "$i" = "y" -o
> "$i" = "O" -o "$i" = "o" || i= test -z "$i" &&
> echo " [ leaving ]" && break echo " Please,
> remove current USB key, insert new one and
> press enter" read i
> done
> rmdir $TMPDOC
> --EOF--
>
> So, this is a "USB stick generator" I'm working
> on. It seems to work. (I've not tested
> everything, but the basis is OK) The stick is
> correctly parted.
> The documentation is copied.
> My only problem is that it still don't wan't to
> boot...
>
> At the beginning, I

Re: Making bootable USB keys

2009-09-03 Thread Samuel Martín Moro
I've already been told.
But didn't tried it yet, my servers haven't X.
I'll take a look on a test computer.
But in the end, everything'll have to be done in the shellscript.


Samuel Martín Moro
CamTrace
{EPITECH.} tek4



On Thu, Sep 3, 2009 at 6:19 PM, Dimitri Yioulos wrote:

> On Thursday 03 September 2009 11:35:34 am Samuel
> Martín Moro wrote:
> > Hello
> >
> > I'm having some troubles, trying to create
> > bootable USB keys. I found (freebsd-hackers ML
> > archives) a script, supposed to create the
> > bootable image from my iso file.
> > But, it still don't boot... (I may do it wrong)
> >
> > In details:
> > -We distribute a FreeBSD (4.7, 5.4, 6.2 and
> > 7.2) "custom" server. -We burn our install CD
> > (and, in a few, our USB sticks) on a Ferdora 9
> > (sorry...)
> > -USB sticks must contain a FAT32 partition
> > (we'ld like to provide doc for windows users)
> >
> > Well, my english isn't so great... so I'll post
> > my code (more understandable)
> >
> > --maker.sh--
> > #!/bin/sh
> > ISO_DIR=/r00t
> > ISO_PFIX=r00t
> > VERSION=5.9.3.0
> > ISO_FILE=$ISO_DIR/$ISO_PFIX-$VERSION.img
> > DEVICE=
> > TMPDOC=/mnt/tmpdoc
> > DOCDIR=/root/samuel/docdir
> > ERR=
> > SFX=
> > MBR=/root/samuel/mbr
> > BT1=/root/samuel/boot1
> > BT2=/root/samuel/boot2
> >
> > if [ -e "$1" ]; then
> > DEVICE=$1
> > elif [ "$1" -a -e "/dev/$1" ]; then
> > DEVICE=/dev/$1
> > elif [ "$1" ]; then
> > echo "$0: incorrect device specified" >&2
> > exit
> > else
> > echo "$0: must specify device" >&2
> > exit
> > fi
> > for i in `mount | cut -d ' ' -f 1`
> > do
> > if [ "`echo $i | grep $DEVICE`" ]; then
> > echo "$0: $i already mounted" >&2
> > echo "umount it manually or
> > choose an other drive" >&2 exit
> > fi
> > done
> >
> > if [ -e "$TMPDOC" -a -d "$TMPDOC" ]; then
> > echo "$0: removing $TMPDOC directory" >&2
> > rm -rf $TMPDOC
> > elif [ -e "$TMPDOC" ]; then
> > mv $TMPDOC $TMPDOC.old
> > echo "$0: moved $TMPDOC to $TMPDOC.old" >&2
> > fi
> > mkdir $TMPDOC
> >
> > if [ "$2" ]; then
> > echo $2 | grep "\.img$" >/dev/null ||
> > SFX=".img" fi
> >
> > if [ -e "$2$SFX" ]; then
> > ISO_FILE=$2$SFX
> > elif [ "$2" -a -e "$ISO_DIR/$2$SFX" ]; then
> > ISO_FILE=$ISO_DIR/$2
> > elif [ "$2" -a -e "$ISO_DIR/$ISO_PFIX-$2$SFX"
> > ]; then ISO_FILE="$ISO_DIR/$ISO_PFX-$2$SFX"
> > else
> > echo "$0: will use default file
> > \`$ISO_FILE'" >&2 echo " as system
> > image source" >&2 fi
> > if [ -e "$ISO_FILE" ]; then
> > MSize=`ls -l $ISO_FILE | awk '{print $5}'`
> > else
> > echo "$0: $ISO_FILE doesn't exist!" >&2
> > rm -rf $TMPDOC
> > exit
> > fi
> > if [ -z "$MSize" -o "$MSize" -lt 1 ]; then
> > echo "$0: bad image size (size=$MSize)" >&2
> > rm -rf $TMPDOC
> > exit
> > fi
> >
> > while :
> > do
> > echo " [ Working on $DEVICE ]"
> >
> > echo -n "determining device geometry  "
> > infos=`fdisk -l $DEVICE 2>/dev/null | grep
> > "[0-9]* heads"` ident=`fdisk -l $DEVICE
> > 2>/dev/null | awk '/Disk identifier/{print
> > $3}'` csz=`fdisk -l $DEVICE 2>/dev/null | awk
> > '/Units = cylinders /{print $7}'`
> > eval `echo $infos | awk '{print "hpc=" $1 "
> > sec=" $3 " cyl=" $5}'` if [ -z "$hpc" -o -z
> > "$sec" -o -z "$cyl" -o -z "$csz" ]; then echo "
> > [ FAIL ]"
> > echo "$0: can't get infos for device
> > $DEVICE" >&2 rm -rf $TMPDOC
> > exit
> > fi
> > echo " [ OK ]"
> >
> > echo -n "initializing partition table "
> > #dd if=/dev/zero of=$DEVICE bs=$csz count=1
> > >/dev/null 2>&1 dd if=$BT1 of=$DEVICE
> > >/dev/null 2>&1 round=128
> > tocyl=`expr $hpc '*' $sec '*' $csz`
> > ret=`expr $MSize % $tocyl`
> > MSize=`expr $MSize / $tocyl`
> > test "$ret" -eq "0" || MSize=`expr $MSize +
> > 1` s2len=$MSize
> > s2off=`expr $cyl - $s2len - 1`
> > s1len=`expr $s2off - 1`
> > s1off=1
> > sfdisk -DLqf $DEVICE >/dev/null 2>&1 < > $s1off $s1len b
> > $s2off $s2len a5 *
> > EOF
> > echo " [ OK ]"
> >
> > echo -n "formatting FAT32 partition   "
> > dd if=/dev/zero of=${DEVICE}1 bs=$csz
> > count=1 >/dev/null 2>&1 mkdosfs -i 42424242 -n
> > "Docs" -F 32 ${DEVICE}1 >/dev/null 2>&1 mount
> > -t vfat ${DEVICE}1 $TMPDOC || ERR=1 if [ "$ERR"
> > ]; then
> > echo " [ FAIL ]"
> > echo "$0: unable to mount ${DEVICE}1 on
> > $TMPDOC" rm -rf $TMPDOC
> > exit
> > fi
> > echo " [ OK ]"
> >
> > echo -n "copying documentation files  "
> > cp -rp $DOCDIR/* $TMPDOC/ >/dev/null 2>&1
> > || ERR=2 if [ "$ERR" ]; then
> > echo " [ FAIL ]"
> > echo "$0: unable to copy doc files"
> > ERR=
> > fi
> > umount ${DEVICE}1
> > echo " [ OK ]"
> >
> > echo -n "copying system   "
> > dd if=$ISO_FILE of=${DEVICE}2 status=noxfer
> > >/dev/null 2>&1 echo " [ OK ]"
> >
> > mbrsig $DEVICE 2>&1 | awk '{print "
> > marking device with serial " $3 }'
> > echo " [

Re: Making bootable USB keys

2009-09-03 Thread Fbsd1

Samuel Martín Moro wrote:

Hello

I'm having some troubles, trying to create bootable USB keys.
I found (freebsd-hackers ML archives) a script, supposed to create the
bootable image from my iso file.
But, it still don't boot... (I may do it wrong)

In details:
-We distribute a FreeBSD (4.7, 5.4, 6.2 and 7.2) "custom" server.
-We burn our install CD (and, in a few, our USB sticks) on a Ferdora 9
(sorry...)
-USB sticks must contain a FAT32 partition (we'ld like to provide doc for
windows users)

Well, my english isn't so great... so I'll post my code (more
understandable)



clip 

I have same problem with getting a usb stick to boot. After much testing 
with different sticks and PC combinations have come to this conclusion.


When usb hardware first can out they were created for usb 1.0 standard 
and at that same period PC's where using software drivers for usb 
support and the PC's bio's boot selection did not include option to boot 
from usb disk. As usb devices became more popular PC manufactures 
started adding USB firmware to their motherboards for usb 2.0 standard. 
From my research into usb 2.0 it only supports data recording and does 
not support booting function. About 2007 usb 2.2 standard came out and 
it supports an usb memory stick as bootable. In 2008 some manufactures 
of motherboards added usb 2.2 standard to their motherboards and bio's 
selection to boot from memory stick.


To be bootable the first file on the the stick has to be the boot image. 
 Haveing a ms fat partition first on the stick will never work unless 
you fill it with an bootable ms/windows or ms/dos system or the same 
kind of setup found on the cdrom1 release cd.


Only usb 2.2 memory sticks are bootable on newer PC's that have usb 2.2 
firmware on their motherboards and matching Bio's with selection for 
booting from usb 2.2 memory sticks. Please note that bio's booting 
selection for booting from USB disk is different than booting selection 
for booting from usb memory stick. I have posted many posts on this list 
about this subject and have not received any posts contrary to the above 
statement.


The pending 8.0 release has a complete rewrite of the USB code and a new 
  stick.img is being generated as part of the release install 
distribution's. I can dd the 8.0-stick.img file to an 2.0 stick and it 
never boots, but do the same thing to a 2.2 stick and it boots on all 3 
of my PC manufactured since June 2008.


Final Conclusion: Booting from a USB memory stick successfully is 
totally dependent on using new start-of-the-art hardware.








___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: Making bootable USB keys

2009-09-04 Thread Samuel Martín Moro
In fact, we provide the servers and the keys.
So we're sure everything will work.

And also, our install CD is already able to create this kind of USB stick.
It was a former co-worker who did it.
I started mine looking its. But most of used commands haven't exact
equivalent under linux (and I fucking hate sfdisk and counting in
cylinders!)

Here's an example of a generated stick:
h2g2:~# fdisk da0
*** Working on device /dev/da0 ***
parameters extracted from in-core disklabel are:
cylinders=493 heads=255 sectors/track=63 (16065 blks/cyl)

parameters to be used for BIOS calculations are:
cylinders=493 heads=255 sectors/track=63 (16065 blks/cyl)

Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 11 (0x0b),(DOS or Windows 95 with 32 bit FAT)
start 63, size 6602652 (3223 Meg), flag 0
beg: cyl 0/ head 1/ sector 1;
end: cyl 410/ head 254/ sector 63
The data for partition 2 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
start 6602715, size 1317330 (643 Meg), flag 80 (active)
beg: cyl 411/ head 0/ sector 1;
end: cyl 492/ head 254/ sector 63
The data for partition 3 is:

The data for partition 4 is:

h2g2:~#



Samuel Martín Moro
CamTrace
{EPITECH.} tek4



On Fri, Sep 4, 2009 at 6:31 AM, Fbsd1  wrote:

> Samuel Martín Moro wrote:
>
>> Hello
>>
>> I'm having some troubles, trying to create bootable USB keys.
>> I found (freebsd-hackers ML archives) a script, supposed to create the
>> bootable image from my iso file.
>> But, it still don't boot... (I may do it wrong)
>>
>> In details:
>> -We distribute a FreeBSD (4.7, 5.4, 6.2 and 7.2) "custom" server.
>> -We burn our install CD (and, in a few, our USB sticks) on a Ferdora 9
>> (sorry...)
>> -USB sticks must contain a FAT32 partition (we'ld like to provide doc for
>> windows users)
>>
>> Well, my english isn't so great... so I'll post my code (more
>> understandable)
>>
>>
> clip 
>
> I have same problem with getting a usb stick to boot. After much testing
> with different sticks and PC combinations have come to this conclusion.
>
> When usb hardware first can out they were created for usb 1.0 standard and
> at that same period PC's where using software drivers for usb support and
> the PC's bio's boot selection did not include option to boot from usb disk.
> As usb devices became more popular PC manufactures started adding USB
> firmware to their motherboards for usb 2.0 standard. From my research into
> usb 2.0 it only supports data recording and does not support booting
> function. About 2007 usb 2.2 standard came out and it supports an usb memory
> stick as bootable. In 2008 some manufactures of motherboards added usb 2.2
> standard to their motherboards and bio's selection to boot from memory
> stick.
>
> To be bootable the first file on the the stick has to be the boot image.
>  Haveing a ms fat partition first on the stick will never work unless you
> fill it with an bootable ms/windows or ms/dos system or the same kind of
> setup found on the cdrom1 release cd.
>
> Only usb 2.2 memory sticks are bootable on newer PC's that have usb 2.2
> firmware on their motherboards and matching Bio's with selection for booting
> from usb 2.2 memory sticks. Please note that bio's booting selection for
> booting from USB disk is different than booting selection for booting from
> usb memory stick. I have posted many posts on this list about this subject
> and have not received any posts contrary to the above statement.
>
> The pending 8.0 release has a complete rewrite of the USB code and a new
>  stick.img is being generated as part of the release install distribution's.
> I can dd the 8.0-stick.img file to an 2.0 stick and it never boots, but do
> the same thing to a 2.2 stick and it boots on all 3 of my PC manufactured
> since June 2008.
>
> Final Conclusion: Booting from a USB memory stick successfully is totally
> dependent on using new start-of-the-art hardware.
>
>
>
>
>
>
>
>
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: Making bootable USB keys

2009-09-04 Thread Samuel Martín Moro
Hello

So, for the hexdump problem (files that begin differently), I found that
status=noxfer isn't a correct dd option on FreeBSD... (yeah, and writting
scripts with `>/dev/null 2>&1' isn't such a good idea...)

I tested back, it failed again.
I used a generated stick (by our FreeBSD script) to compare with mine.

da0 (mine) / da1 (good)
da0s2 and da1s2 are (nearly) the same for 8192b (the start of daXs2a)
then, da0s2a is:
1e80  00 00 00 04 00 ff ff ff  ff 2f 7c 5c 2d 00 00 00
|./|\-...|
1e90  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
||
*
2000  00 00 00 00 00 00 00 00  20 00 00 00 30 00 00 00  |
...0...|
2010  38 00 00 00 48 00 00 00  00 00 00 00 ff ff ff ff
|8...H...|
2020  b9 db a0 4a 58 af 11 00  7e a8 11 00 2b 00 00 00
|...JX...~...+...|

and da1s2a is:
1e80  00 00 00 04 00 ff ff ff  ff 2f 7c 5c 2d 00 00 00
|./|\-...|
1e90  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
||
*
2000  72 32 45 69 a2 45 71 4b  d3 2c f5 2e e9 82 28 cd
|r2Ei.EqK.,(.|
2010  b6 d4 02 b1 e2 34 51 36  76 c5 b5 22 4a 0e 4b aa
|.4Q6v.."J.K.|
2020  b5 54 71 3e a5 c7 36 8a  52 b9 77 a9 18 6c f3 e9
|.Tq>..6.R.w..l..|

I searched into my generated file, there's no "r2Ei".

I'll post updates.
(But if you can help ... ^^)


Thanks!

Samuel Martín Moro
CamTrace
{EPITECH.} tek4



On Fri, Sep 4, 2009 at 9:51 AM, Samuel Martín Moro wrote:

> In fact, we provide the servers and the keys.
> So we're sure everything will work.
>
> And also, our install CD is already able to create this kind of USB stick.
> It was a former co-worker who did it.
> I started mine looking its. But most of used commands haven't exact
> equivalent under linux (and I fucking hate sfdisk and counting in
> cylinders!)
>
> Here's an example of a generated stick:
> h2g2:~# fdisk da0
> *** Working on device /dev/da0 ***
> parameters extracted from in-core disklabel are:
> cylinders=493 heads=255 sectors/track=63 (16065 blks/cyl)
>
> parameters to be used for BIOS calculations are:
> cylinders=493 heads=255 sectors/track=63 (16065 blks/cyl)
>
> Media sector size is 512
> Warning: BIOS sector numbering starts with sector 1
> Information from DOS bootblock is:
> The data for partition 1 is:
> sysid 11 (0x0b),(DOS or Windows 95 with 32 bit FAT)
> start 63, size 6602652 (3223 Meg), flag 0
> beg: cyl 0/ head 1/ sector 1;
> end: cyl 410/ head 254/ sector 63
> The data for partition 2 is:
> sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
> start 6602715, size 1317330 (643 Meg), flag 80 (active)
> beg: cyl 411/ head 0/ sector 1;
> end: cyl 492/ head 254/ sector 63
> The data for partition 3 is:
> 
> The data for partition 4 is:
> 
> h2g2:~#
>
>
>
> Samuel Martín Moro
> CamTrace
> {EPITECH.} tek4
>
>
>
> On Fri, Sep 4, 2009 at 6:31 AM, Fbsd1  wrote:
>
>> Samuel Martín Moro wrote:
>>
>>> Hello
>>>
>>> I'm having some troubles, trying to create bootable USB keys.
>>> I found (freebsd-hackers ML archives) a script, supposed to create the
>>> bootable image from my iso file.
>>> But, it still don't boot... (I may do it wrong)
>>>
>>> In details:
>>> -We distribute a FreeBSD (4.7, 5.4, 6.2 and 7.2) "custom" server.
>>> -We burn our install CD (and, in a few, our USB sticks) on a Ferdora 9
>>> (sorry...)
>>> -USB sticks must contain a FAT32 partition (we'ld like to provide doc for
>>> windows users)
>>>
>>> Well, my english isn't so great... so I'll post my code (more
>>> understandable)
>>>
>>>
>> clip 
>>
>> I have same problem with getting a usb stick to boot. After much testing
>> with different sticks and PC combinations have come to this conclusion.
>>
>> When usb hardware first can out they were created for usb 1.0 standard and
>> at that same period PC's where using software drivers for usb support and
>> the PC's bio's boot selection did not include option to boot from usb disk.
>> As usb devices became more popular PC manufactures started adding USB
>> firmware to their motherboards for usb 2.0 standard. From my research into
>> usb 2.0 it only supports data recording and does not support booting
>> function. About 2007 usb 2.2 standard came out and it supports an usb memory
>> stick as bootable. In 2008 some manufactures of motherboards added usb 2.2
>> standard to their motherboards and bio's selection to boot from memory
>> stick.
>>
>> To be bootable the first file on the the stick has to be the boot image.
>>  Haveing a ms fat partition first on the stick will never work unless you
>> fill it with an bootable ms/windows or ms/dos system or the same kind of
>> setup found on the cdrom1 release cd.
>>
>> Only usb 2.2 memory sticks are bootable on newer PC's that have usb 2.2
>> firmware on their motherboards and matching Bio's with selection for booting
>> from usb 2.2 memory sticks. Please note that bio's booting selection for
>> booting from USB disk is different than booting selection for booting from
>> us

Re: Making bootable USB keys

2009-09-04 Thread Daniel O'Connor
WARNING: This e-mail has been altered by MIMEDefang.  Following this
paragraph are indications of the actual changes made.  For more
information about your site's MIMEDefang policy, contact
Postmaster .  For more information about MIMEDefang, 
see:

http://www.roaringpenguin.com/mimedefang/enduser.php3

An attachment named makeusb.sh was removed from this document as it
constituted a security hazard.  If you require this document, please contact
the sender and arrange an alternate means of receiving it.

On Fri, 4 Sep 2009, Samuel Martín Moro wrote:
> I'm having some troubles, trying to create bootable USB keys.
> I found (freebsd-hackers ML archives) a script, supposed to create
> the bootable image from my iso file.
> But, it still don't boot... (I may do it wrong)
>
> In details:
> -We distribute a FreeBSD (4.7, 5.4, 6.2 and 7.2) "custom" server.
> -We burn our install CD (and, in a few, our USB sticks) on a Ferdora
> 9 (sorry...)
> -USB sticks must contain a FAT32 partition (we'ld like to provide doc
> for windows users)
>
> Well, my english isn't so great... so I'll post my code (more
> understandable)

I use the attached script (on FreeBSD :) to prep a USB stick for 
booting.

I imagine you could munge it into your setup without too much trouble.

-- 
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C


signature.asc
Description: This is a digitally signed message part.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Re: Making bootable USB keys

2009-09-04 Thread Daniel O'Connor
On Fri, 4 Sep 2009, Daniel O'Connor wrote:
> WARNING: This e-mail has been altered by MIMEDefang.  Following this
> paragraph are indications of the actual changes made.  For more
> information about your site's MIMEDefang policy, contact
> Postmaster .  For more information about
> MIMEDefang, see:
>
> http://www.roaringpenguin.com/mimedefang/enduser.php3
>
> An attachment named makeusb.sh was removed from this document as it
> constituted a security hazard.  If you require this document, please
> contact the sender and arrange an alternate means of receiving it.

Oops try this http://www.gsoft.com.au/~doconnor/makeusb.sh

-- 
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C


signature.asc
Description: This is a digitally signed message part.


Re: Making bootable USB keys

2009-09-05 Thread Matthias Luft
Dimitri Yioulos wrote:
> Might want to try UNetbootin.

There is also a similar script -- but the related tutorial is a german one:
http://wiki.bsdforen.de/howto/cd_iso_to_usb

so long,
Matthias



smime.p7s
Description: S/MIME Cryptographic Signature


Re: Making bootable USB keys

2009-09-05 Thread Fbsd1

Samuel Martín Moro wrote:

In fact, we provide the servers and the keys.
So we're sure everything will work.

And also, our install CD is already able to create this kind of USB stick.


I am just curious.
What manufacture / model and GB size of USB stick are you using?
When you plug the USB stick into a FreeBSD system what version of the 
USB standard is used in the firmware on the USB stick (1.0, 2.0 or 2.2)?
The firmware USB version standard used by the stick is displayed when 
the stick is first plugged into a Freebsd release 7.2

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"