3

I have attached a FreeBSD disk to my Linux machine. How to detect if the disklabel(aka bsdlabel) is on the first sector of the disk or the PC MBR is on the first sector of the disk and disklabel is nested inside the primary partition of the PC MBR? fdisk tells following:

T42 ~ # fdisk -lu /dev/sdc
This disk has both DOS and BSD magic.
Give the 'b' command to go to BSD mode.

Disk /dev/sdc: 256 MB, 256901120 bytes
8 heads, 32 sectors/track, 1960 cylinders, total 501760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *          32      187903       93936   a5  FreeBSD
T42 ~ # 

First 512 bytes of the disk can be seen below:

T42 ~ # dd if=/dev/sdc count=1 | hexdump -C
00000000  fc 31 c0 8e c0 8e d8 8e  d0 bc 00 7c be 1a 7c bf  |.1.........|..|.|
00000010  1a 06 b9 e6 01 f3 a4 e9  00 8a 31 f6 bb be 07 b1  |..........1.....|
00000020  04 38 2f 74 08 7f 78 85  f6 75 74 89 de 80 c3 10  |.8/t..x..ut.....|
00000030  e2 ef 85 f6 75 02 cd 18  80 fa 80 72 0b 8a 36 75  |....u......r..6u|
00000040  04 80 c6 80 38 f2 72 02  8a 14 89 e7 8a 74 01 8b  |....8.r......t..|
00000050  4c 02 bb 00 7c 80 fe ff  75 32 83 f9 ff 75 2d 51  |L...|...u2...u-Q|
00000060  53 bb aa 55 b4 41 cd 13  72 20 81 fb 55 aa 75 1a  |S..U.A..r ..U.u.|
00000070  f6 c1 01 74 15 5b 66 6a  00 66 ff 74 08 06 53 6a  |...t.[fj.f.t..Sj|
00000080  01 6a 10 89 e6 b8 00 42  eb 05 5b 59 b8 01 02 cd  |.j.....B..[Y....|
00000090  13 89 fc 72 0f 81 bf fe  01 55 aa 75 0c ff e3 be  |...r.....U.u....|
000000a0  bc 06 eb 11 be d4 06 eb  0c be f3 06 eb 07 bb 07  |................|
000000b0  00 b4 0e cd 10 ac 84 c0  75 f4 eb fe 49 6e 76 61  |........u...Inva|
000000c0  6c 69 64 20 70 61 72 74  69 74 69 6f 6e 20 74 61  |lid partition ta|
000000d0  62 6c 65 00 45 72 72 6f  72 20 6c 6f 61 64 69 6e  |ble.Error loadin|
000000e0  67 20 6f 70 65 72 61 74  69 6e 67 20 73 79 73 74  |g operating syst|
000000f0  65 6d 00 4d 69 73 73 69  6e 67 20 6f 70 65 72 61  |em.Missing opera|
00000100  74 69 6e 67 20 73 79 73  74 65 6d 00 00 00 00 00  |ting system.....|
00000110  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001b0  00 00 00 00 00 00 00 00  00 00 00 00 55 aa 80 01  |............U...|
000001c0  01 00 a5 07 a0 dd 20 00  00 00 e0 dd 02 00 00 00  |...... .........|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.0160705 s, 31.9 kB/s
00000200
T42 ~ # 
  • Good question, good research. It isn't a complete answer but you may find MBR: Sector layout and Case Study FreeBSD disk labels to be worth a read. I cannot really vouch for their accuracy, though. Looking at the fdisk code would also be a good place to start, to see under what exact conditions it prints that particular message. – a CVn Jun 27 '13 at 8:18
  • Not sure about this: does file -s /dev/sdc /dev/sdc1 show the information you want? – Gilles 'SO- stop being evil' Jun 27 '13 at 22:40
0

It might be a bit overkill for you, but I have succesfully used Boot Info Script, to get information about the boot sector and other boot related files (for Linux + Windows set ups).

From looking at the script I see it does test for GUIDs etc. specific FreeBSD, so it probably gives you the information that you need (including a lot of extra stuff, so there might be more direct ways of finding an answer to your question).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.