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 12-18-2015, 10:58 AM   #1
aaazen
Member
 
Registered: Dec 2009
Location: California
Distribution: Slackware
Posts: 305

Rep: Reputation: 138Reputation: 138
FreeBSD - linux kernel: sda3: <bsd:bad subpartition - ignored


Linux kernel 4.4-rc5 does not recognize FreeBSD partitions on MSDOS slices.

I have FreeBSD 10.2 installed on Linux /dev/sda3 (FreeBSD slice 3).

When booting up Linux this message is displayed in /var/log/messages:

kernel: sda3: <bsd:bad subpartition - ignored

The problem is that FreeBSD slices use relative block addressing for partitions but the code assumes absolute block addressing which works for OpenBSD and NetBSD slices.

There is a simple Linux patch that fixes the FreeBSD slices on kernel 4.4-rc5.

Code:
--- block/partitions/msdos.c.orig	2015-12-13 17:42:58.000000000 -0800
+++ block/partitions/msdos.c	2015-12-17 18:32:21.832267195 -0800
@@ -300,6 +300,9 @@
 			continue;
 		bsd_start = le32_to_cpu(p->p_offset);
 		bsd_size = le32_to_cpu(p->p_size);
+		if (memcmp(flavour,"bsd\0",4) == 0) {
+			bsd_start = bsd_start + offset;
+		}
 		if (offset == bsd_start && size == bsd_size)
 			/* full parent partition, we have it already */
 			continue;
After applying the Linux kernel patch and rebooting, I now see this in /var/log/messages:

kernel: sda3: <bsd: sda21 sda22 sda23 sda24 >

and I can now mount the first FreeBSD "a" partition like this:

#mount -t ufs -o ro,ufstype=ufs2 /dev/sda21 /fbsd

The patch should work for older versions of Linux probably back to version 3.7 or earlier.

Last edited by aaazen; 12-18-2015 at 11:02 AM. Reason: mention FreeBSD version
 
Old 12-20-2015, 08:14 AM   #2
aaazen
Member
 
Registered: Dec 2009
Location: California
Distribution: Slackware
Posts: 305

Original Poster
Rep: Reputation: 138Reputation: 138
I tested the patch against Linux 3.10.94 and it works fine there too.
 
Old 12-22-2015, 09:11 AM   #3
aaazen
Member
 
Registered: Dec 2009
Location: California
Distribution: Slackware
Posts: 305

Original Poster
Rep: Reputation: 138Reputation: 138
The patch is posted to the Linux kernel bug system, bugzilla.kernel.org

https://bugzilla.kernel.org/show_bug.cgi?id=109761
 
Old 12-29-2015, 03:47 PM   #4
aaazen
Member
 
Registered: Dec 2009
Location: California
Distribution: Slackware
Posts: 305

Original Poster
Rep: Reputation: 138Reputation: 138
Here is a "prettier" version of the patch.
(based on recommendations from the Linux scripts/checkpatch.pl perl script)

Code:
--- linux/block/partitions/msdos.c.orig	2015-12-27 18:17:37.000000000 -0800
+++ linux/block/partitions/msdos.c	2015-12-29 10:44:25.813773357 -0800
@@ -300,6 +300,8 @@ static void parse_bsd(struct parsed_part
 			continue;
 		bsd_start = le32_to_cpu(p->p_offset);
 		bsd_size = le32_to_cpu(p->p_size);
+		if (memcmp(flavour, "bsd\0", 4) == 0)
+			bsd_start = bsd_start + offset;
 		if (offset == bsd_start && size == bsd_size)
 			/* full parent partition, we have it already */
 			continue;
If anyone tests this patch can you let me know?
 
Old 05-29-2017, 07:45 AM   #5
aaazen
Member
 
Registered: Dec 2009
Location: California
Distribution: Slackware
Posts: 305

Original Poster
Rep: Reputation: 138Reputation: 138
Fixed in Linux-4.12-rc3

This is now fixed in Linux-4.12-rc3 thanks to Christoph Hellwig, Jens Axboe and of course Linus.
 
Old 11-07-2017, 10:36 AM   #6
aaazen
Member
 
Registered: Dec 2009
Location: California
Distribution: Slackware
Posts: 305

Original Poster
Rep: Reputation: 138Reputation: 138
New patch...

I was overly optimistic in my assessment of the patch working with older versions of FreeBSD. I works with version 10 and 11 but not with version 6...

Here is a newer patch:
Code:
--- a/block/partitions/msdos.c.orig	2017-11-05 13:05:14.000000000 -0800
+++ b/block/partitions/msdos.c	2017-11-06 09:46:00.148228242 -0800
@@ -301,7 +301,9 @@ static void parse_bsd(struct parsed_part
  			continue;
  		bsd_start = le32_to_cpu(p->p_offset);
  		bsd_size = le32_to_cpu(p->p_size);
-		if (memcmp(flavour, "bsd\0", 4) == 0)
+		/* FreeBSD has relative offset if C partition offset is zero */
+		if (memcmp(flavour, "bsd\0", 4) == 0 &&
+		    le32_to_cpu(l->d_partitions[2].p_offset) == 0)
  			bsd_start += offset;
  		if (offset == bsd_start && size == bsd_size)
  			/* full parent partition, we have it already */
 
  


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
LXer: Arch BSD: Arch Linux Atop The FreeBSD Kernel LXer Syndicated Linux News 0 01-24-2013 04:20 PM
LXer: FreeBSD/PC-BSD 9.1 Benchmarked Against Linux, Solaris, BSD LXer Syndicated Linux News 0 12-19-2012 07:31 PM
Linux Slackware Vs BSD freeBSD LordNikonPT Linux - Newbie 1 09-06-2004 11:52 PM
bad subpartition ignored ?? what's that ? Miky Linux - General 0 06-08-2004 05:46 AM

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

All times are GMT -5. The time now is 09:24 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration