lkml.org 
[lkml]   [1999]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectUFS/Disklabel strangeness
Date
Hi all

I've been poking around the UFS/Disklabel code in an attempt to read a
Jaz disk formatted under FreeBSD. The UFS code is fine - the trouble is
that the disklabel code has trouble registering the BSD partition's
existance.

The jaz disk in question had been formatted under FreeBSD using
disklabel -rwB sd0 auto
newfs sd0c

As far as i can tell, the w flag with the B flag causes a bootstrap to be
written to sector 0 of the disk which *includes* a dummy fdisk partition
table. When FreeBSD fdisk is executed on the resulting disk, one gets
%/sbin/fdisk /dev/sd0
******* Working on device /dev/sd0 *******
parameters extracted from in-core disklabel are:
cylinders=1021 heads=64 sectors/track=32 (2048 blks/cyl)

parameters to be used for BIOS calculations are:
cylinders=1021 heads=64 sectors/track=32 (2048 blks/cyl)

Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
<UNUSED>
The data for partition 2 is:
<UNUSED>
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
sysid 165,(FreeBSD/NetBSD/386BSD)
start 0, size 50000 (24 Meg), flag 80
beg: cyl 0/ sector 1/ head 0;
end: cyl 1023/ sector 63/ head 255

In addition, subsequent disklabel commands under FreeBSD give
%/sbin/disklabel /dev/sd0
# /dev/sd0:
type: unknown
disk:
label:
flags:
bytes/sector: 512
sectors/track: 32
tracks/cylinder: 64
sectors/cylinder: 2048
cylinders: 1021
sectors/unit: 2091050
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0 # milliseconds
track-to-track seek: 0 # milliseconds
drivedata: 0

3 partitions:
# size offset fstype [fsize bsize bps/cpg]
c: 2091050 0 unused 0 0 # (Cyl. 0 -1021*)

and this is what is visible to Linux's disklabel/partitioning code.
Therefore detection of the FreeBSD filesystem fails on 2 counts:
1) the disklabel "partition" used by newfs is marked as not in use
2) the linux code in check_and_add_bsd_partition() detects an apparent
overlap of partitions (between the BSD partition and those defined in
the disklabel) and exits without doing anything

If the kernel is hacked to ignore these 2 issues, the resulting partition
(on /dev/sda5) mounts as ufs and is quite usable.

(1) is not too hard to circumvent - a few lines of (non-kernel) source code
can fix that. (2) is a problem through. Looking through the code, the
overlap test will cause nothing to be done if a disklabel partition is equal
to a partition-table partition in addition to the overlap trouble already
mentioned so simply resetting the partition table to include the whole disk
won't help. Therefore I'm not sure what exactly to do here
- is the kernel at fault and if so, how can the code be rewritten
consistantly? The type of the partition isn't visible to
check_and_add_bsd_partition(); is it safe to ignore such overlaps?
- if BSD is at fault, how can the disk be set up to allow Linux to read it?

A related fault is that this jaz disk's disklabel can't be read under Linux
fdisk since
Partition /dev/sda4 has invalid starting sector 0
according to fdisk. It could be argued though that this is a result of
the bogus fdisk partition entry so i'm not all that fussed about it.

Comments and suggestions welcome, even if i've missed something obvious. :)

jonathan
--
* Jonathan Woithe jwoithe@physics.adelaide.edu.au *
* http://www.physics.adelaide.edu.au/~jwoithe/home.html *
***-----------------------------------------------------------------------***
** "Time is an illusion; lunchtime doubly so" **
* "...you wouldn't recognize a subtle plan if it painted itself purple *
* and danced naked on a harpsicord singing 'subtle plans are here again'" *

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:50    [W:0.023 / U:1.352 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site