Re: Installation from USB pen
- From: Brooks Davis <brooks@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 22 Mar 2006 08:54:45 -0800
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.
The size of the ufs image is calculated from the iso one. The usage for
the script is quite simple:
./fbsd-install-iso2img.sh iso-path img-path
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.
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.
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
--
Dario Freni (saturnero@xxxxxxxxxxxx)
FreeSBIE developer (http://www.freesbie.org)
GPG Public key at http://www.saturnero.net/saturnero.asc
#!/bin/sh
# You can set some variables here. Edit them to fit your needs.
# 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=0
set -u
if [ $# -lt 2 ]; then
echo "Usage: $0 source-iso-path output-img-path"
exit 1
fi
isoimage=$1; shift
imgoutfile=$1; shift
export tmpdir=$(mktemp -d -t fbsdmount)
# Temp file and directory to be used later
export tmpfile=$(mktemp -t bsdmount)
export isodev=$(mdconfig -a -t vnode -f ${isoimage})
echo "#### Building bootable UFS image ####"
ISOSIZE=$(du -k ${isoimage} | awk '{print $1}')
SECTS=$((($ISOSIZE + ($ISOSIZE/5))*2))
# Root partition size
echo "Initializing image..."
dd if=/dev/zero of=${imgoutfile} count=${SECTS}
ls -l ${imgoutfile}
export imgdev=$(mdconfig -a -t vnode -f ${imgoutfile})
bsdlabel -w -B ${imgdev}
newfs -O1 /dev/${imgdev}a
mkdir -p ${tmpdir}/iso ${tmpdir}/img
mount -t cd9660 /dev/${isodev} ${tmpdir}/iso
mount /dev/${imgdev}a ${tmpdir}/img
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
#echo "/dev/ufs/${UFS_LABEL} / ufs ro 1 1" > ${tmpdir}/img/etc/fstab
if [ ${serial} -eq 2 ]; then
echo "-D" > ${tmpdir}/img/boot.config
echo 'console="comconsole, vidconsole"' >> ${tmpdir}/img/boot/loader.conf
elif [ ${serial} -eq 1 ]; then
echo "-h" > ${tmpdir}/img/boot.config
echo 'console="comconsole"' >> ${tmpdir}/img/boot/loader.conf
fi
cleanup() {
umount ${tmpdir}/iso
mdconfig -d -u ${isodev}
umount ${tmpdir}/img
mdconfig -d -u ${imgdev}
rm -rf ${tmpdir} ${tmpfile}
}
cleanup
ls -lh ${imgoutfile}
--
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
Attachment:
pgpEz474Db0s6.pgp
Description: PGP signature
- Follow-Ups:
- Re: Installation from USB pen
- From: Dario Freni
- Re: Installation from USB pen
- References:
- Installation from USB pen
- From: Dario Freni
- Installation from USB pen
- Prev by Date: dlopen() and dlclose() are not MT-safe?
- Next by Date: Re: dlopen() and dlclose() are not MT-safe?
- Previous by thread: Installation from USB pen
- Next by thread: Re: Installation from USB pen
- Index(es):
Relevant Pages
- Installation from USB pen
... The size of the ufs image is calculated from the iso one. ... the script
is quite simple: ... you can dd the img directly to an USB pen. ... want to make
a serial-console install image just set the serial variable ... (freebsd-hackers) - Re: Installation from USB pen
... The size of the ufs image is calculated from the iso one. ... the script
is quite simple: ... you can dd the img directly to an USB pen. ... want to make
a serial-console install image just set the serial variable ... (freebsd-hackers) - RE: Disabling USB mass storage
... > registry on each to disable usb drive creation. ... As part of your script,
have it report back on the status. ... customer machines, but everything we do has to be
deployable on a very large ... > We tried restricting usbstor.sys through the GPO, ...
(Focus-Microsoft) - Re: USB hotplug woes
... The goal is that if someone where to stick in an USB flash drive, ... The script
basically initializes the network, ... Further more I tried the 2.6 kernel and the
machine just went nuts only ... Do you want the script to autorun whe the usb device is
pluged in? ... (Debian-User) - A bit OT, but this issue about FAT patented by MS is not a real one to be worried about, some experi
... Got myself one of those multi-card adapters (an Imation Flash Go). ... Wrote
a script ot automatically mounts it in Linux. ... (That should work with any type card
this adapter accepts). ... For a good big size movie you need USB 2. ... (comp.os.linux.development.apps)