thanks to merdely and someone whose email i lost for some pointers
i got tired of rolling my own install CDs and wasting CD-Rs, so i wanted to make my flash key bootable, and be able to install openbsd from it. but, i also wanted to be able to use it for storage too
from the somewhere (your system, ftp, etc) get:
if your system is older and you want a newer version on the usb key, either upgrade (long time) or grab baseXY.tgz and bsd.rd from ftp, then extract /usr/mdec/boot & /usr/mdec/biosboot from baseXY.tgz
general overview
on with it!
zero out the flash drive (if needed)
dd if=/dev/zero of=/dev/rsd0c bs=32k
then, make sure we get a completely fresh disk to work with by using fdisk -i
$ sudo fdisk -i sd0
-----------------------------------------------------
------ ATTENTION - UPDATING MASTER BOOT RECORD ------
-----------------------------------------------------
Do you wish to write new MBR and partition table? [n] y
use fdisk to create partitions
$ sudo fdisk -e sd0
Enter 'help' for information
fdisk: 1> p m
Disk: sd0 geometry: 124/255/63 [974 Megabytes]
Offset: 0 Signature: 0xAA55
Starting Ending LBA Info:
#: id C H S - C H S [ start: size ]
------------------------------------------------------------------------
0: 00 0 0 0 - 0 0 0 [ 0: 0M] unused
1: 00 0 0 0 - 0 0 0 [ 0: 0M] unused
2: 00 0 0 0 - 0 0 0 [ 0: 0M] unused
*3: A6 0 1 1 - 123 254 63 [ 63: 973M] OpenBSD
we want 2 partitions. one that is fat32 (type 06) and another that is ffs (type A6). the fat32 partition will be used for general storage and the ffs partition will be used to house the openbsd installer. the openbsd partition must start at the 32nd sector on the disk (C/H/S - 0/0/32)
fdisk:*1> p m Disk: sd0 geometry: 124/255/63 [974 Megabytes] Offset: 0 Signature: 0xAA55 Starting Ending LBA Info: #: id C H S - C H S [ start: size ] ------------------------------------------------------------------------ 0: 06 1 5 37 - 123 254 63 [ 16416: 965M] DOS > 32MB 1: 00 0 0 0 - 0 0 0 [ 0: 0M] unused 2: 00 0 0 0 - 0 0 0 [ 0: 0M] unused *3: A6 0 0 33 - 1 5 36 [ 32: 8M] OpenBSD
we need to make the openbsd partition bootable, which we can do from within fdisk using the 'flag' command as such. a bootable ("Active") partition is noted with an * in front of the partition number, so if you see something like:
3: A6 0 0 34 - 16 4 37 [ 33: 8M] OpenBSDyou need to make it active, which you can do with the 'flag' command within fdisk
fdisk:*1> flag 3 Partition 3 marked active. fdisk:*1> p m Disk: sd0 geometry: 1978/16/63 [974 Megabytes] Offset: 0 Signature: 0xAA55 Starting Ending LBA Info: #: id C H S - C H S [ start: size ] ------------------------------------------------------------------------ 0: 06 1 5 37 - 123 254 63 [ 16416: 965M] DOS > 32MB 1: 00 0 0 0 - 0 0 0 [ 0: 0M] unused 2: 00 0 0 0 - 0 0 0 [ 0: 0M] unused *3: A6 0 0 33 - 1 5 36 [ 32: 8M] OpenBSD write the partition info to the disk and exit from fdisk using 'quit' fdisk:*1> quit Writing current MBR to disk.
now, we need to edit the disklabel.
$ sudo disklabel -e sd0
# /dev/rsd0c: type: SCSI disk: SCSI disk label: U3 Cruzer Micro flags: bytes/sector: 512 sectors/track: 63 tracks/cylinder: 255 sectors/cylinder: 16065 cylinders: 124 total sectors: 1994385 rpm: 3600 interleave: 1 trackskew: 0 cylinderskew: 0 headswitch: 0 # microseconds track-to-track seek: 0 # microseconds drivedata: 0 16 partitions: # size offset fstype [fsize bsize cpg] a: 16384 32 unused 0 0 # Cyl 0*-1* c: 1994385 0 unused 0 0 # Cyl 0 - 124* i: 1975644 16416 unused # Cyl 1*- 123
we need to set the fstypes for 'a' and 'i'. 'a' is our openbsd partition, or 4.2BSD. 'i' is our general storage partition, so we'll set MSDOS by adding the total sizes for the 'a' and 'i' partitions, you should equal the number in the 'c' partition. if you are short, you can squeeze out a little more space for storage by adding the difference to the size for 'i' in other words, some algebra
S = SIZE; O = OFFSET iS = cS - (aO + aS)
16 partitions: # size offset fstype [fsize bsize cpg] a: 16384 32 4.2BSD 0 0 # Cyl 0*-1* c: 1994385 0 unused 0 0 # Cyl 0 - 124* i: 1977969 16416 MSDOS # Cyl 1*- 123
once you are done squeezing out all of the extra space, save that to disk by doing a :wq from within vi (assuming that's the editor you're using)
now, let's format the partitions
(openbsd partition, /dev/rsd0a)
$ sudo newfs /dev/rsd0a /dev/rsd0a: 8.0MB in 16384 sectors of 512 bytes 4 cylinder groups of 2.00MB, 128 blocks, 256 inodes each super-block backups (for fsck -b #) at: 32, 4128, 8224, 12320,(msdos partition, /dev/rsd0i)
$ sudo newfs /dev/rsd0i /dev/rsd0i: 1974080 sectors in 246760 FAT32 clusters (4096 bytes/cluster) bps=512 spc=8 res=32 nft=2 mid=0xf8 spt=63 hds=255 hid=16416 bsec=1977969 bspf=1928 rdcl=2 infs=1 bkbs=2
now, we need to start populating our disk with stuff. mount our 'a' partition, and copy files (bsd.rd and boot to it)
$ sudo /sbin/mount /dev/sd0a /mnt $ sudo cp bsd.rd boot /mnt $ ls /mnt bsd.rd boot
but, we want bsd.rd elsewhere on the disk so we don't have to play any boot.conf magic,so, as merdely suggests, simply:
$ sudo mv /mnt/bsd.rd /mnt/bsdno magic stuff needed. continuing ...
now, we need to use installboot to install the first (biosboot) and second (boot) stage boot programs. we'll do a dry run (using -n) to make sure everything is ok first
$ sudo /usr/mdec/installboot -nv /mnt/boot /usr/mdec/biosboot sd0 boot: /mnt/boot proto: /usr/mdec/biosboot device: /dev/rsd0c /usr/mdec/biosboot: entry point 0 proto bootblock size 512 /mnt/boot is 3 blocks x 16384 bytes fs block shift 2; part offset 32; inode block 24, offset 936 using MBR partition 3: type 166 (0xa6) offset 32 (0x20) $ sudo /usr/mdec/installboot -v /mnt/boot /usr/mdec/biosboot sd0 boot: /mnt/boot proto: /usr/mdec/biosboot device: /dev/rsd0c /usr/mdec/biosboot: entry point 0 proto bootblock size 512 /mnt/boot is 3 blocks x 16384 bytes fs block shift 2; part offset 32; inode block 24, offset 936 using MBR partition 3: type 166 (0xa6) offset 32 (0x20)
take note of that last line. the 'offset 32 (0x21)' part in particular. 32 should match whatever the offset is for your 'a' partition from disklabel
now, unmount /mnt and reboot your target computer with the key plugged in. as long as your computer supports booting from usb thumb drives, you should be good to go