ZFS non-removable

Developer discussions.

ZFS non-removable

Postby rahvee » Wed May 25, 2016 6:54 am

I have been running a windows VM inside a ZFS volume, so I can snapshot and replicate the ZFS volume as a form of backup for windows. The problem is, when the mac hibernates, the ZFS volumes unmount, and although they remount automatically, they don't remount quickly enough, so vmware crashes.

Is it possible, now or in the future, to make ZFS volumes non-removable, like Macintosh HD, so the applications can always assume the volume is present?
rahvee
 
Posts: 6
Joined: Wed May 25, 2016 4:40 am

Re: ZFS non-removable

Postby Brendon » Wed May 25, 2016 1:34 pm

Hi Rahvee,

This sounds like an interesting problem! I am 99% certain that we don't unmount the drives during when a machine is hibernating. I do run VMs on a ZFS drive, not windows though, but that machine never sleeps.

I would like to see a lot more description around your configuration (hardware and software) and also any information related to the VMWare crash, and I will try to replicate if possible.

If you don't want to post that sort of information here, catch up with us on IRC.

Cheers
Brendon
Brendon
 
Posts: 286
Joined: Thu Mar 06, 2014 12:51 pm

Re: ZFS non-removable

Postby rahvee » Thu May 26, 2016 3:31 am

Sure, this is easy. I always run the latest of everything, so that means OSX 10.11.5 El Capitan, and o3x ... I'm not sure what version, but it was the latest a couple months ago.

ZFS volumes appear as mounted volumes in the side bar, and they have the "eject" icon on them. Macintosh HD also appears, but without the "eject" button.

Side note: I've never clicked the eject button on a ZFS volume, and I don't know what would happen, but it would be nice to make them not appear in the sidebar. You can go to Finder/Preferences and un-check "hard disks" but then you won't see other hard disks. You can also drag the ZFS volume out of side bar, but that's only temporary until the next reboot or remount. I can't find any option to treat the ZFS volumes as permanently attached, like Macintosh HD.

The first and easiest way to see that ZFS doesn't mount quickly enough is to set some app to "Open at Login" and have it immediately try to access some file in the ZFS volume. For example, I tried making VMWare Fusion open a particular VM at login, but it would pop up an error message saying machine could not be found, or something like that. To workaround that issue, I actually (sadly) use this crontab:

@reboot while [ ! -f '/Volumes/Virtual_Machines/Windows_10.vmwarevm/Virtual Disk.vmdk' ] ; do sleep 1 ; done ; sleep 5 ; open '/Applications/VMware Fusion.app'

The other time when it's a problem, as described in this thread, is:

When I close the lid of the computer, the computer sleeps. If I open it up again a little while later, everything is fine, which shows you that ZFS doesn't unmount for sleeps, and sleeps are no problem. But if you leave the lid closed for a long time (overnight) then the computer hibernates. In this case, OSX dumps all of its ram to disk, and unmounts everything, including Macintosh HD, and powers off. When you power on again, it remounts Macintosh HD, and loads all the RAM back from disk, before waking up any of the apps. It's *supposed* to be just like waking up from sleep, except it doesn't work that way in reality. For whatever reason, Macintosh HD obviously comes back before any of the apps, but the ZFS volumes don't mount quickly enough, so apps come back at the same time as ZFS, or earlier. I don't know if apps consistently come back faster than ZFS, or if there's a race, but I know I've never seen ZFS win the race. Every time I've done this so far, VMware gives me a message about virtual machine unavailable (or something like that) and the only option is to close vmware. This is not a problem if the guest VM is housed on Macintosh HD; only when the VM is housed on a "removable" volume such as ZFS.
rahvee
 
Posts: 6
Joined: Wed May 25, 2016 4:40 am

Re: ZFS non-removable

Postby Brendon » Thu May 26, 2016 1:36 pm

Hi

Thanks for the detailed response

ZFS volumes appear as mounted volumes in the side bar, and they have the "eject" icon on them. Macintosh HD also appears, but without the "eject" button.


Agree, we don't know how to prevent the ZFS datasets from being ejectable at this point. There appears to be no harm in them being ejectable, unless of course you eject one accidentally.

The first and easiest way to see that ZFS doesn't mount quickly enough is to set some app to "Open at Login" and have it immediately try to access some file in the ZFS volume. For example, I tried making VMWare Fusion open a particular VM at login, but it would pop up an error message saying machine could not be found, or something like that. To workaround that issue, I actually (sadly) use this crontab:

@reboot while [ ! -f '/Volumes/Virtual_Machines/Windows_10.vmwarevm/Virtual Disk.vmdk' ] ; do sleep 1 ; done ; sleep 5 ; open '/Applications/VMware Fusion.app'


Ah yes, its certainly true that there is no coordination as to when ZFS volumes become available verses when a user can login to a machine. It is because once the ZFS drivers are loaded it takes some time for the drives to be ready for use, and there is nothing in OSX that will cause it to wait for "all drives" to be available. The only way we can see of doing this is to modify the launchd item that starts the login screen to wait for ZFS. This has been discussed and rejected because it requires modifications to files that we feel could ultimately cause other problems for users.

The same issue applies if you use ZFS has your home directory, you have to wait after boot for the drives to mount before attempting to login.

When I close the lid of the computer, the computer sleeps. If I open it up again a little while later, everything is fine, which shows you that ZFS doesn't unmount for sleeps, and sleeps are no problem. But if you leave the lid closed for a long time (overnight) then the computer hibernates. In this case, OSX dumps all of its ram to disk, and unmounts everything, including Macintosh HD, and powers off. When you power on again, it remounts Macintosh HD, and loads all the RAM back from disk, before waking up any of the apps. It's *supposed* to be just like waking up from sleep, except it doesn't work that way in reality. For whatever reason, Macintosh HD obviously comes back before any of the apps, but the ZFS volumes don't mount quickly enough, so apps come back at the same time as ZFS, or earlier. I don't know if apps consistently come back faster than ZFS, or if there's a race, but I know I've never seen ZFS win the race. Every time I've done this so far, VMware gives me a message about virtual machine unavailable (or something like that) and the only option is to close vmware. This is not a problem if the guest VM is housed on Macintosh HD; only when the VM is housed on a "removable" volume such as ZFS.


I understand your description and will try to replicate. As stated yesterday ZFS does not unmount drives during hibernate. However this does not preclude your symptoms being caused by some similar effect.

Thanks
Brendon
Brendon
 
Posts: 286
Joined: Thu Mar 06, 2014 12:51 pm


Return to OpenZFS on OS X Development

Who is online

Users browsing this forum: No registered users and 16 guests