At work I use both Linux and FreeBSD extensively. Recently while going through some old bash scripts trying to make sense of them, I had two terminals open, one for looking through the script and the other for looking up man pages, to decipher command line switches.
This was going fine, until I can across a certain command that just didn’t make sense, the mount command.
The operation was happening at boot up, where a partition was being mounted as the root filesystem.
mount -f -o rw /dev/md0 /
This mounts dev/md0 on /. Sinple enough, the -o option specifies that the partition is to be mounted readable and writable. What about the -f part though.
I switched across to my other terminal, and typed in man mount to have a look for this command switch. According to the man page, go on, check for yourself, this command ‘fakes’ the mount, i.e, does everything except the system call.
This had me puzzled for a while, until I realised that I was looking at the man page for the LINUX implementation of mount,not the FreeBSD implementation, so I ssh’d to a FreeBSD box and had a look and sure enough, I found,
Sure enough, the command is different, but what a difference!
In Linux, -f ‘fakes’ a mount, whereas in FreeBSD, it ‘forces’ a mount. Those are two completely different things, you could hypothetically want to check a volatile FS using -f to fake a mount, and then acting based on the return from that, but if you run the command on FreeBSD, it will force the mount, a dangerous thing to do!
So note to self – Linux and FreeBSD are NOT THE SAME…watch out for the subtle differences between even the most fundamental of commands in the two operating systems