elitak / nixos-infect

[GPLv3+] install nixos over the existing OS in a DigitalOcean droplet (and others with minor modifications)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DigitalOcean: `rm: cannot remove '/boot/efi': Device or resource busy`

willhansen opened this issue · comments

DigitalOcean droplet.

Tried running script from command-line and through the "user data" mechanism:
image

In both cases, the install logs end with
rm: cannot remove '/boot/efi': Device or resource busy

I am still able to ssh into the ubuntu droplet.

Can confirm same behavior on a fresh Ubuntu 23.10 droplet.

[edit: 22.04 appears to work fine]

I ran into this as well on 24.04, the issue here seems to be this line: https://github.com/elitak/nixos-infect/blob/master/nixos-infect#L376

Since it appears both /boot and /boot/efi are both mounts, you can't just mv /boot out of the way. In my case, I was able to manually:

  • unmount /boot/efi
  • unmount /boot
  • mount the efi partition directly at /boot

Then re-run the script which carried out the rest of the process. There probably needs to be logic to detect and handle this case.

Hm, no wait, the second part of that line should do the right thing, and when I manually run each of those it results in the right set of steps. Something else is up here.

Ah, I see what's actually wrong here: I ran this with set -x and noticed the following output

+ rm -rf /boot.bak
+ isEFI
+ '[' -d /sys/firmware/efi ']'
+ mv -v /boot /boot.bak
mv: cannot move '/boot' to '/boot.bak': Device or resource busy

What's wrong here is that since isEFI is false, it doesn't unmount /boot/efi. These appear to systems that aren't using EFI to boot, but for some reason have a dedicated EFI partition. I have no idea why it's set up this way, but this check should probably test for the mount, not whether the system appears to be EFI.