I created a file to mount as /tmp dir to limit it's size so it cant crash the system. I used mkfs.ext4 on it and it mounts in /etc/fstab. Now I need to increase the size, so I used fallocate again, and the /tmpfile shows larger now, but when mounted is the same size. I tried a bunch of things, like mounting manually and using resize2fs on the unmounted file and the mounted dir. The former has no errors, but still isnt larger, even after running the suggested e2fsck -f /tmpfile on it.

Any ideas?

I'm not using a loop device as with this answer, nor 2 partitions formated with parted. How to increase the size of a loop virtual disk?

EDIT: As pointed out, mounting a file to a directory uses a loop device by default, even without the mount -o loop option. Using fallocate -l 200M /tmpfile and then resize2fs /dev/loop# worked with the file mounting edited out of the /etc/fstab, rebooting, and then mounting it over the bootup /tmp to check the size, by undoing the fstab edit and using mount -a. Sidenote, I could have mounted it to /mnt to check, but unix/linux deals with overmounting gracefully: What happens when you 'mount over' an existing folder with contents?, though it seems there could be more conflicts when overmounting the home directory, but perhaps not.

  • The size will be determined by the filesystem on it. This suggests that using resize2fs was probably the correct approach. Maybe, since this is for /tmp, jusr run mkfs.ext4 on the file as you probably don't need any of the existing files. The file should not be mounted whilst you are doing this.
    – icarus
    Jan 13, 2022 at 3:43
  • You are using a loop device, it was set up for you automatically. lsblk should show it, and then you can follow the answer to the linked question to solve your problem. Jan 13, 2022 at 5:37
  • @icarus I'm trying /tmp first before resizing /home/user, so I want to avoid mkfs. It did finally work with resize2fs when using it on the /dev/loop1 device.
    – alchemy
    Jan 13, 2022 at 20:28
  • @StephenKitt, thanks for the comment.. lsblk did help me find the /tmpfile wasnt expanded from 30M to 300M because it is in human readable by default. (I couldve swore I used df -h to verify). Anyway, it does work now. Not sure what the difference is/was. I did follow the other link this time after you pointed out it is mounted to a loop device even without the mount -o loop option, thanks. I'll edit in what I did and you can use that as an answer if you like.
    – alchemy
    Jan 13, 2022 at 20:33
  • Feel free to write it as an answer, it’s perfectly OK to answer one’s question oneself! Jan 13, 2022 at 21:29


You must log in to answer this question.

Browse other questions tagged .