◄  ▲  ► |
#!/bin/bashAfter days of making the floppy equivalent of "coasters", I got it figured out. And of course, to document my progress, I wrote down each step. When you do that, you're basically writing a shell script, so... I wrote a shell script.
# Too many commands will need superuser rights, so demand root!
if [ "$USER" != "root" ]; then
echo "You must run this script as root."
exit
fi
# Unmount the floppy just in case it's mounted
sync;sync
umount -r /dev/fd0 2> /dev/null
umount -l /dev/fd0 2> /dev/null
# Unmount the tempfs mount point just in case it was left mounted by script crash
umount -r tempfs 2> /dev/null
umount -l tempfs 2> /dev/null
I start by verifying the user is "root".
I then unmount everything. It shouldn't be mounted, but during development, I was always crashing and leaving things mounted. I use the "sync;sync" command to flush all buffers to the disks before unmounting. Actually, the "umount" command does that, so using sync twice and following with umount is stupid. Specially on a floppy I'm about to overwrite anyway.
The "2>" is a trick I learned in NT-DOS to redirect error messages. "1>" is standard out, while "2>" is standard error. I was pleased to see that the same syntax works in Linux. You never know 'till you try.