Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Works for me, but I'm not able to make a file-based pool #1

Open
rnickle opened this issue Aug 21, 2021 · 5 comments
Open

Works for me, but I'm not able to make a file-based pool #1

rnickle opened this issue Aug 21, 2021 · 5 comments

Comments

@rnickle
Copy link

rnickle commented Aug 21, 2021

Thanks, this works great. I did the same flow based on https://wsl.dev/wsl2-kernel-zfs/ and wrote a script somewhat like yours. I was trying to use this to create a unit testing environment for ZFS scripts, so my goal is to create a pool using temp files, run the tests and then discard the pool. I'm applying it to Ubuntu 20.04 (from the Microsoft Store.)

I used Linux 5.10.60 for my build, but as you did, ZFS 2.10, but zpool doesn't work:

root:/usr/src# for i in {1..4}; do dd if=/dev/zero of=/root/vdev$i.img bs=1024 count=98304; done
root:/usr/src# zpool create testpool /root/vdev?.img
cannot create 'testpool': no such pool or dataset

Here's the same file-based temp file pool on a non-WSL VM with Ubuntu 20.04 built with the Ubuntu installer:

# for i in {1..4}; do dd if=/dev/zero of=/tmp/dev$i.img bs=1024 count=98304; done
# zpool create testpool /tmp/vdev?.img
# zpool list
NAME       SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
bpool     1.88G  78.8M  1.80G        -         -     0%     4%  1.00x    ONLINE  -
rpool       26G  2.07G  23.9G        -         -     1%     7%  1.00x    ONLINE  -
testpool   192M   112K   192M        -         -     0%     0%  1.00x    ONLINE  -

So I tried your excellent implementation, and it worked flawlessly, but I still end up in the same state.

Thanks for considering, I'm still digging, I will add more data if I find anything interesting.

@alexhaydock
Copy link
Owner

Thanks for letting me know, @rnickle! I'm glad someone actually found this and was able to get some use out of it.

I have been having a similar issue myself actually when trying to test pool configurations using sparse files. I need to rework my Win 10 development environment to really give this a proper test. Got a bit stuck as they've removed all the Insider Preview builds of Win 10 to get ready for the Win 11 release, but my dev box is too old to upgrade to 11. So for now I'm stuck unable to get the latest WSL2 with the nice drive mapping features.

It shouldn't really be needed for testing pools with sparse files, but I wanted to make sure I could get it reliably working with passed-through disks before I started to debug the sparse file issue too hard - in case both showed the same behaviour.

I'll rework my dev env and see if I can work out what we might be missing here.

@rnickle
Copy link
Author

rnickle commented Aug 21, 2021

Thanks for looking into it, so your suggestion about the drive mapping is what I was planning to try next: try to mount a VHD, I can try that later today.

I tried strace and gdb but wasn't able to get any clues that way, perhaps I'm not trying hard enough yet. I pored over the source but no ideas.

For my development environment I'm working in a vanilla but up-to-date corporate Win 10 Pro environment, I could use my personal Win 10 environment for testing too, but neither of these machines are on insider builds (that's a good idea!) For a point of reference I have a very clean Ubuntu 20.04 VM which is successfully running ZFS.

I wonder if it is because it is a kernel built-in, but that doesn't make sense. It is almost as if there is some service element missing, and yet, the services in the systemd directory seem mostly related to mounting services, not pool services.

One thing I noticed with sysctl is that the kernel.spl.hostid was set to '0', which didn't seem right since that was set to the host ID on my Ubuntu reference. Running 'zgenhostid' was sufficient to get the WSL session to generate an /etc/hostid file and set the kernel variable:
kernel.spl.hostid = 2bd45778

But that didn't change the behavior of creating a zpool. Still wondering if there's some other metadata or prerequisite that needs to be set to enable the zfs commands to access those features in the kernel.

Thanks!

@rnickle
Copy link
Author

rnickle commented Aug 23, 2021

I posed a Q&A on the OpenZFS project: Statically linked module for WSL2, does not seem to initialize properly. #12503

@alexhaydock
Copy link
Owner

I posed a Q&A on the OpenZFS project: Statically linked module for WSL2, does not seem to initialize properly. #12503

Great idea! I haven't had the time to do much debugging here directly myself, but I've upvoted your discussion thread and I subscribed to it so I can see how things progress over there.

@rnickle
Copy link
Author

rnickle commented Aug 30, 2021

I thought I might have some great insight by refactoring the flow to build a kernel with loadable modules instead of static linking, but I have exactly the same results:

# lsmod
Module                  Size  Used by
# modprobe zfs
# lsmod
Module                  Size  Used by
zfs                  4300800  0
zunicode              335872  1 zfs
zzstd                 569344  1 zfs
zlua                  172032  1 zfs
zavl                   16384  1 zfs
icp                   311296  1 zfs
zcommon                86016  2 zfs,icp
znvpair                69632  2 zfs,zcommon
spl                    90112  6 zfs,icp,zzstd,znvpair,zcommon,zavl
# zpool create testpool /root/vdev1.img 
cannot create 'testpool': no such pool or dataset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants