Once a week I pop out the microSD card on my church’s recorder and get the sermon uploaded. I do this on OpenBSD, and also mount/umount the microSD card via the command line. On another note, I use the SSH ControlMaster feature when logging into my servers. Why is this related? You’ll see. The other day I mounted the microSD card

doas mount /dev/sd3i /mnt/usb

Then cd’d to that directory to copy out the music file. While I was there I SSH’d into a server for some reason. I finished my copying of the audio, exited the terminal, edited and uploaded the Sunday sermon. Then went to umount the microSD card

$ doas umount /mnt/usb
umount: /mnt/usb: Device busy

Huh. I wasn’t cd’d into the directory, no open files, I checked fstat

$ fstat -f /mnt/usb
USER     CMD          PID   FD MOUNT        INUM  MODE R/W    SZ|DV
courtney ssh        40229   wd /mnt/usb        2  drwxr-xr-x r     4096
$ ps -ux | grep 40229
courtney 40229  0.0  0.0  2312  2664 ??  Ip     12:14PM    0:00.00 ssh: /home/courtney/.ssh/controlmasters/courtney@example.com22 [mux] (ssh)

Well okay then. Why on earth is my control master file there? I found that strange. Turns out, this isn’t some SSH thing. For some reason in the UNIX world if you create an open file from your shell, it creates a file descriptor from that directory, something I wasn’t aware of. I thought since I wasn’t cd’d into the directory and that the file was on my /home partition, this wouldn’t be a thing. Sure enough, closing the SSH connection solved the issue

$ ssh -O exit example.com
Exit request sent.
$ doas umount -v /mnt/usb
/dev/sd3i: unmount from /mnt/usb

All good. I tried this with httpd out of curiosity. I started httpd from /mnt/usb

# httpd -f /etc/httpd.conf

This had the same effect. I had to stop httpd so I could then umount /dev/sd3i. So many small things that you may never encounter unless you really know operating systems, or have a random encounter like I did here, I guess.

#100DaysToOffload #Post1