elitak / nixos-infect

[GPLv3+] install nixos over the existing OS in a DigitalOcean droplet (and others with minor modifications)
GNU General Public License v3.0
1.3k stars 214 forks source link

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

Open willhansen opened 6 months ago

willhansen commented 6 months ago

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.

ironicbadger commented 6 months ago

Can confirm same behavior on a fresh Ubuntu 23.10 droplet.

[edit: 22.04 appears to work fine]

keeakita commented 1 month ago

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:

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.

keeakita commented 1 month ago

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.

keeakita commented 1 month ago

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.