From owner-freebsd-questions@FreeBSD.ORG Fri Feb 29 20:40:53 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3F7FB1065679 for ; Fri, 29 Feb 2008 20:40:53 +0000 (UTC) (envelope-from jeff.gold@gmail.com) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.175]) by mx1.freebsd.org (Postfix) with ESMTP id DAC778FC22 for ; Fri, 29 Feb 2008 20:40:50 +0000 (UTC) (envelope-from jeff.gold@gmail.com) Received: by ug-out-1314.google.com with SMTP id y2so532376uge.37 for ; Fri, 29 Feb 2008 12:40:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=y0o6zRVh7jjRUNdH49uEG+R238YkVOG0ueLxyvClzDQ=; b=X3FWNZbg8F0ZiOsUTHvbLCLVgX9voTj1CX5QLRRr0Q0uRpOgwto9YGf9dH9roAi2CnnwMox4UG/E/uvmZApYf0ekrwVdonL1dXgKuOgWupn9nRLu4BX6EYPiQxNjBtNhV2gn60iFBnbS740SGjEkTOtC+faxTWDTyjRkA6e8VK4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=lTiGu0OzaMaGfO5ArvekSS8KZtZfZVsiAd6Zc0avlOMy9TGoTw+skaPYcfYj5MXhNOJMcwj0CR8zWkLmaCuRWFqR6KgVKlhe7AYvIkL/Al5/ru2W8835Yg4lKffWljZ0P3Tf54NroGWt2Y9ukSMyOQxIYuhXYo8K03FWW+6h4gY= Received: by 10.78.132.2 with SMTP id f2mr10878834hud.37.1204317647642; Fri, 29 Feb 2008 12:40:47 -0800 (PST) Received: by 10.78.72.3 with HTTP; Fri, 29 Feb 2008 12:40:47 -0800 (PST) Message-ID: <4bded9640802291240r14c9b011t19f3734fb229853@mail.gmail.com> Date: Fri, 29 Feb 2008 15:40:47 -0500 From: "Jeff Gold" To: jedrek In-Reply-To: <47C805B8.1040202@t-n-p.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4bded9640802150914x4c868f40ue0f21b8d8e163745@mail.gmail.com> <47C805B8.1040202@t-n-p.org> Cc: freebsd-questions@freebsd.org Subject: Re: Scripting sysinstall X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Feb 2008 20:40:53 -0000 On Fri, Feb 29, 2008 at 8:16 AM, jedrek 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 < $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 <> $DESTDIR/etc/fstab /dev/acd0 /cdrom cd9660 ro,noauto 0 0 EOF fi cat < $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