balena-os / resin-device-toolbox

[DEPRECATED] The official Resin Device Toolbox CLI for resinOS
Apache License 2.0
14 stars 3 forks source link

"Resource busy" error when configuring SD Card #32

Closed lekkas closed 7 years ago

lekkas commented 7 years ago

Error Log

kostasl@macbook:~/resin/github/resin-os/resin-device-toolbox$ sudo ./bin/resin-device-toolbox configure /dev/disk2
? Network SSID My_Wifi_Ssid
? Network Key super_secret_wifi_password
? Do you want to set advanced settings? No
EBUSY: EBUSY: resource busy or locked, open '/dev/disk2'

If you need help, or just want to say hi, don't hesitate in reaching out at:

    GitHub: https://github.com/resin-os/resin-device-toolbox/issues/new
    Gitter: https://gitter.im/resin-io/chat

Node version: v6.2.1

/resin-boot/system-connections/resin-sample does not seem to be updated after the error.

lekkas commented 7 years ago

ref: https://github.com/resin-io/resin-image-fs

jviotti commented 7 years ago

We've managed to discover the root of the issue: reconfix uses resin-image-fs to write to FAT partitions. That module doesn't mount the partitions, but provides FAT implementation on JavaScript that works just with a file descriptor on the drive.

The way that module works is that for each I/O operation it opens a file descriptor, and closes it when its done. At least in OS X, I can confirm that unmounting a drive, opening a file descriptor to it, and then closing the file descriptor causes the OS the mount the partitions (if they contain a mountable file-system of course).

We could either refactor resin-image-fs to somehow allow the client application to control the file descriptor life (which could be tricky and take time to do right), or we could make use of something like denymount to prevent the drive from being re-mounted on the configure command.

The module linked to above is OS X specific, but I believe this issue doesn't happen on other OSes.

lekkas commented 7 years ago

Fixed by https://github.com/resin-os/resin-device-toolbox/pull/59