Date: Thu, 20 Mar 2014 19:13:05 +0000 From: Paul Thornton <prt@prt.org> To: freebsd-hackers@freebsd.org Subject: Re: Changes between 9.1 and 9.2 affecting boot/loader/gpt discs Message-ID: <532B3DC1.4070502@prt.org> In-Reply-To: <532B2AF9.6010800@FreeBSD.org> References: <532B1EAC.8040407@prt.org> <532B2AF9.6010800@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi, On 20/03/2014 17:52, Andrey V. Elsukov wrote: > On 20.03.2014 21:00, Paul Thornton wrote: >> All pointers and suggestions will be very gratefully accepted, this has >> been tying me in knots for the past few weeks. > > Hello, > > Can you show the output of: > # dd if=/dev/ada0 count=1 | hexdump -vC This seems OK to me. I've diffed block 0 of the 9.1 install with the 9.2 install and the only difference was the extra partition (as the 9.2 machine hadn't completed its installation process and removed it). > 00000000 33 c0 8e d0 bc 00 7c 8e c0 8e d8 be 00 7c bf 00 |3.....|......|..| > 00000010 06 b9 00 02 fc f3 a4 50 68 1c 06 cb fb b9 04 00 |.......Ph.......| > 00000020 bd be 07 80 7e 00 00 7c 0b 0f 85 10 01 83 c5 10 |....~..|........| > 00000030 e2 f1 cd 18 88 56 00 55 c6 46 11 05 c6 46 10 00 |.....V.U.F...F..| > 00000040 b4 41 bb aa 55 cd 13 5d 72 0f 81 fb 55 aa 75 09 |.A..U..]r...U.u.| > 00000050 f7 c1 01 00 74 03 fe 46 10 66 60 80 7e 10 00 74 |....t..F.f`.~..t| > 00000060 26 66 68 00 00 00 00 66 ff 76 08 68 00 00 68 00 |&fh....f.v.h..h.| > 00000070 7c 68 01 00 68 10 00 b4 42 8a 56 00 8b f4 cd 13 ||h..h...B.V.....| > 00000080 9f 83 c4 10 9e eb 14 b8 01 02 bb 00 7c 8a 56 00 |............|.V.| > 00000090 8a 76 01 8a 4e 02 8a 6e 03 cd 13 66 61 73 1e fe |.v..N..n...fas..| > 000000a0 4e 11 0f 85 0c 00 80 7e 00 80 0f 84 8a 00 b2 80 |N......~........| > 000000b0 eb 82 55 32 e4 8a 56 00 cd 13 5d eb 9c 81 3e fe |..U2..V...]...>.| > 000000c0 7d 55 aa 75 6e ff 76 00 e8 8a 00 0f 85 15 00 b0 |}U.un.v.........| > 000000d0 d1 e6 64 e8 7f 00 b0 df e6 60 e8 78 00 b0 ff e6 |..d......`.x....| > 000000e0 64 e8 71 00 b8 00 bb cd 1a 66 23 c0 75 3b 66 81 |d.q......f#.u;f.| > 000000f0 fb 54 43 50 41 75 32 81 f9 02 01 72 2c 66 68 07 |.TCPAu2....r,fh.| > 00000100 bb 00 00 66 68 00 02 00 00 66 68 08 00 00 00 66 |...fh....fh....f| > 00000110 53 66 53 66 55 66 68 00 00 00 00 66 68 00 7c 00 |SfSfUfh....fh.|.| > 00000120 00 66 61 68 00 00 07 cd 1a 5a 32 f6 ea 00 7c 00 |.fah.....Z2...|.| > 00000130 00 cd 18 a0 b7 07 eb 08 a0 b6 07 eb 03 a0 b5 07 |................| > 00000140 32 e4 05 00 07 8b f0 ac 3c 00 74 fc bb 07 00 b4 |2.......<.t.....| > 00000150 0e cd 10 eb f2 2b c9 e4 64 eb 00 24 02 e0 f8 24 |.....+..d..$...$| > 00000160 02 c3 49 6e 76 61 6c 69 64 20 70 61 72 74 69 74 |..Invalid partit| > 00000170 69 6f 6e 20 74 61 62 6c 65 00 45 72 72 6f 72 20 |ion table.Error | > 00000180 6c 6f 61 64 69 6e 67 20 6f 70 65 72 61 74 69 6e |loading operatin| > 00000190 67 20 73 79 73 74 65 6d 00 4d 69 73 73 69 6e 67 |g system.Missing| > 000001a0 20 6f 70 65 72 61 74 69 6e 67 20 73 79 73 74 65 | operating syste| > 000001b0 6d 00 00 00 00 62 7a 99 b6 12 00 00 00 00 00 fe |m....bz.........| > 000001c0 ff ff ee fe ff ff 01 00 00 00 00 40 06 00 80 fe |...........@....| > 000001d0 ff ff a5 fe ff ff 28 40 06 00 60 1f 19 3a 00 fe |......(@..`..:..| > 000001e0 ff ff a5 fe ff ff 50 60 1f 3a b0 ff 18 00 00 00 |......P`.:......| > 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.| > 00000200 > Also can you describe how exactly you configure the boot process? > I.e. what you have in loader.conf, boot.config, how you install boot code? This is slightly complicated, made more complex by the Apple EFI implementation. The disc has to be MBR bootable, and as a result the machine ends up with both a GPT partition scheme and an MBR one. These two are in sync (so the partitions in the dump above correspond to the GPT partitions shown in the last mail) and although I'm not amazingly happy with this setup, it hasn't gone wrong until now. These partitions are created by a combination of fdisk, gpart, and manual adjustment to the partition table in an interesting dance to stop gpart from overwriting the entire MBR partition table with one single EFI protected partition - because if that happens, then the machine won't boot as there isn't a valid partition marked 0x80 in the MBR table. The installer itself is actually a minimal 8.3 system that does all of the newfs, extract, amend /etc files processes. Once it has finished building the new machine and unmounted the target disc, it uses bsdlabel to install the bootcode with the following: bsdlabel -B -b /root/bootcode /dev/ad4p2 Where /root/bootcode is the /boot/bootcode file copied from the 9.2 installation (ie: don't use the wrong bootcode from 8.3) and /dev/ad4p2 is the partition we were installing to. In previous testing, I tried variations on this - for example: gpart bootcode -B -b bootcode -p gptboot -i 2 /dev/ad4 however, that just wins you a 'Missing Operating System' or other early failures and doesn't even make it as far as the loader. Partition wise, p1 is an EFI boot partition (which is what the machine actually starts up from, and there is a somewhat magic "please boot the legacy partition on this disc" call which to the EFI BIOS, which then goes off and starts the MBR partition marked as bootable). p2 is the FreeBSD partition just installed, the majority of the disc. p3 is the small install partition which it runs from whilst installing. The Mac doesn't support pxe booting or anything like that so we're a bit stuck with having an install partition. The default install doesn't put anything in boot.config or loader.conf (unless a mirror has been created, in which case geom_mirror_load="YES" goes in there). Paul. -- Paul Thornton
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?532B3DC1.4070502>