Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Mar 2006 08:54:45 -0800
From:      Brooks Davis <brooks@one-eyed-alien.net>
To:        Dario Freni <saturnero@freesbie.org>
Cc:        hackers@freebsd.org
Subject:   Re: Installation from USB pen
Message-ID:  <20060322165445.GA19647@odin.ac.hmc.edu>
In-Reply-To: <4420AF56.60106@freesbie.org>
References:  <4420AF56.60106@freesbie.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--qMm9M+Fa2AknHoGS
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Mar 22, 2006 at 02:58:46AM +0100, Dario Freni wrote:
> Hi everybody,
> attached a tiny script to convert a FreeBSD install iso image to a
> binary ufs image ready to be flashed e.g. on an USB pendrive.
>=20
> The size of the ufs image is calculated from the iso one. The usage for
> the script is quite simple:
>=20
> ./fbsd-install-iso2img.sh iso-path img-path
>=20
> Once you're done, you can dd the img directly to an USB pen. If you also
> want to make a serial-console install image just set the serial variable
> on top of the script to 1.
>=20
> This script is derived from another similar one that I made for the
> pfSense project. It was requested for those kind of systems which have
> an usb port booting-capable and a serial console.
>=20
> I hope you'll find it useful. Bye,

Way cool!  We've to tons of boxes that are a complete pain is the ass to
install on via CD, this will save tons of time.  Obviously, it would be
better it we made one of these as part of the release build and put it
on the ftp site, but this is a hugh step in the right direction.

One minor nit, you might want to put a check that the user is root at the
top of the script since that is a requirement.

> P.S.: beer-ware license

Are you going to be at BSDCan. :)

-- Brooks

> --=20
> Dario Freni (saturnero@freesbie.org)
> FreeSBIE developer (http://www.freesbie.org)
> GPG Public key at http://www.saturnero.net/saturnero.asc

> #!/bin/sh
>=20
> # You can set some variables here. Edit them to fit your needs.
>=20
> # Set serial variable to 0 if you don't want serial console at all,
> # 1 if you want comconsole and 2 if you want comconsole and vidconsole
> serial=3D0
>=20
> set -u
>=20
> if [ $# -lt 2 ]; then
>     echo "Usage: $0 source-iso-path output-img-path"
>     exit 1
> fi
>=20
> isoimage=3D$1; shift
> imgoutfile=3D$1; shift
>=20
> export tmpdir=3D$(mktemp -d -t fbsdmount)
> # Temp file and directory to be used later
> export tmpfile=3D$(mktemp -t bsdmount)
>=20
> export isodev=3D$(mdconfig -a -t vnode -f ${isoimage})
>=20
> echo "#### Building bootable UFS image ####"
>=20
> ISOSIZE=3D$(du -k ${isoimage} | awk '{print $1}')
> SECTS=3D$((($ISOSIZE + ($ISOSIZE/5))*2))
>=20
> # Root partition size
>=20
> echo "Initializing image..."
> dd if=3D/dev/zero of=3D${imgoutfile} count=3D${SECTS}
> ls -l ${imgoutfile}
> export imgdev=3D$(mdconfig -a -t vnode -f ${imgoutfile})
>=20
> bsdlabel -w -B ${imgdev}
> newfs -O1 /dev/${imgdev}a
>=20
> mkdir -p ${tmpdir}/iso ${tmpdir}/img
>=20
> mount -t cd9660 /dev/${isodev} ${tmpdir}/iso
> mount /dev/${imgdev}a ${tmpdir}/img
>=20
> echo "Copying files to the image..."
> ( cd ${tmpdir}/iso && find . -print -depth | cpio -dump ${tmpdir}/img )
> #bzcat ${tmpdir}/iso/dist/root.dist.bz2 | mtree -PUr -p ${tmpdir}/img 2>&=
1 > /dev/null
>=20
> #echo "/dev/ufs/${UFS_LABEL} / ufs ro 1 1" > ${tmpdir}/img/etc/fstab
>=20
> if [ ${serial} -eq 2 ]; then
>         echo "-D" > ${tmpdir}/img/boot.config
>         echo 'console=3D"comconsole, vidconsole"' >> ${tmpdir}/img/boot/l=
oader.conf
> elif [ ${serial} -eq 1 ]; then
>         echo "-h" > ${tmpdir}/img/boot.config
>         echo 'console=3D"comconsole"' >> ${tmpdir}/img/boot/loader.conf
> fi
>=20
> cleanup() {
>     umount ${tmpdir}/iso
>     mdconfig -d -u ${isodev}
>     umount ${tmpdir}/img
>     mdconfig -d -u ${imgdev}
>     rm -rf ${tmpdir} ${tmpfile}
> }
>=20
> cleanup
>=20
> ls -lh ${imgoutfile}


--=20
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4

--qMm9M+Fa2AknHoGS
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFEIYFUXY6L6fI4GtQRAjglAJ95vlX+Oqm4y6SmG5DFOxUKyzwpKACgs4np
sFF2M/YQ3FbfMmBNZaXfwHg=
=8rHe
-----END PGP SIGNATURE-----

--qMm9M+Fa2AknHoGS--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060322165445.GA19647>