View Single Post
  #3   (View Single Post)  
Old 31st July 2008
J65nko J65nko is offline
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 3,503
Default III. USB-mediazine® OpenBSD reinstall using 'bsd.rd' and USB memory stick

III. USB-mediazine® OpenBSD reinstall using 'bsd.rd' and USB memory stick
  • Introduction
  • Select 'bsd.rd' for booting
  • Boot messages of the bsd ramdisk kernel
  • Confirm the start of the install
  • Select terminal type and keyboard mapping
  • Partition the disk at MBR level
  • Sub-partition OpenBSD MBR partition with 'disklabel'
  • Network Configuration
  • root password
  • Select USB flash drive device and directory
  • Choose file sets
  • Copying install sets from USB flash drive
  • Miscellaneous configuration
  • Setting timezone
  • Boot block, halt and reboot

The following is a transcript of an install of a recent OpenBSD snapshot on a PC running OpenBSD 3.6. This reinstall is done using a 'bsd.rd' install kernel as described in and with the installation file sets on an USB flash memory drive.

We will use the following procedure to copy the 'bsd.rd' install kernel from the USB stick containing the file sets, to the '/' directory of the OpenBSD 3.6 PC.

After insertion of the USB flash drive, we check 'dmesg' output.
umass0 at uhub0 port 2 configuration 1 interface 0
umass0: Sony Storage Media, rev 2.00/1.00, addr 2
umass0: using SCSI over Bulk-Only
scsibus0 at umass0: 2 targets
sd0 at scsibus0 targ 1 lun 0: <Sony, Storage Media, 0100> SCSI0 0/direct removable
sd0: 1920MB, 1920 cyl, 64 head, 32 sec, 512 bytes/sec, 3932160 sec total
The USB stick has been detected as 'sd0'. Read the partition table with fdisk
$ su - root
Terminal type? [xterm]

# fdisk sd0
fdisk: sysctl(machdep.bios.diskinfo): Device not configured
Disk: sd0       geometry: 1920/64/32 [3932160 Sectors]
Offset: 0       Signature: 0xAA55
         Starting       Ending       LBA Info:
 #: id    C   H  S -    C   H  S [       start:      size   ]
*0: 06    0   1  1 - 1919  63 32 [          32:     3932128 ] DOS > 32MB
 1: 00    0   0  0 -    0   0  0 [           0:           0 ] unused
 2: 00    0   0  0 -    0   0  0 [           0:           0 ] unused
 3: 00    0   0  0 -    0   0  0 [           0:           0 ] unused
Check the disklabel output
# disklabel sd0
disklabel: warning, DOS partition table with no valid OpenBSD partition
# /dev/rsd0c:
type: SCSI
disk: SCSI disk
label: Storage Media
bytes/sector: 512
sectors/track: 32
tracks/cylinder: 64
sectors/cylinder: 2048
cylinders: 1920
total sectors: 3932160
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]
  c:       3932160             0  unused      0     0      # Cyl     0 -  1919
  i:       3932128            32   MSDOS                   # Cyl     0*-  1919
OpenBSD has created a virtual label 'i:' for the MSDOS FAT partition on the USB stick. We know now we will have to mount as 'sd0i'.

