# Setting currdev in the boot loader



## Marcin Nowrot (Feb 14, 2015)

Immediately after I try to boot FreeBSD 10.1 on My Mac Book Pro I get the following message `can't load kernel`. After that I get to the "OK" command line where (after `show`) I see that both `currdev` and `loaddev` are set to `ada0p7:` which is correct when we talk about the GPT partition table. The problem is, that the boot loader sees only the Hybrid MBR partition table which does not contain this entry. I've worked this problem around by issuing `set currdev=disk0s3:` followed by `autoboot` and I was able to boot the kernel and log in, but repeating this process on each reboot is tedious at best. Is there a way to permanently set `currdev` to `disk0s3:`?


----------



## junovitch@ (Feb 14, 2015)

Boot time stuff is set in /boot/loader.conf.  The default settings are in /boot/defaults/loader.conf.  You can reference that and copy/paste and set the currdev line into /boot/loader.conf.


----------



## Marcin Nowrot (Feb 16, 2015)

I've edited /boot/loader.conf adding the following line:
	
	



```
currdev="disk0s3"
```
But unfortunately this didn't solve the problem. It seems to me that BTX loader tries to use some predefined `currdev` value, before even touching /boot/loader.conf - do you by any chance know where this might be changed? My (BSD beginner's) guess would be that it is stored somewhere on the freebsd-boot partition. Is it possible to mount it and edit files on this partition manually?


----------



## Juanitou (Feb 16, 2015)

Just a shot in the dark, as I’m not knowledgeable in these matters, but what is the output of `gpart show`?


----------



## junovitch@ (Feb 17, 2015)

I was afraid that would be before /boot/loader.conf is looked at.  However I think this should work without having to tinker it with it.  As said above, the `gpart show` output would be helpful.  I'm not familiar with MacBook hardware so seeing the output would be helpful.  What do you mean by the "Hybrid MBR" line?  I'm not an expert here but I thought it was MBR or GPT.  GPT also does a protective MBR for the first 512 bytes of the drive.  The s3 naming scheme for a "slice" looks like a plain MBR to me.


----------



## Marcin Nowrot (Feb 17, 2015)

Yes, as it seems, BTX sees only MBR, however the installer saw the GPT and has assigned the default currdev so.

Regarding hybrid MBR, please see: http://www.rodsbooks.com/gdisk/hybrid.html

Also, attaching results from `gpart show` - as it seems it properly recognizes GPT.


```
=>  34  977104993  ada0  GPT  (466G)
  34  6  - free -  (3.0K)
  40  409600  1  efi  (200M)
  409640  908772816  2  !53746f72-6167-11aa-aa11-00306543ecac  (433G)
  909182456  1269536  3  apple-boot  (620M)
  910451992  744  - free -  (372K)
  910452736  19529728  4  linux-data  (9.3G)
  929982464  7813120  5  linux-swap  (3.7G)
  937795584  1024  6  freebsd-boot  (512K)
  937796608  37747704  7  freebsd-ufs  (18G)
  975544312  1560714  8  freebsd-swap  (762M)
  977105026  1  - free -  (512B)

=>  63  19529665  ada0p4  MBR  (9.3G)
  63  19529665  - free -  (9.3G)

=>  63  19529665  gptid/a53c8923-5fcb-4ce0-8e9a-db9741c2d9f1  MBR  (9.3G)
  63  19529665  - free -  (9.3G)
```
... and from `gpart list`

