I was experimenting around with filesystems in linux. I want to understand a few issues. Here are the commands that I have used:
truncate disk.img -s 1M
mkfs.vfat -F12 -S512 -s1 disk.img
#I have made a FAT12 filesystem on a simple 1 MB file in my home directory
Now I can mount my file with:
sudo mount disk.img /mnt
Why do we use sudo here?? I cannot mount without sudo
Now I copy a file spanning 2 clusters to the mountpoint:
sudo cp file.bin /mnt
Then I umount the disk:
sudo umount /mnt
I use a hex editor like ghex to view what exactly has happened after all this:
ghex disk.img
In the FAT, I see the following (RAW format):
(Beginning from byte 0x200, after the bootsector)
f8ff ff00 4000 ff0f 0000 0000 ..........
Here's my main question: I thought that FAT12 used 1.5 bytes per cluster in the FAT, but it seems to be using 2? (I'm not sure about this, maybe I don't understand FAT12 that well)
sudois a different issue. Mounting affects the whole OS, it deals with the kernel, the result is seen by all users. Such "global" actions normally require root access. The root may provide tools to mount FUSE. Any FUSE is operated by a userspace program, so it's not "global". For FAT it'sfusefat(at least in Debian,fusefat disk.img ~/mnt/ -o rw+to mount,fuser -u ~/mnt/to unmount). Please see this. – Kamil Maciorowski Dec 27 '19 at 11:01