Mount the USB stick read-only.
# mount -o ro  /dev/sd0i /mnt
#  mount
/dev/wd0a on / type ffs (local)
/dev/sd0i on /mnt type msdos (local, read-only)
Copy the installation kernel 'bsd.rd' from USB stick to the root directory.
# ls -l /mnt/snap
total 414272
-rwxr-xr-x  1 snap  snap      1019 May 31 06:37 MD5
-rwxr-xr-x  1 snap  snap  42640349 May 31 06:40 base41.tgz
-rwxr-xr-x  1 snap  snap   6113799 May 31 06:39 bsd
-rwxr-xr-x  1 snap  snap   6163453 May 31 06:39
-rwxr-xr-x  1 snap  snap   5017801 May 31 06:39 bsd.rd
-rwxr-xr-x  1 snap  snap  78795861 May 31 06:39 comp41.tgz
-rwxr-xr-x  1 snap  snap   1240407 May 31 06:38 etc41.tgz
-rwxr-xr-x  1 snap  snap   1474560 May 31 06:38 floppy41.fs
-rwxr-xr-x  1 snap  snap   7665620 May 31 06:38 man41.tgz
-rwxr-xr-x  1 snap  snap   2292830 May 31 06:38 misc41.tgz
-rwxr-xr-x  1 snap  snap  11956881 May 31 06:37 xbase41.tgz
-rwxr-xr-x  1 snap  snap     75570 May 31 06:37 xetc41.tgz
-rwxr-xr-x  1 snap  snap  35582512 May 31 06:37 xfont41.tgz
-rwxr-xr-x  1 snap  snap  10347873 May 31 06:37 xserv41.tgz
-rwxr-xr-x  1 snap  snap   2547392 May 31 06:40 xshare41.tgz

# cp /mnt/snap/bsd.rd /

# ls -l /
total 20620
-rw-r--r--   2 root  wheel      770 Sep 17  2004 .cshrc
-rw-r--r--   2 root  wheel      314 Feb  1  2005 .profile
drwxr-xr-x   2 root  wheel      512 Sep 17  2004 altroot
drwxr-xr-x   2 root  wheel     1024 Sep 17  2004 bin
-rw-r--r--   1 root  wheel    42644 Nov  9  2004 boot
-rw-r--r--   1 root  wheel  5358583 Oct 19  2004 bsd
-rw-r--r--   1 root  wheel  5017801 May 31 07:02 bsd.rd
drwxr-xr-x   3 root  wheel    20480 May 31 07:17 dev
drwxr-xr-x  17 root  wheel     2048 May 31 07:52 etc
drwxr-xr-x   3 root  wheel      512 Jan 10  2005 home
drwxr-xr-x   1 root  wheel    16384 Jan  1  1980 mnt
drwx------   3 root  wheel      512 May 31 07:52 root
drwxr-xr-x   2 root  wheel     2048 Sep 17  2004 sbin
drwxr-xr-x   2 root  wheel      512 Sep 17  2004 stand
lrwxr-xr-x   1 root  wheel       11 Nov  9  2004 sys -> usr/src/sys
drwxrwxrwt   2 root  wheel      512 May 31 08:16 tmp
drwxr-xr-x  15 root  wheel      512 Sep 17  2004 usr
drwxr-xr-x  22 root  wheel      512 Sep 17  2004 var
We now can reboot the system to start the install.
# shutdown -r now
Shutdown NOW!
shutdown: [pid 9216]
*** FINAL System shutdown message from j65nko@heraclitus.utp.xnet ***
System going down IMMEDIATELY

System shutdown time has arrived
Select 'bsd.rd' for booting
>> OpenBSD/i386 BOOT 2.06
boot>   /bsd.rd
booting hd0a:/bsd.rd: 4687092+742840 [52+172256+157781]=0x57e58c
entry point at 0x200120
We intervene at the boot> prompt and type '/bsd.rd'. This causes the installation kernel '/bsd.rd' to be started and not the standard '/bsd' kernel. You have 5 seconds to do this.

The safest option is to press the space bar a few times while the system boots. The BIOS will buffer these spaces and those are enough to tell the Second Stage Boot Loader to wait for user input and not to automatically load the default '/bsd' kernel as it is accustomed to. See boot (8) for the details.

Boot messages of the bsd ramdisk kernel
Copyright (c) 1982, 1986, 1989, 1991, 1993
	The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2007 OpenBSD. All rights reserved.

