On 09/06/12 12:01, Thomas Jeunet wrote:
On Wed, Sep 5, 2012 at 9:36 AM, Ted Unangst <t...@tedunangst.com> wrote:
We provide many forms of installation media, but neither floppy nor
iso images are "best" suited for usb drives.  It's pretty easy to make
a hard drive image containing the installer bsd.rd.

I tested this on i386, it should work on amd64 too.  It's just a bunch
of shell commands, save it to makeimage.sh or whatever.  Maybe we
could integrate this into the distrib build makefiles, but I wanted to
get a procedure done first.  I don't know what the best way to get a
disklabel on is, I just dumped a tiny bit of text into a file.

It's actually very similar to what builds the install.iso, but I
didn't do it as a makefile for now so it's easier for standalone users
to run.

It assumes you have a working bsd.rd in /.  If you wanted to build
amd64 on i386, or vice versa, you'll have to fiddle with the files.

#!/bin/sh
set -e
cp /bsd.rd .
gzip -9 bsd.rd
dd if=/dev/zero bs=1k count=3584 of=disk.img
sudo vnconfig vnd0 disk.img
sudo fdisk -y -i vnd0
echo "16 partitions:" > disklabel.txt
echo "#                size           offset  fstype [fsize bsize  cpg]" >> 
disklabel.txt
echo "  a:             6944              128  4.2BSD   2048 16384    1" >> 
disklabel.txt
echo "  c:             7168                0  unused" >> disklabel.txt
disklabel -R vnd0 disklabel.txt
newfs -i 512000 vnd0a
mount /dev/vnd0a /mnt
cp bsd.rd.gz /mnt/bsd
cp /usr/mdec/boot /mnt/boot
/usr/mdec/installboot /mnt/boot /usr/mdec/biosboot vnd0
umount /mnt
vnconfig -u vnd0
rm bsd.rd.gz
rm disklabel.txt


Here's a version without the disklabel file, using EXAMPLES section
from softraid(4).

I modified gzip invocation to avoid handling temporary files, but I
end up wondering if it's worth it...
I also added missing sudo invocation


#!/bin/sh
set -e
dd if=/dev/zero bs=1k count=3584 of=disk.img
sudo vnconfig vnd0 disk.img
sudo fdisk -y -i vnd0
printf "a\n\n\n\n\nw\nq\n\n" | sudo disklabel -E vnd0
sudo newfs -i 512000 vnd0a
sudo mount /dev/vnd0a /mnt
gzip -9 -c /bsd.rd | sudo tee /mnt/bsd >/dev/null
sudo cp /usr/mdec/boot /mnt/boot
sudo /usr/mdec/installboot /mnt/boot /usr/mdec/biosboot vnd0
sudo umount /mnt
sudo vnconfig -u vnd0

All this sudo'ing makes my head spin.

Just run the script as root and remove the tee workaround.

/Alexander

Reply via email to