ZFS Root dualboot

Hello

I have Ubuntu with ZFS on root installed on my study-laptop, but want to make it dualboot (yes, so very 2011) with windows 10. Is this possible? If yes, how would I go about it?

I’m fairly new to ZFS and would likely need guidance, or just reinstall without ZFS.

And inb4: yes, I want dualboot and not Windows in a VM.

Thanks in advance

Sorry I don’t have a direct answer to your dual boot question, but my approach has been to use an external USB SSD (A Samsung T7 I think for my laptop, but I’ve also used a spare NVME drive in a cheap USB-C caddy). The performance is not quite that of the internal drives, but for general purpose use it is fine. This means you don’t mess up either your ZFS or your Windows (which as you are fairly new to ZFS is a good idea).

I also use REFind to boot. Normally this would be for my Linux (and ZFS), but when you plug in the external drive, it will detect it and give it as an option - useful if you forget the select the boot you want via the BIOS.

Hope that gives you an alternative that might be useful…

can you add a second drive internally to your lappy?.
if so i would go that route.
you can then control via your bios/uefi the boot order and you dont have to deal with the risk of bricking one of your o.s partitions and losing both installs because of it.

theres also issues between some versions of zfs and windows 10/11
so may not be the best idea to dual boot off 1 drive with multiple partitions.

I can add a second drive, and that is currently looking like the way to go.
I was skeptical because of the additional power drain on the battery, as I need every percent I can get. Also I specifically bought a very big drive, so I can put both OSs on one drive.

Also having to go into UEFI everytime instead of being promted is a bit of a hassle but I think I’ll manage.

Just if I wanted to try it while the install is still new (and easily reproduceable), how would I got about it? I cannot easily shrink the partition with parted, I’ve seen…

if yours zfs doesn’t install a grub you can hack a bootloader together that uses grub.
with the only drawback being you have to manually update it every time you update grub.

at least with below you can choose which o.s to boot into without having to go into bios…
but it is a hack. so use with that understanding.

https://openzfs.github.io/openzfs-docs/Getting%20Started/Arch%20Linux/Root%20on%20ZFS/5-bootloader.html

oh and ssd/nvme dont use that much power compared to spinning rust. so may be the way to go for a second drive.

On my laptop I installed Windows 10 first, then created another partition for ZFS, put systemd-boot/kernel/initrd in the existing ESP, and created a EFI entry for systemd-boot. Nothing special, just works. Installing Windows second will usually remove/change the existing EFI entries and create another ESP (in my experience), but easily undo-able.

1 Like

The instructions for Arch look like ZFS is installed on partitions, e.g.:

zpool create
….
-O mountpoint=/boot
-R /mnt
bpool
mirror
$(for i in ${DISK}; do
printf "$i-part2 ";
done)
System Installation — OpenZFS documentation

The instructions for Ubuntu look like ZFS is install for the whole disk:

• This HOWTO uses a whole physical disk.
• Do not use these instructions for dual-booting.
Ubuntu 22.04 Root on ZFS — OpenZFS documentation

ZFS on a partition(s) would make it possible to have Windows on another partition, and boot between them.
ZFS on your laptop whole physical drive will not.

1 Like

If adding a 2nd drive is an option, I would add a 2nd drive. Windows tends to do wacky things with boot partitions after updates when it shares a drive with a Linux installation too. It’s the kind of situation where it will work perfectly fine for a year or more, then one reboot after a Windows update causes the whole setup to go sideways and cause your Linux partition to not be bootable without fixing the boot partition. Giving each OS it’s own drive side steps this whole nightmare completely.

If you are really insisting upon installing everything on one drive, you should definitely install Windows first and then Linux afterwards. Windows is the more unpredictable of the two, so you need to make whatever concessions it needs to appease it. I am not sure how well Ubuntu’s automated ZFS on root installer is going to play along with not having a full disk though. As a lover of ZFS, in a situation like this (dual-booting on a single drive shared with Windows) you will probably have a vastly easier experience with your root Linux partition being ext4. Unless you feel like experimenting and you have plenty of time in which you can test without relying upon this system, in which case give it a shot and document your experience somewhere to help others who may consider attempting the same!

1 Like

This is very insightful, thank you. To check if my system was installed as in the guide I did the following:
lsblk | grep -v loop
to figure out the dev and then
df -hT | grep nvme0n1
which gave back a
/dev/nvme0n1p1 vfat 511M 14M 498M 3% /boot/efi

so the disk itself is formatted as vfat.
bpool has mount /boot and rpool has /.

