# ZFS without GPT?



## poorandunlucky (Mar 30, 2017)

Hey,

I might've delusioned myself here, but is it possible to boot from just a bare ZFS drive, no GPT or MBR?

I wrote zfsboot according to zfsboot(8) but now it's saying

`Can't find /boot/zfsloader`

And then complains about not being able to find the kernel.

If I type

`boot: ?`

I get the directory listing for /.

I wasn't able to find the solution for this, albeit a lot of guides for installing on GPT from the time this was a breakthrough, but I get this far...

zfsboot(8) says ZFS makes provision for people to install loaders, so I guess it doesn't write data in the first _n_ blocks of a device, but where does it look?  Does anyone know, or do I have to figure it out?

: <

I don't want to have a GPT but I don't want to figure it out either...


----------



## SirDice (Mar 31, 2017)

poorandunlucky said:


> I might've delusioned myself here, but is it possible to boot from just a bare ZFS drive, no GPT or MBR?


No. A BIOS or UEFI can't read ZFS. So you need a boot loader. And there's only 400 or so bytes available in a boot sector, that's not enough to cram a ZFS filesystem driver in there.



poorandunlucky said:


> I don't want to have a GPT but I don't want to figure it out either...


Why not? It's significantly better than MBR.


----------



## SirDice (Mar 31, 2017)

Thinking about it a bit more, and after actually reading gptboot(8). Theoretically it should be possible but if you read BUGS in gptzfsboot(8) you'll see it's difficult to get everything in line. So to prevent a lot of tricky configurations and dodgy boots it's better to use partitions. Much easier to set up and a lot less error prone.


----------



## poorandunlucky (Apr 1, 2017)

SirDice said:
			
		

> Why not? It's significantly better than MBR.



Quite likely in ways I don't even understand, but I just thought it was possible for ZFS to just use the bare space just like that, which I thought was sort of cool...



			
				SirDice said:
			
		

> Thinking about it a bit more, and after actually reading gptboot(8). Theoretically it should be possible but if you read BUGS in gptzfsboot(8) you'll see it's difficult to get everything in line. So to prevent a lot of tricky configurations and dodgy boots it's better to use partitions. Much easier to set up and a lot less error prone.



I almost want to pretend that didn't happen, but since the bootloader can read the filesystem, there's decent reason to have hope...  I just remembered that I created a dataset for /boot (for better security and integrity without hindering performance), but in /boot/loader.conf I only have `vfs.root.mountfrom="zfs:poot"`, not `vfs.root.mountfrom="zfs:pool/dataset"`.


My VM isn't booting anymore for some reason that escapes me, so I'm reinstalling FreeBSD (for the nth hundredth time), but I'm going to give that another go and ask you for help if I get another boot: prompt that lists the content of / because I have no idea how to issue commands to the bootloader and there aren't many examples on how to deal with it... if you don't mind, of course...


----------



## poorandunlucky (Apr 11, 2017)

OK, so I've dealt with zfsboot(8)...  as I thought, it's the path relative to the dataset that was obfuscating the bootstrapper.  Issuing the path `zfs:freebsd/boot:/zfsloader` worked (because that's what it was looking for, obv. even if it talks about the kernel.

Now, I'm in zfsloader(8), and I don't have a `boot` prompt anymore, I have an `OK` prompt.







Now I'm really stumped, and I need to use pwgen : <

What does it want?  I've read to give it a path in the format 0:something:somethingelse but I've no clue what to tell it... I tried a bunch of things so far.

There are no datasets beyond zfs:freebsd/boot, no encryption either.

Also, after all this is done, I can just put options in /boot/boot.boot (?) and loader.conf, right?


----------



## SirDice (Apr 11, 2017)

You're now stuck in loader(8). Your /boot doesn't appear to have a kernel. If you look at the errors it's trying to load the load the kernel (/boot/kernel/kernel) and can't find it.


----------



## poorandunlucky (Apr 11, 2017)

Wait... the first error message I got, before `FreeBSD x86-64 boot`, what gave me that?

And then, what was giving me the `boot` prompt, was that boot(8), or zfsboot(8)?

How do I tell (zfs)loader(8) that the kernel is on disk 1 in pool freebsd in dataset boot in the kernel directory?

I think the problem with (gpt[zfs])boot(8) was that, from its perspective, root was one filesystem down and couldn't find it.


----------



## SirDice (Apr 11, 2017)

poorandunlucky said:


> And then, what was giving me the  boot prompt, was that boot(8), or zfsboot(8)?


boot(8) is a fairly generic man page about the whole boot process, it's not a specific command or process. The boot prompt comes, in your case, from zfsboot(8). Its primary function is to load loader(8) (or zfsloader(8)), loader(8) is what actually loads the kernel.

It's slightly dated now but the handbook has some information about the whole boot process: 12.2. FreeBSD Boot Process


----------



## poorandunlucky (Apr 11, 2017)

But the first error in the screenshot, what gave me that?  did boot load loader, loader couldn't find the kernel, exited > 0, and boot gave me its prompt so I could run loader with parameters?

i don't understand why you say that there's no kernel under /boot/kernel, as far as I can tell, it hasn't looked yet because it couldn't load loader (which isn't on the root filesystem).  it's like i have a fstab entry for /boot, it's not gotten there yet, that's why boot needed me to tell it the location of loader ... no?


----------



## poorandunlucky (Apr 12, 2017)

SirDice : Can you tell me how to tell (zfs)loader to load the kernel it's looking for, please?


----------



## SirDice (Apr 12, 2017)

Typically this is done in loader.conf:

```
vfs.root.mountfrom="zfs:zroot"
```
Or 

```
vfs.root.mountfrom="zfs:zroot/ROOT/default"
```
It depends on how the setup has been done what the exact value should be.


----------



## poorandunlucky (Apr 12, 2017)

SirDice : Oh, that part I got it... it was zfs:freebsd/boot:/zfsloader (the part where I tell zfsboot where to continue), it's the `OK _` prompt at zfsloader that's got me stuck, I think it's `1:zfs:freebsd/boot:/kernel/kernel` but I have no idea, I'm just giving you an idea for the format, maybe it rings a bell more easily, idk...

And I do have vfs.root.mountfrom="zfs:freebsd/boot", to give it the name of the filesystem in which the boot files are, but obviously that's wrong or I wouldn't have gotten the boot prompt asking me for the loader's location, I think...


----------



## redpill (Apr 13, 2017)

I suspect you're having a fight with loader(8)'s default settings.

Correct me if I'm wrong, but it looks to me like all of your boot files are located in the / directory of the dataset you're trying to boot from, and not in /boot (not to be confused with the dataset of the same name) like loader expects in this case. Is /boot on a separate filesystem?

You can use the following commands at the 'OK' prompt to get a picture of where loader expects things to be given your current settings:

```
OK show kernelname
OK show loader_conf_files
OK show module_path
```
You can also change these and other variables from the prompt if you wish to test different things out without having to edit loader.conf.

In my limited experience, so long as currdev is pointing at the right dataset, usually everything just works.

```
OK show currdev
```


----------



## poorandunlucky (Apr 13, 2017)

redpill : well we could have fun with phraseology here, but /boot is a dataset on its own, I want redundancy here I don't need elsewhere.

freebsd is the name of the pool, and then datasets are named canonically from their mountpoints in the standard FreeBSD hierarchy, so /boot is a 1st child of freebsd.

this is a fresh install of 11-REL all with defaults except for zfs_load="YES" in /boot/loader.conf, i'm just not able to first boot.  the only difference is the zfs filesystem, and that /boot (the directory) isn't on the root dataset.


----------

