How to create a dir with a size of 15 MiB without any files?

Hello guys I got an interesting task to create a dir without any files and even “invisible” files in it , but it should be 15 MiB. There is a scrypt to check it and it checks by using du , so I need help in this task

Is this some task you have been assigned by your teacher?, if so do your own homework.

2 Likes

It’s not my homework , it’s an additional task for people who want it, I am interested in it so I want to know how to do it, if you don’t want to help me you can just keep silence

Try reading this How to create limited-size directory - DEV Community

You have to keep adding files to that directory until it has grown to the wanted size, and then remove all the files again.

1 Like

No, because the file system is tmpfs

Oh sorry didn’t add this description to the post :A directory /tmp/empty must be created in the file system /tmp, and has a size of at least 15 MiB

something like that:

sudo /bin/mount -o size=15M --bind /run/user/1000/some_folder /some/local/folder

didn’t help

if you dont post exactly what you tried (and the result/error/etc) we won’t be able to help.

with my command I mount 2 tmpfs on each boot

sudo mkdir -p /run/user/1000/some_folder
sudo mount -t tmpfs -o size=15M none /run/user/1000/some_folder
sudo umount -lf /some/local/folder 2>/dev/null
sudo rm -rf /some/local/folder
sudo mkdir -p /some/local/folder
sudo /bin/mount -o size=15M --bind /run/user/1000/some_folder /some/local/folder
df -h /some/local/folder
none 15M 0 15M 0% /some/local/folder
there is 0 used memory

That shows the size of the filesystem you created by

sudo mount -t tmpfs -o size=15M none /run/user/1000/some_folder

And after bind-mounted on top of /some/local/folder. /some/local/folder will still be the same tmpfs file system you created as /run/user/1000/some_folder.

1 Like