johnramsden / zedenv-grub

zedenv plugin for GRUB
https://zedenv.readthedocs.io/en/latest/plugins.html#grub
BSD 3-Clause "New" or "Revised" License
11 stars 4 forks source link

zedenv destroy "Couldn't remove directory /mnt/boot/zfsenv." #19

Closed a-schaefers closed 5 years ago

a-schaefers commented 5 years ago

First discovered in https://github.com/johnramsden/zedenv/issues/14 (and likely unrelated), so reposting this as a zedenv-grub bug:

When running "zedenv destroy foo --verbose" during my tests, it consistently outputs:

Couldn't remove directory /mnt/boot/zfsenv. [Errno 2] No such file or directory: '/mnt/boot/zfsenv'

But still successfully completes the operations. I tried manually creating /mnt/boot/zfsenv, the zfsenv/ directory will be removed still, but the verbose output will still say that it "Couldn't remove directory"...

Example:

root@e6430 ~ # zedenv list
Name    Active   Mountpoint   Creation              
gentoo  NR       /            Sun-Nov-18-0:44-2018  
debian           -            Sat-Nov-24-23:01-2018 
root@e6430 ~ # ls -al /mnt/boot/
total 1
drwxr-xr-x 2 root root 2 Nov 26 17:49 .
drwxr-xr-x 3 root root 4 Nov 24 22:47 ..
root@e6430 ~ # zedenv create foo --verbose
Creating Boot Environment:

Getting properties of rpool/root/foo for clones [{'snapshot': 'rpool/root/gentoo@2018-11-26-17-686807', 'properties': ['mountpoint=/', 'canmount=off'], 'datasetchild': ''}]

root@e6430 ~ # zedenv destroy foo --verbose
Do you really want to destroy 'foo'?
This action will be permanent.

Destroy 'rpool/root/foo'? [y/N]: y

Configuring boot environment bootloader with grub

Checking prop: 'org.zedenv.grub:boot'
Checking prop: 'org.zedenv.grub:bootonzfs'
Using plugin grub

Boot environment 'foo' is a clone.
Checking to make sure there are no dependant clones to promote.

The origin snapshot '2018-11-26-17-686807' for the boot environment 'foo' still exists, do you want to destroy it? This action will be permanent.

Destroy 'rpool/root/gentoo@2018-11-26-17-686807'? [y/N]: y

Destroyed rpool/root/gentoo@2018-11-26-17-686807.

Creating Temporary working directory. No changes will be made until the end of the GRUB configuration.

Going over list [{'name': 'rpool/root/gentoo'}, {'name': 'rpool/root/debian'}].

Dataset rpool/root/gentoo is root, skipping.

Setting up rpool/root/debian.

Mounting boot environment 'debian'.

Mountpoint '/mnt/boot/zfsenv/zedenv-debian' given, using as mountpoint.

Mounted dataset to '/mnt/boot/zfsenv/zedenv-debian'.

Generating the GRUB configuration.

Generated GRUB menu successfully at /boot/grub/grub.cfg.

Mount root: '/mnt/boot/zfsenv' doesnt exist.

Couldn't remove directory /mnt/boot/zfsenv.
[Errno 2] No such file or directory: '/mnt/boot/zfsenv'

Destroyed boot environment foo successfully.

root@e6430 ~ # mkdir /mnt/boot/zfsenv
root@e6430 ~ # zedenv create foo && zedenv destroy foo --verbose
Do you really want to destroy 'foo'?
This action will be permanent.

Destroy 'rpool/root/foo'? [y/N]: y

Configuring boot environment bootloader with grub

Checking prop: 'org.zedenv.grub:boot'
Checking prop: 'org.zedenv.grub:bootonzfs'
Using plugin grub

Boot environment 'foo' is a clone.
Checking to make sure there are no dependant clones to promote.

The origin snapshot '2018-11-26-17-893880' for the boot environment 'foo' still exists, do you want to destroy it? This action will be permanent.

Destroy 'rpool/root/gentoo@2018-11-26-17-893880'? [y/N]: y

Destroyed rpool/root/gentoo@2018-11-26-17-893880.

Creating Temporary working directory. No changes will be made until the end of the GRUB configuration.

Going over list [{'name': 'rpool/root/gentoo'}, {'name': 'rpool/root/debian'}].

Dataset rpool/root/gentoo is root, skipping.

Setting up rpool/root/debian.

Mounting boot environment 'debian'.

Mountpoint '/mnt/boot/zfsenv/zedenv-debian' given, using as mountpoint.

Mounted dataset to '/mnt/boot/zfsenv/zedenv-debian'.

Generating the GRUB configuration.

Generated GRUB menu successfully at /boot/grub/grub.cfg.

Mount root: '/mnt/boot/zfsenv' doesnt exist.

Couldn't remove directory /mnt/boot/zfsenv.
[Errno 2] No such file or directory: '/mnt/boot/zfsenv'

Destroyed boot environment foo successfully.

root@e6430 ~ # ls -al /mnt/boot/
total 1
drwxr-xr-x 2 root root 2 Nov 26 17:52 .
drwxr-xr-x 3 root root 4 Nov 24 22:47 ..
johnramsden commented 5 years ago

I believe I found the root of the problem, but unfortunately I don't have a GRUB system at the moment. I tried and failed to set up a GRUB VM this evening and seem to have deleted my old ones. I'll get to it as soon as I have time, but if you are able to, you could test out if the fix is working by cloning the issue/19 branch.

a-schaefers commented 5 years ago

I have tested the issue/19 branch with zedenv create and destroy, it does indeed fix the issue.