Does this confirm or deny that it is set up in the same way, as

Ubuntu 22.04 Root on ZFS — OpenZFS documentation

did?

Thanks, yes second drive is looking like the way to go to avoid troubles…

Should be possible to basically turn off a device after boot on linux I hope…? I certainly head similar stories with pcie passthough stuff.

angrily puts that second nvme drive in the cart

Actually, that’s just the ~500MB EFI partition, suggesting that ZFS is installed on a partition(s).

Can you show a:
zpool list
and
zpool status
?

zpool list:

NAME    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
bpool  1.88G   246M  1.63G        -         -     2%    12%  1.00x    ONLINE  -
rpool  1.81T  12.3G  1.80T        -         -     0%     0%  1.00x    ONLINE  -

zpool status:

  pool: bpool
 state: ONLINE
config:

	NAME                                    STATE     READ WRITE CKSUM
	bpool                                   ONLINE       0     0     0
	  xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx1  ONLINE       0     0     0

errors: No known data errors

  pool: rpool
 state: ONLINE
config:

	NAME                                    STATE     READ WRITE CKSUM
	rpool                                   ONLINE       0     0     0
	  xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx2  ONLINE       0     0     0

errors: No known data errors

It looks like you have a 2TB NVMe, and your ZFS install is similar to the partition install (with a boot pool, bpool, and a root pool, rpool, on paritions) shown for Arch on the OpenZFS site – and you have a 500MB EFI partition, that (if it’s also like the OpenZFS Arch install) likely has an EFi grub install that boots from UEFI, and then loads the bpool, which mounts the rpool.

You’ve got lots of room on your disk – you’re only using 12G of your 1.8T root pool? – but, the bad news is that you can’t resize/shrink that rpool that to make room for a Windows partition. You’re going to have to back it up/recreate it/start from scratch/etc.

Before getting to that point, I’d recommend first learning/setting up rEFInd:
[The rEFInd Boot Manager]
on your system, so you can use it to boot into your existing EFI grub.
Then, once you’re comfortable with that process, try adding:
ZFS Boot Menu
[GitHub - zbm-dev/zfsbootmenu: ZFS Bootloader for root-on-ZFS systems with support for snapshots and native full disk encryption]
to your rEFInd, so you can boot from rEFInd, to ZFS Boot Menu, directly into your ZFS Linux (bypassing the EFI grub) – in addition to booting from the EFI grub).

Once you’re an expert at controlling your boot environment, then you can think about how you want to redo your drive and install your desired OSs, like maybe you can make a;
EFI – 900MB
Windows partition – .8TB
Linux ZFS – .8TB

or
EFI – 900MB
Windows partition – 500G
Linux ZFS – 500G
Data partition - .8TB

etc.

and setup rEFInd, ZFS Boot Menu, etc. to choose between whatever you setup.

Sure, occasionally, an update or install might hijack boot control away from rEFInd, but once you understand what’s going on under the hood, it’s usually just a simple fix to restore the boot chain as desired, e.g.:

$ sudo efibootmgr -o 0000,0085,0002,0003
BootCurrent: 0000
Timeout: 0 seconds
BootOrder: 0000,0085,0002,0003
Boot0000* rEFInd Boot Manager
Boot0002* Windows Boot Manager
Boot0003* Windows Boot Manager
Boot0085* ubuntu

The rEFInd Boot Manager: Keeping rEFInd Booting

2 Likes

How would @droidben be accessing their Linux data while in windows/vice versa? They’d have to have a small VM with ZFS and samba if they wanted to do that? … or have yet another exchange partition… or an external drive or network server

Is there a ZFS for Windows implementation/tool/utility of any kind (e.g. like there is for ext4)

Yes, loads of free space, hence this discussion here :slight_smile:

I did a GUI install of ubuntu and just selected ZFS on root. Seems like the Ubuntu folks like their ZFS setup the same as the OpenZFS folks like theirs on Arch.

Since I’ve not got too much time on my hands, I think the better option here (since partition resizing is not possible) is to just pop in a second SSD. I’ve got the second m.2 slot anyways, why not use it for what it’s worth. I’ll have to live with hitting the boot menu key when wanting to boot win10, but I’ll accept that tradeoff.

Although the path you suggested with rEFInd sounds very interesting and when I have more time on my hands and this problem still bothers me, I would definitely like to go down this rabbithole, I think I’d learn a lot. Thanks a lot for your effort, kudos to you for pointing me in the right direction.

When I get the second SSD and slapped win10 on it, I’ll post here if everything worked out.