OpenBSD 4.1-current (RAMDISK_CD) #353: Wed May 30 03:23:45 MDT 2007
cpu0: Intel Pentium II ("GenuineIntel" 686-class, 512KB L2 cache) 351 MHz
real mem  = 133787648 (127MB)
avail mem = 122945536 (117MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 07/21/98, BIOS32 rev. 0 @ 0xfb280
apm0 at bios0: Power Management spec V1.2
apm0: flags 70102 dobusy 1 doidle 1
pcibios0 at bios0: rev 2.1 @ 0xf0000/0xb6f8
pcibios0: PCI IRQ Routing Table rev 1.0 @ 0xfdd10/144 (7 entries)
pcibios0: PCI Exclusive IRQs: 10 11
pcibios0: PCI Interrupt Router at 000:07:0 ("Intel 82371SB ISA" rev 0x00)
pcibios0: PCI bus #1 is the last bus
bios0: ROM list: 0xc0000/0x8000
cpu0 at mainbus0
pci0 at mainbus0 bus 0: configuration mode 1 (no bios)
pchb0 at pci0 dev 0 function 0 "Intel 82443BX AGP" rev 0x02
ppb0 at pci0 dev 1 function 0 "Intel 82443BX AGP" rev 0x02
pci1 at ppb0 bus 1
pcib0 at pci0 dev 7 function 0 "Intel 82371AB PIIX4 ISA" rev 0x02
pciide0 at pci0 dev 7 function 1 "Intel 82371AB IDE" rev 0x01: DMA, channel 0 wired to
 compatibility, channel 1 wired to compatibility
wd0 at pciide0 channel 0 drive 0: <ST32122A>
wd0: 16-sector PIO, LBA, 2014MB, 4124736 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2
pciide0: channel 1 disabled (no drives)
uhci0 at pci0 dev 7 function 2 "Intel 82371AB USB" rev 0x01: irq 11
"Intel 82371AB Power" rev 0x02 at pci0 dev 7 function 3 not configured
vga1 at pci0 dev 10 function 0 "S3 ViRGE DX/GX" rev 0x01
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
xl0 at pci0 dev 12 function 0 "3Com 3c905B 100Base-TX" rev 0x64: irq 11, address 00:50:04:50:5b:d1
bmtphy0 at xl0 phy 24: Broadcom 3C905B internal PHY, rev. 0
isa0 at pcib0
isadma0 at isa0
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
npx0 at isa0 port 0xf0/16: reported by CPUID; using exception 16
pccom0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
pccom0: console
pccom1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo
fdc0 at isa0 port 0x3f0/6 irq 6 drq 2
fd0 at fdc0 drive 0: 1.44MB 80 cyl, 2 head, 18 sec
usb0 at uhci0: USB revision 1.0
uhub0 at usb0
uhub0: Intel UHCI root hub, rev 1.00/1.00, addr 1
uhub0: 2 ports with 2 removable, self powered
biomask ffe5 netmask ffe5 ttymask ffe7
rd0: fixed, 3800 blocks
umass0 at uhub0 port 2 configuration 1 interface 0
umass0: Sony Storage Media, rev 2.00/1.00, addr 2
umass0: using SCSI over Bulk-Only
scsibus0 at umass0: 2 targets
sd0 at scsibus0 targ 1 lun 0: <Sony, Storage Media, 0100> SCSI0 0/direct removable
sd0: 1920MB, 244 cyl, 255 head, 63 sec, 512 bytes/sec, 3932160 sec total
dkcsum: wd0 matches BIOS drive 0x80
Note that the Sony USB flash drive has been detected.

Confirm the start of the install
root on rd0a swap on rd0b dump on rd0b
erase ^?, werase ^W, kill ^U, intr ^C, status ^T
(I)nstall, (U)pgrade or (S)hell? i
We want an install so we press 'i'.
Welcome to the OpenBSD/i386 4.1 install program.

This program will help you install OpenBSD. At any prompt except password
prompts you can escape to a shell by typing '!'. Default answers are shown
in []'s and are selected by pressing RETURN.  At any time you can exit this
program by pressing Control-C, but exiting during an install can leave your
system in an inconsistent state.
Select terminal type and keyboard mapping
Terminal type? [vt220] Enter
kbd(8) mapping? ('L' for list) [none] Enter
Partition the disk at MBR level
IS YOUR DATA BACKED UP? As with anything that modifies disk contents, this
program can cause SIGNIFICANT data loss.

It is often helpful to have the installation notes handy. For complex disk
configurations, relevant disk hardware manuals and a calculator are useful.

Proceed with install? [no] yes
We get a change to back out here. Of course we continue.
Cool! Let's get to it.

You will now initialize the disk(s) that OpenBSD will use. To enable all
available security features you should configure the disk(s) to allow the
creation of separate filesystems for /, /tmp, /var, /usr, and /home.

Available disks are: wd0 sd0.
'wd0' is the hard disk we want to install on, 'sd0' is our USB flash drive with the installation file sets. Be aware that USB and SCSI disks use the same 'sd?' naming convention.
Which one is the root disk? (or 'done') [done] wd0
Do you want to use *all* of wd0 for OpenBSD? [no] yes
Putting all of wd0 into an active OpenBSD MBR partition (type 'A6')...done.
Because in our case, OpenBSD will be the only OS we just leave everything to the installation program.

Sub-partition OpenBSD MBR partition with 'disklabel'
You will now create an OpenBSD disklabel inside the OpenBSD MBR
Partition. The disklabel defines how OpenBSD splits up the MBR partition
into OpenBSD partitions in which filesystems and swap space are created.

The offsets used in the disklabel are ABSOLUTE, i.e. relative to the
start of the disk, NOT the start of the OpenBSD MBR partition.

# Inside MBR partition 3: type A6 start 63 size 4124673

Treating sectors 63-4124736 as the OpenBSD portion of the disk.
You can use the 'b' command to change this.

Initial label editor (enter '?' for help at any prompt)
> p
device: /dev/rwd0c
type: ESDI
disk: ESDI/IDE disk
label: ST32122A
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 16
sectors/cylinder: 1008
cylinders: 4092
total sectors: 4124736
free sectors: 0
rpm: 3600

16 partitions:
#	      size	  offset  fstype [fsize bsize  cpg]
  a:	   3999681	      63  4.2BSD   2048 16384  328
  b:	    124992	 3999744    swap
  c:	   4124736	       0  unused      0	    0
> help
Available commands:
	? [cmnd]  - this message or command specific help.
	a [part]  - add new partition.
	b	  - set OpenBSD disk boundaries.
	c [part]  - change partition size.
	D	  - set label to default.
	d [part]  - delete partition.
	e	  - edit drive parameters.
	g [d|u]	  - use [d]isk or [u]ser geometry.
	M	  - show entire OpenBSD man page for disklabel.
	m [part]  - modify existing partition.
	n [part]  - set the mount point for a partition.
	p [unit]  - print label.
	q	  - quit and save changes.
	r	  - recalculate free space.
	s [path]  - save label to file.
	u	  - undo last change.
	w	  - write label to disk.
	X	  - toggle expert mode.
	x	  - exit without saving changes.
	z	  - zero out partition table.
Numeric parameters may use suffixes to indicate units:
	'b' for bytes, 'c' for cylinders, 'k' for kilobytes, 'm' for megabytes,
	'g' for gigabytes or no suffix for sectors (usually 512 bytes).
	'%' for percent of total disk size, '&' for percent of free space.
	Non-sector units will be rounded to the nearest cylinder.
Entering '?' at most prompts will give you (simple) context sensitive help.
> q
No label changes.
Because we want to keep the existing labelled partitions we just type 'q' to preserve them.
Available disks are: sd0.
Which one do you wish to initialize? (or 'done') [done] done
We get a chance to work with another disk. 'sd0' is our USB flash drive with our installation files. We don't want that to be touched, so we indicate that we are done.
OpenBSD filesystems:
wd0a /

The next step *DESTROYS* all existing data on these partitions!
Are you really sure that you're ready to proceed? [no] yes
/dev/rwd0a: 1953.0MB in 3999680 sectors of 512 bytes
10 cylinder groups of 202.47MB, 12958 blocks, 25984 inodes each
/dev/wd0a on /mnt type ffs (rw, asynchronous, local, ctime=Thu May 31 06:11:57 2007)
Our disk has been initialized with a new filesystem. We now will do the TCP/IP configuration.

Network Configuration
System hostname? (short form, e.g. 'foo') diogenes
Configure the network? [yes] Enter
Available interfaces are: xl0.
Which one do you wish to initialize? (or 'done') [xl0] Enter
Symbolic (host) name for xl0? [diogenes] Enter
The media options for xl0 are currently
	media: Ethernet autoselect (100baseTX full-duplex)
Do you want to change the media options? [no] Enter
IPv4 address for xl0? (or 'none' or 'dhcp')
Netmask? [] Enter
IPv6 address for xl0? (or 'rtsol' or 'none') [none] Enter
No more interfaces to initialize.
DNS domain name? (e.g. '') [my.domain] utp.xnet
DNS nameserver? (IP address or 'none') [none]
Use the nameserver now? [yes] Enter
Default IPv4 route? (IPv4 address, 'dhcp' or 'none')
add net default: gateway
Edit hosts with ed? [no] Enter
Do you want to do any manual network configuration? [no] Enter
root password
Password for root account? (will not echo)
Password for root account? (again)
The installer does not provide opportunity to create an user account. You are only asked for the password for the root account.

Select USB flash drive device and directory
Let's install the sets!
Location of sets? (disk ftp http or 'done') [disk] Enter
Is the disk partition already mounted? [no] Enter
Available disks are: wd0 sd0.
Which one contains the install media? (or 'done') [wd0] sd0
Pathname to the sets? (or 'done') [4.1/i386] snap
INSTALL.i386 not found. Use sets found here anyway? [no] yes
We select the USB flash drive, detected as sd0 and the directory 'snap' containing the file sets.

Choose file sets
Select sets by entering a set name, a file name pattern or 'all'. De-select
sets by prepending a '-' to the set name, file name pattern or 'all'. Selected
sets are labelled '[X]'.

	[X] bsd
	[X] bsd.rd
	[ ]
	[X] base41.tgz
	[X] etc41.tgz
	[X] misc41.tgz
	[X] comp41.tgz
	[X] man41.tgz
	[ ] xbase41.tgz
	[ ] xetc41.tgz
	[ ] xshare41.tgz
	[ ] xfont41.tgz
	[ ] xserv41.tgz
Set name? (or 'done') [] x*

	[X] bsd
	[X] bsd.rd
	[ ]
	[X] base41.tgz
	[X] etc41.tgz
	[X] misc41.tgz
	[X] comp41.tgz
	[X] man41.tgz
	[X] xbase41.tgz
	[X] xetc41.tgz
	[X] xshare41.tgz
	[X] xfont41.tgz
	[X] xserv41.tgz
Set name? (or 'done') [] done
The installer has found the sets on the USB drive. We add the file sets for the X Window system.

Copying install sets from USB flash drive
Ready to install sets? [yes] Enter
Getting bsd ...
100% |**************************************************|  5970 KB    00:06 ETA
Getting bsd.rd ...
100% |**************************************************|  4900 KB    00:05 ETA
Getting base41.tgz ...
100% |**************************************************| 41640 KB    00:56 ETA
Getting etc41.tgz ...
100% |**************************************************|  1211 KB    00:02 ETA
Getting misc41.tgz ...
100% |**************************************************|  2239 KB    00:02 ETA
Getting comp41.tgz ...
100% |**************************************************| 76949 KB    01:30 ETA
Getting man41.tgz ...
100% |**************************************************|  7485 KB    00:11 ETA
Getting xbase41.tgz ...
100% |**************************************************| 11676 KB    00:14 ETA
Getting xetc41.tgz ...
100% |**************************************************| 75570	      00:00 ETA
Getting xshare41.tgz ...
100% |**************************************************|  2487 KB    00:07 ETA
Getting xfont41.tgz ...
100% |**************************************************| 34748 KB    00:52 ETA
Getting xserv41.tgz ...
100% |**************************************************| 10105 KB    00:14 ETA
Location of sets? (disk ftp http or 'done') [disk] done
Additional opportunity to retrieve sets from another source. 'games41.tgz' or 'site41.tgz' for example. But we are done.

Miscellaneous configuration
Start sshd(8) by default? [yes] Enter
NTP server? (or 'none' or 'default') [none]
Do you expect to run the X Window System? [no] yes
Change the default console to com0? [no] yes
Available speeds are: 9600 19200 38400 57600 115200.
Which one should com0 use? (or 'done') [9600] Enter
Saving configuration files...done.
Generating initial host.random file...done.
Setting timezone
What timezone are you in? ('?' for list) [Canada/Mountain] ?
Africa/	     Chile/	  GB-Eire      Israel	    NZ-CHAT	 UCT
America/     Cuba	  GMT	       Jamaica	    Navajo	 US/
Antarctica/  EET	  GMT+0	       Japan	    PRC		 UTC
Arctic/	     EST	  GMT-0	       Kwajalein    PST8PDT	 Universal
Asia/	     EST5EDT	  GMT0	       Libya	    Pacific/	 W-SU
Atlantic/    Egypt	  Greenwich    MET	    Poland	 WET
Australia/   Eire	  HST	       MST	    Portugal	 Zulu
Brazil/	     Etc/	  Hongkong     MST7MDT	    ROC		 posix/
CET	     Europe/	  Iceland      Mexico/	    ROK		 posixrules
CST6CDT	     Factory	  Indian/      Mideast/	    Singapore	 right/
Canada/	     GB		  Iran	       NZ	    Turkey
What timezone are you in? ('?' for list) [Canada/Mountain] Europe

What sub-timezone of 'Europe' are you in? ('?' for list) > ?
Amsterdam    Chisinau	  Kiev	       Moscow	    Sarajevo	 Vatican
Andorra	     Copenhagen	  Lisbon       Nicosia	    Simferopol	 Vienna
Athens	     Dublin	  Ljubljana    Oslo	    Skopje	 Vilnius
Belfast	     Gibraltar	  London       Paris	    Sofia	 Volgograd
Belgrade     Guernsey	  Luxembourg   Podgorica    Stockholm	 Warsaw
Berlin	     Helsinki	  Madrid       Prague	    Tallinn	 Zagreb
Bratislava   Isle_of_Man  Malta	       Riga	    Tirane	 Zaporozhye
Brussels     Istanbul	  Mariehamn    Rome	    Tiraspol	 Zurich
Bucharest    Jersey	  Minsk	       Samara	    Uzhgorod
Budapest     Kaliningrad  Monaco       San_Marino   Vaduz

What sub-timezone of 'Europe' are you in? ('?' for list) Ansterdan
'Europe/Ansterdan' is not a valid timezone on this system.
What timezone are you in? ('?' for list) [Canada/Mountain] Europe/Amsterdam
Setting local timezone to 'Europe/Amsterdam'...done.
I made a typo, so my choice was rejected. You see it is also possible to set the timezone and sub-timezone in one go.

Boot block, halt and reboot
Making all device nodes...done.
Installing boot block...
boot: /mnt/boot
proto: /usr/mdec/biosboot
device: /dev/rwd0c
/usr/mdec/biosboot: entry point 0
proto bootblock size 512
/mnt/boot is 3 blocks x 16384 bytes
fs block shift 2; part offset 63; inode block 24, offset 1576
using MBR partition 3: type 166 (0xa6) offset 63 (0x3f)

CONGRATULATIONS! Your OpenBSD install has been successfully completed!
To boot the new system, enter halt at the command prompt. Once the
system has halted, reset the machine and boot from the disk.
# halt
syncing disks... done

The operating system has halted.
Please press any key to reboot.
Type halt and press a key to reboot

$Id: usb-install.xml,v 1.8 2007/06/26 23:15:09 j65nko Exp $
$Id: vbul-html.xsl,v 1.6 2007/06/27 04:49:57 j65nko Exp $
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote