Betrifft OS: |
---|
![]() |
Der folgende Artikel enthält hauptsächlich ein Skript, das FreeBSD-CD-ISO Images in Images für USB-Sticks umwandelt. Damit ist die Erstellung eines bootbaren FreeBSD-Installations-Sticks sehr komfortabel möglich. Da FreeBSD mittlerweile USB-Stick Images anbietet die direkt auf USB-Sticks kopiert werden können (mittels dd) ist es nicht mehr notwendig ein USB-Stick-Image aus der CD zu erzeugen.
Das Skript fbsd2img.sh wird folgendermaßen aufgerufen:
fbsd2img.sh SOURCE DESTINATION
Dabei steht SOURCE für das heruntergeladene CD-ISO, beispielsweise 7.2-RELEASE-i386-bootonly.iso. DEST steht für das zu erstellende USB-Image. Der entsprechende Befehl könnte dementsprechend so aussehen:
fbsd2img.sh 7.2-RELEASE-i386-bootonly.iso 7.2-RELEASE-i386-bootonly.usb
Das so erstellte USB-Image kann per dd auf den USB-Stick übertragen werden:
dd if=7.2-RELEASE-i386-bootonly.usb of=/dev/REPLACE_WITH_TARGET_USB_DEVICE
Nach diesen beiden Befehlen ist der USB-Stick ein voll einsatzfähiges FreeBSD-Installationsmedium :) Getestet mit:
Das folgende Skript ist das oben referenzierte fbsd2img.sh. Hinweise:
#!/bin/sh #Dario Freni #FreeSBIE developer (http://www.freesbie.org) #GPG Public key at http://www.saturnero.net/saturnero.asc # # fbsd-install-iso2img.sh iso-path img-path # 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) # ADJUST TMPDIR HERE! # 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 ) 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}