From owner-freebsd-questions@FreeBSD.ORG Tue Mar 30 17:08:38 2010 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 573281065670 for ; Tue, 30 Mar 2010 17:08:38 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id A9D828FC13 for ; Tue, 30 Mar 2010 17:08:37 +0000 (UTC) X-Spam-Status: No X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-2.9, required 5, autolearn=not spam, ALL_TRUSTED -1.00, BAYES_00 -1.90) X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-ID: o2UH8DpB009897 Received: from kobe.laptop (ppp-94-64-219-161.home.otenet.gr [94.64.219.161]) (authenticated bits=128) by igloo.linux.gr (8.14.3/8.14.3/Debian-9.1) with ESMTP id o2UH8DpB009897 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 30 Mar 2010 20:08:18 +0300 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.4/8.14.4) with ESMTP id o2UH87uc098419 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 30 Mar 2010 20:08:08 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.4/8.14.4/Submit) id o2UFIJr4002875; Tue, 30 Mar 2010 18:18:19 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) From: Giorgos Keramidas To: Jay Hall References: <03658C6E-697A-43C5-9E6D-8B261D18F9A4@socket.net> Date: Tue, 30 Mar 2010 18:18:19 +0300 In-Reply-To: <03658C6E-697A-43C5-9E6D-8B261D18F9A4@socket.net> (Jay Hall's message of "Mon, 29 Mar 2010 10:49:08 -0500") Message-ID: <87eij14z44.fsf@kobe.laptop> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: freebsd-questions@freebsd.org Subject: Re: Custom Kernel to Memory Stick 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: Tue, 30 Mar 2010 17:08:38 -0000 On Mon, 29 Mar 2010 10:49:08 -0500, Jay Hall wrote: > Ladies and Gentlemen, > > I have been asked to explore the possibility of booting FreeBSD from a > memory stick. This was not a problem; worked great when installed from > the distribution CD. > > What would be the best way to get our custom configuration onto the > memory stick? The fastest way I know is to create an image to an 'image' file stored on disk or ramdisk and then dd the image to the USB disk. You can create a suitably large image with truncate(1), e.g.: truncate -s 1g /var/tmp/image.bin Then attach the image to an mdconfig device: mdconfig -a -t vnode -u 20 -f /var/tmp/image.bin Create a filesystem on it, and install everything from your buildworld and buildkernel run: fdisk -BI /dev/md20 bsdlabel -w -B /dev/md20s1 newfs -U /dev/md20s1a Mount the new image partition before installkernel+installworld: mount -t ufs /dev/md20s1a /mnt Then you sould be able to install with DESTDIR pointing to the image partition: cd /usr/src env DESTDIR=/mnt make installkernel installworld Don't forgte to use mergemaster with -D /mnt to install the /mnt/etc files from /usr/src/etc. Then tweak the /mnt/etc/fstab file to point at the USB disk as the root filesystem. Finally detach the image and write it on a USB disk: umount /mnt mdconfig -du 20 dd if=/var/tmp/image.bin of=/dev/da0 bs=4m One of the nice tricks you can use for the root filesystem of the USB disk is to add a UFS label to the USB root filesystem. This way you don't have to assume that the USB root filesystem is called da0s1a but you can use /dev/ufs/LABELNAME in the fstab file of the image partition.