Date: Fri, 29 Feb 2008 15:40:47 -0500 From: "Jeff Gold" <jeff.gold@gmail.com> To: jedrek <jedrek@t-n-p.org> Cc: freebsd-questions@freebsd.org Subject: Re: Scripting sysinstall Message-ID: <4bded9640802291240r14c9b011t19f3734fb229853@mail.gmail.com> In-Reply-To: <47C805B8.1040202@t-n-p.org> References: <4bded9640802150914x4c868f40ue0f21b8d8e163745@mail.gmail.com> <47C805B8.1040202@t-n-p.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Feb 29, 2008 at 8:16 AM, jedrek <jedrek@t-n-p.org> wrote:
> Have you considered partitioning the disk manually with fdisk & bsdlabel and [...]
Not only have I considered it, I've done it! I've been meaning to
post a follow up message to explain exactly how in case other people
are stuck in the same place but hadn't got around to it yet. Below is
the shell script I'm using to create a bootable FreeBSD system. I've
tested it successfully under QEMU and plan to try it on real hardware
soon. This was indeed much easier to write that than to figure out
why sysinstall doesn't work. Thanks for the link. I'll read it and
see if there's anything in there I can use to improve my script.
Jeff
#! /bin/sh
set -ex
disk=${1:-ad0}
source=${2:-`echo /usr/pressgang/*-RELEASE | head -1`}
dd if=/dev/zero of=/dev/$disk bs=1k count=1
fdisk -BI $disk
bsdlabel -B -w ${disk}s1 auto
size=`fdisk -s $disk | sed -En 's,^ *1: *[0-9]+ *([0-9]+) .*,\1,p'`
used=0
slice() {
letter=${1?missing letter}; shift
percent=${1?missing percent}; shift
fixed=${1?missing fixed}; shift
fstype=${1?missing fstype}; shift
if [ x$fixed = xG ]; then
ssize=`expr $percent \* 2097152`
else
ssize=`expr $size / 100 \* $percent`
fi
if expr $ssize \> $size - $used >/dev/null; then
ssize=`expr $size - $used`
fi
echo $letter: $ssize $used $fstype $*
used=`expr $used + $ssize`
}
echo "8 partitions:" > /tmp/bsdlabel.conf
slice a 1 G 4.2BSD 2048 16384 32776 >> /tmp/bsdlabel.conf
slice b 2 G swap >> /tmp/bsdlabel.conf
echo "c: $size 0 unused 0 0" >> /tmp/bsdlabel.conf
slice d 10 p 4.2BSD 2048 16384 28552 >> /tmp/bsdlabel.conf
slice e 15 p 4.2BSD 2048 16384 8 >> /tmp/bsdlabel.conf
slice f 100 p 4.2BSD 2048 16384 28552 >> /tmp/bsdlabel.conf
bsdlabel -R ${disk}s1 /tmp/bsdlabel.conf
rm -f /tmp/bsdlabel.conf
newfs /dev/${disk}s1a
newfs /dev/${disk}s1d
newfs /dev/${disk}s1e
newfs -U /dev/${disk}s1f
DESTDIR=/mnt
export DESTDIR
mount /dev/${disk}s1a $DESTDIR
mkdir -p $DESTDIR/usr $DESTDIR/tmp $DESTDIR/var
mount /dev/${disk}s1d $DESTDIR/usr
mount /dev/${disk}s1e $DESTDIR/tmp
mount /dev/${disk}s1f $DESTDIR/var
for dist in base dict doc manpages ports; do
cd $source/$dist
yes | ./install.sh >/dev/null
# stdout goes to null so that obnoxious install questions are
# not visible to the user, who might mistake them for something
# that requires a response.
done
cd $source/kernels
./install.sh GENERIC
rmdir $DESTDIR/boot/kernel
mv $DESTDIR/boot/GENERIC $DESTDIR/boot/kernel
cat <<EOF > $DESTDIR/etc/fstab
# device mountpoint fstype options dump pass
/dev/${disk}s1b none swap sw 0 0
/dev/${disk}s1a / ufs rw 1 1
/dev/${disk}s1d /usr ufs rw 2 2
/dev/${disk}s1e /tmp ufs rw 2 2
/dev/${disk}s1f /var ufs rw 2 2
EOF
if [ -e /dev/acd0 ]; then
mkdir -p $DESTDIR/cdrom
cat <<EOF >> $DESTDIR/etc/fstab
/dev/acd0 /cdrom cd9660 ro,noauto 0 0
EOF
fi
cat <<EOF > $DESTDIR/etc/rc.conf
# FIXME: something should go in here.
EOF
cd $source/packages/All
cp *.tbz $DESTDIR/
chroot $DESTDIR pkg_add dependencies-*.tbz
rm -f $DESTDIR/*.tbz
umount $DESTDIR/var
umount $DESTDIR/tmp
umount $DESTDIR/usr
umount $DESTDIR
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4bded9640802291240r14c9b011t19f3734fb229853>
