Subject: Re: Apple UFS support and swap partition
To: Rob Newberry <robthedude@mac.com>
From: Darrin B.Jewell <dbj@netbsd.org>
List: port-macppc
Date: 03/21/2005 17:09:45
Rob Newberry <robthedude@mac.com> writes:

> 1) Does NetBSD REQUIRE a swap partition?

No.  It can run without swap or use a swapfile in the filesystem.
Create a file using dd and add it to the fstab like this:
  /var/swapfile none swap sw 0 0
or use the swapon command to add it by hand.  See the swapon(8)
and fstab(5) man pages for more details.

> 
> 2) What's the state of Apple UFS support in NetBSD-2.0 and/or later?
> I'm trying to use NetBSD-2.0, and I'd like to keep doing that, as
> binaries are available...

It should work, including root.  However, there are some gotchas that
are not really specific to the filesystem that you'll need to handle.

Specifically, the boot process does not conform to the ofw spec and
the kernel support for apple partition maps is burdened by some
legacy issues.  Someday I'd like to get the time to clean some
of this up.  In the meantime however, it can still be made to go.

You can probably tell it to find the kernel from the command line
with something like:
  boot hd:,\ofwboot.xcf hd:10,/netbsd

From looking at the disklabel you included, your apple UFS partition
is showing up as wd0b.  Therefore, when it asks you for a root
partition, tell it that "wd0b".  In order to have it find this
without you having to manually tell it on every boot, you will have
to change this line in your kernel config file:
   config netbsd root on ? type ?
to something like this:
   config netbsd root on wd0b type ? dumps on none
and then recompile your kernel.

