LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > *BSD
User Name
Password
*BSD This forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.

Notices


Reply
  Search this Thread
Old 01-16-2013, 05:20 AM   #1
Vilius
Member
 
Registered: Jan 2006
Location: Lithuania
Distribution: Arch, Debian
Posts: 193

Rep: Reputation: 16
OpenBSD fdisk - Linux fdisk compatibility ?


Hello,

MBR partition table made by linux fdisk looks certainly not correct when printed by openbsd fdisk:

Partition table created on linux (centos 6.3):
Code:
# fdisk -l /dev/sdc

Disk /dev/sdc: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x61f77373

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1         131     1052226   83  Linux
/dev/sdc2             132         262     1052257+  83  Linux
/dev/sdc4             263        1305     8377897+   5  Extended
/dev/sdc5             263         523     2096451   8e  Linux LVM
/dev/sdc6             524         784     2096451   8e  Linux LVM
/dev/sdc7             785        1045     2096451   a6  OpenBSD

Same disk on OpenBSD (5.2):
Code:
# fdisk sd1
Disk: sd1       geometry: 1305/255/63 [20971520 Sectors]
Offset: 0       Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
 0: 83      0   1   1 -    130 254  63 [          63:     2104452 ] Linux files*
 1: 83    131   0   1 -    261 254  63 [     2104515:     2104515 ] Linux files*
 2: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
 3: 05    262   0   1 -   1304 254  63 [     4209030:    16755795 ] Extended DOS
Offset: 4209030 Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
 0: 8E    262   1   1 -    522 254  63 [     4209093:     4192902 ] Linux LVM
 1: 05    523   0   1 -    783 254  63 [     8401995:     4192965 ] Extended DOS
 2: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
 3: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
Offset: 8401995 Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
 0: 8E    523   1   1 -    783 254  63 [     8402058:     4192902 ] Linux LVM
 1: 05    784   0   1 -   1044 254  63 [    12594960:     4192965 ] Extended DOS
 2: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
 3: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
Offset: 12594960        Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
 0: A6    784   1   1 -   1044 254  63 [    12595023:     4192902 ] OpenBSD
 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
OpenBSD fdisk shows separate 4 partition block for extended partition, but result above shows 4 4-partition blocks(instead of 2).

If I create same partition table on OpenBSD from scratch:
Code:
# fdisk sd1
Disk: sd1       geometry: 1305/255/63 [20971520 Sectors]
Offset: 0       Signature: 0x0
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
 0: 83      0   1   1 -    130 254  63 [          63:     2104452 ] Linux files*
 1: 83    131   0   1 -    261 254  63 [     2104515:     2104515 ] Linux files*
 2: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
 3: 05    262   0   1 -   1304 254  63 [     4209030:    16755795 ] Extended DOS
Offset: 4209030 Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
 0: 8E    262   1   1 -    522 254  63 [     4209093:     4192902 ] Linux LVM
 1: 83    523   1   1 -    783 254  63 [     8402058:     4192902 ] Linux files*
 2: A6    784   1   1 -   1044 254  63 [    12595023:     4192902 ] OpenBSD
 3: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
Now if we connect that disk to linux partition table is not recognized:
Code:
# fdisk -l /dev/sdb

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

#

Why this is happening ?
How do I create partition table compatible between two OSes ?

thanks
Vilius M.
 
Old 01-16-2013, 08:00 PM   #2
aaazen
Member
 
Registered: Dec 2009
Posts: 358

Rep: Reputation: Disabled
Quote:
Originally Posted by Vilius View Post
Partition table created on linux (centos 6.3):
# fdisk -l /dev/sdc

Disk /dev/sdc: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
...
The Linux fdisk is showing units in "cylinders" but the OpenBSD fdisk is showing "sectors".

To get the Linux fdisk to show sectors use the "-u=sectors" option:

#fdisk -l -u=sectors /dev/sdc
 
Old 01-17-2013, 08:02 AM   #3
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,882

Rep: Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988
I suggest you read-up on how extended partitions actually work (they're a horrible ugly kludge). The first OpenBSD example was correct. The partition table for extended/logical partitions doesn't work the same way as the MBR partition table. Each logical partition has it's own partition table and it will be defined by entry no 0 in that table. Entry number 1 points to the next logical partition's partition table, and so on forming a chain. Entry 2 and 3 in these partition tables are not used and should always be empty.

Linux's disk partitioning tools hide this from the user, OpenBSDs does not.

When you created it by hand, you've created an invalid structure, which is why you can't see it from linux fdisk.


Personally, for a dual-boot setup, I'd be inclined to use cfdisk from linux for a quick and easy way to setup the partitions and skip the fdisk step from the openbsd installer and get straight on with the labelling.


Also, I wouldn't recommend trying to put the OpenBSD partition in a logical partition (I'm not even sure that is supported). It really belongs in one of the four primary partitions..

Last edited by GazL; 01-17-2013 at 08:20 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use Fdisk in Linux ? gardenair Linux - Newbie 8 06-03-2011 09:42 AM
understadning /dev/dm-02 mapping and fdisk -l or fdisk -l | less mixxmaster27 Linux - Newbie 2 06-03-2010 12:17 PM
Replacing fdisk with gnu fdisk in busybox? Alkisx Slackware 5 10-23-2009 11:51 AM
weird fdisk problem (Fdisk unable to see winxp partitions) khidot Slackware - Installation 5 04-07-2007 09:26 PM
fdisk in linux antken Linux - General 1 01-22-2001 07:00 AM

LinuxQuestions.org > Forums > Other *NIX Forums > *BSD

All times are GMT -5. The time now is 01:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration