Closed antoniprzybylik closed 3 months ago
You can use sync
before umount
You can use
sync
before umount
This does not solve my problem.
The reason for being empty is that the file couldn't be written to the disk in time.
The solution is to use multiple sync
commands or wait for a period of time.
Like this, and it will work.
dd if=/dev/zero of=./IMAGE bs=1M count=50
./mkfs.simplefs IMAGE
mount -o loop -t simplefs IMAGE mnt/
echo "I have a cat." > mnt/file.txt
sync
sync
sync
...
umount mnt/
mount -o loop -t simplefs IMAGE mnt/
If it still doesn't work, please provide me with more information.
The solution is to use multiple
sync
commands or wait for a period of time.
Well... It worked.
I always thought that the sync
command blocks until my data is written to all connected drives. However, it turns out that's not the case. So this is possible that I could execute sync
, wait for it to finish, disconnect a disk, and lose my data? What a disappointment.
When mounting newly created filesystem, creating a file with content "I have a cat.", unmounting, and then remounting the filesystem again, the file remains but its content disappears.
How to reproduce the bug:
Now try to print the contents of the file "mnt/file.txt", it will be empty.