A few details of the issues that are hurting you:
  . the kernel doesn't correctly read the booted partition from
  open firmware.  It's currently hard coded to partition `a'
  on line 326 of src/sys/arch/macppc/macppc/autoconf.c

  . the kernel does not parse paths correctly per the ofw spec

  . the kernel internally uses a `disklabel' which is derived from
  the partition map, but does not contain all the pmap partitions,
  or contain them in the same order.  This partition translation
  is ugly and can be found in src/sys/arch/macppc/macppc/disksubr.c

  . boot arguments are not properly read from ofw, and are instead
  extracted from the boot command line.

  . ofwboot doesn't really have support for apple ufs, but you
  are unlikely to hit this as a problem, since the ffs filesystem
  support will do ok most of the time.  This pr port-macppc/23923

I hope this helps.

Darrin


> 
> Here's why I ask...
> 
> I have a disk with NetBSD-2.0 installed on a Apple UFS partition.
> From OpenFirmware, I can load the NetBSD kernel from this UFS
> partition with the following sequence:
> 
> 	boot hd:,\ofwboot.xcf
> 
> 	<blah blah complaint>
> 	open /netbsd: No such file or directory
> 	open /netbsd.gz: No such file or directory
> 	open /netbsd.macppc: No such file or directory
> 	Boot:
> 
> I then enter:
> 
> 	hd:10,/netbsd
> 
> and the NetBSD kernel loads.
> 
> Unfortunately, at the end of the process, I get stuck with the
> following repeating sequence:
> 
> 	cannot mount root, error = 69
> 	root device (default wd0a)
> 	dump device (default wd0b)
> 	file system (default generic)
> 	no file system for wd0 (dev = 0xa00 )
> 	cannot mount root, error = 69
> 	root device (default wd0a)
> 	dump device (default wd0b)
> 	file system (default generic)
> 	no file system for wd0 (dev = 0xa00 )
> 	cannot mount root, error = 69
> 	root device (default wd0a)
> 	dump device (default wd0b)
> 	file system (default generic)
> 	no file system for wd0 (dev = 0xa00 )
> 
> I don't know what it's doing here.
> 
> Here's some more pieces of information, if they're helpful.  If I boot
> from the NetBSD-2.0 CD, I can run the following:
> 
> 	#disklabel wd0
> 	disklabel: Invalid signature in mbr record 0
> 	# /dev/rwd0c:
> 	type: ESDI
> 	disk: Maxtor 53073U6
> 	label: fictitious
> 	flags:
> 	bytes/sector: 512
> 	sectors/track: 63
> 	tracks/cylinder: 16
> 	sectors/cylinder: 1008
> 	cylinders: 59554
> 	total sectors: 60030432
> 	rpm: 3600
> 	interleave: 1
> 	trackskew: 0
> 	cylinderskew: 0
> 	headswitch: 0             #microseconds
> 	track-to-track seek: 0    #microseconds
> 	drivedata: 0
> 
> 	8 partitions:
> 	#     size      offset     fstype [fsize bsize cpg/sgs]
> 	 a:   262144      1824    unknown                     # (Cyl.
> 1*-
> 261*)
> 	 b: 19748032    263968  Apple UFS      0     0      0 # (Cyl.
> 261*-19853*)
> 	 c: 60030432         0     unused      0     0        # (Cyl.
> 0 -59553)
> 	 d: 19748032  20274144        HFS                     #
> (Cyl. 20113*-39704*)
> 	 e:   262144  20012000    unknown                     #
> (Cyl. 19853*-20113*)
> 	 f:   262144  40022176    unknown                     #
> (Cyl. 39704*-39964*)
> 	 g: 19746096  40284320        HFS                     #
> (Cyl. 39964*-59553*)
>       h:       16  60030416    unknown                     #
> (Cyl. 59553*-59553)
> 
> 	# pdisk -l /dev/wd0c
> 	
> 	Partition map (with 512 byte blocks) on '/dev/wd0c'
> 	 #:                type name                    length   base
> ( size )
> 	 1: Apple_partition_map Apple                       63 @ 1
> 	 2:      Apple_Driver43*Macintosh                   56 @ 64
> 	 3:      Apple_Driver43*Macintosh                   56 @ 120
> 	 4:    Apple_Driver_ATA*Macintosh                   56 @ 176
> 	 5:    Apple_Driver_ATA*Macintosh                   56 @ 232
> 	 6:      Apple_FWDriver Macintosh                  512 @ 288
> 	 7:  Apple_Driver_IOKit Macintosh                  512 @ 800
> 	 8:       Apple_Patches Patch Partition            512 @ 1312
> 	 9:          Apple_Free                         262144 @ 1824
> (128.0M)
> 	10:           Apple_UFS Apple_HFS_Untitled_2  19748032 @
> 263968   (  9.4G)
> 	11:          Apple_Free                         262144 @
> 20012000 (128.0M)
> 	12:           Apple_HFS Apple_HFS_Untitled_3  19748032 @
> 20274144 (  9.4G)
> 	13:          Apple_Free                         262144 @
> 40022176 (128.0M)
> 	14:           Apple_HFS Apple_HFS_Untitled_4  19746096 @
> 40284320 (  9.4G)
> 	15:          Apple_Free                             16 @ 60030416
> 
> 	Device block size=512m, Number of Blocks=60030432 (28.6G)
> 	DeviceType=0x0, DeviceID=0x0
> 	Drivers-
> 	1:  23 @ 64, type=0x1
> 	2:  36 @ 120, type=0xffff
> 	3:  21 @ 176, type=0x701
> 	4:  34 @ 232, type=0xf8ff
> 
> 
> 	# mount /dev/wd0b /mnt
> 	# more /mnt/etc/fstab
> 	/dev/wd0b / ffs rw 1 1
> 	
> Now, there are a few things I can think of that I need to see about
> resolving.
> 
> I suspect that at least part of the problem is that the "flags" and
> mount point information isn't set -- "sysinst" has asked me for this
> information in the past, but I can't find a way to edit it (I thought
> pdisk would do that, but I can't seem to get pdisk to give me the
> option of changing flags on a partition).
> 
> Is it possible to boot from an Apple UFS partition, without a swap
> partition?  Can this be made to work?
> 
> Rob