```
Geom name: ada0
modified: false
state: OK
fwheads: 16
fwsectors: 63
last: 977105026
first: 34
entries: 128
scheme: GPT
Providers:
1. Name: ada0p1
  Mediasize: 209715200 (200M)
  Sectorsize: 512
  Stripesize: 4096
  Stripeoffset: 0
  Mode: r0w0e0
  rawuuid: 24099efe-e511-46e6-90d8-097bd4696bf6
  rawtype: c12a7328-f81f-11d2-ba4b-00a0c93ec93b
  label: EFI System Partition
  length: 209715200
  offset: 20480
  type: efi
  index: 1
  end: 409639
  start: 40
2. Name: ada0p2
  Mediasize: 465291681792 (433G)
  Sectorsize: 512
  Stripesize: 4096
  Stripeoffset: 0
  Mode: r0w0e0
  rawuuid: 7a1a0432-adeb-4232-9a02-0d3b72e61dc7
  rawtype: 53746f72-6167-11aa-aa11-00306543ecac
  label: Mac OS X
  length: 465291681792
  offset: 209735680
  type: !53746f72-6167-11aa-aa11-00306543ecac
  index: 2
  end: 909182455
  start: 409640
3. Name: ada0p3
  Mediasize: 650002432 (620M)
  Sectorsize: 512
  Stripesize: 4096
  Stripeoffset: 0
  Mode: r0w0e0
  rawuuid: 64bf90d9-aed5-4071-b301-759a5030cee8
  rawtype: 426f6f74-0000-11aa-aa11-00306543ecac
  label: Recovery HD
  length: 650002432
  offset: 465501417472
  type: apple-boot
  index: 3
  end: 910451991
  start: 909182456
4. Name: ada0p4
  Mediasize: 9999220736 (9.3G)
  Sectorsize: 512
  Stripesize: 4096
  Stripeoffset: 0
  Mode: r0w0e0
  rawuuid: a53c8923-5fcb-4ce0-8e9a-db9741c2d9f1
  rawtype: 0fc63daf-8483-4772-8e79-3d69d8477de4
  label: (null)
  length: 9999220736
  offset: 466151800832
  type: linux-data
  index: 4
  end: 929982463
  start: 910452736
5. Name: ada0p5
  Mediasize: 4000317440 (3.7G)
  Sectorsize: 512
  Stripesize: 4096
  Stripeoffset: 0
  Mode: r0w0e0
  rawuuid: 108ea454-33af-4245-b26e-469c63707e6e
  rawtype: 0657fd6d-a4ab-43c4-84e5-0933c84b4f4f
  label: (null)
  length: 4000317440
  offset: 476151021568
  type: linux-swap
  index: 5
  end: 937795583
  start: 929982464
6. Name: ada0p6
  Mediasize: 524288 (512K)
  Sectorsize: 512
  Stripesize: 4096
  Stripeoffset: 0
  Mode: r0w0e0
  rawuuid: 9aa34499-b3b5-11e4-9ae8-3dcfb41180dc
  rawtype: 83bd6b9d-7f41-11dc-be0b-001560b84f0f
  label: (null)
  length: 524288
  offset: 480151339008
  type: freebsd-boot
  index: 6
  end: 937796607
  start: 937795584
7. Name: ada0p7
  Mediasize: 19326824448 (18G)
  Sectorsize: 512
  Stripesize: 4096
  Stripeoffset: 0
  Mode: r1w1e1
  rawuuid: 9aa3c1c0-b3b5-11e4-9ae8-3dcfb41180dc
  rawtype: 516e7cb6-6ecf-11d6-8ff8-00022d09712b
  label: (null)
  length: 19326824448
  offset: 480151863296
  type: freebsd-ufs
  index: 7
  end: 975544311
  start: 937796608
8. Name: ada0p8
  Mediasize: 799085568 (762M)
  Sectorsize: 512
  Stripesize: 4096
  Stripeoffset: 0
  Mode: r1w1e0
  rawuuid: 9aa4c7d7-b3b5-11e4-9ae8-3dcfb41180dc
  rawtype: 516e7cb5-6ecf-11d6-8ff8-00022d09712b
  label: (null)
  length: 799085568
  offset: 499478687744
  type: freebsd-swap
  index: 8
  end: 977105025
  start: 975544312
Consumers:
1. Name: ada0
  Mediasize: 500277790720 (466G)
  Sectorsize: 512
  Stripesize: 4096
  Stripeoffset: 0
  Mode: r2w2e3
```


----------



## free-and-bsd (Feb 21, 2015)

Hey, on Mac you're dealing with an EFI bootloader, aren't you? My guess _that_'s why all this confusion about the correct device values.

I tried once a GRUB2 EFI loader on my UEFI-capable system, so I also had that effect that devices were not named correctly...
Anyway, you can read more here about FreeBSD UEFI installer and try to apply the procedure to reinstall your bootcode from your installer media, where you choose Shell after boot is complete.
Or you may post to the FreeBSD EFI bootloader mailing list, they must be able to help then.


----------



## Marcin Nowrot (Feb 25, 2015)

Actually this is what I've tried in the very beginning, but unfortunately, I've hit this Mac-specific bug.


----------

