fallocate failed: Operation not supported

35,580

Solution 1

If sparse files are ok for you (e.g. you want to create an image in order to populate it with a file system), they are created in no time at all

100GB take 3 milliseconds:

# time dd if=/dev/zero of=tmptst.dat bs=1G seek=100 count=0
0+0 records in
0+0 records out
0 bytes (0 B) copied, 0,00037726 s, 0,0 kB/s

real    0m0.003s
user    0m0.000s
sys 0m0.002s

The resulting file:

# ls -lh tmptst.dat
-rw-r--r-- 1 root root 100G 2015-01-22 16:39 tmptst.dat

Its real size at the moment: 0 Bytes

# ls -lsh tmptst.dat
0 -rw-r--r-- 1 root root 100G 2015-01-22 16:39 tmptst.dat

Solution 2

I also ran into this problem.

A symbolic link in the directory path seems to be the problem. try the same command on /tmp and it should work.

I was able to get around the problem by adding a '-x' to the fallocate command. This forced 'posix mode', and it supposed to take longer.

Even though the filesystem was ext4 the symbolic link was causing the 'not supported on this filesystem' error. In fact if I went directly to the directory name ( without any symbolic links ), the fallocate() call did work.

A1: don't have symbolic links anywhere in the full path name of the file you are creating.

A2: use the '-x', even though it takes longer.

b\375

Solution 3

If you do not care about the content but just need some data,

First do,

dd if=/dev/urandom of=tmp.txt bs=1M count=1

It will create,

-rw-r--r-- 1 root root 1.0M Oct 17 00:30 tmp1.txt.

Then, if you like to create a 10M file, use the above generated file for append repeatedly,

for i in {1..10}; do dd if=tmp.txt of=tmp1.txt bs=1M oflag=append conv=notrunc; done;
Share:
35,580

Related videos on Youtube

John J Johnson
Author by

John J Johnson

Updated on September 18, 2022

Comments

  • John J Johnson
    John J Johnson over 1 year

    When running,

    fallocate -l 10G /path/to/file
    

    I'm returned the following error:

    fallocate: file: fallocate failed: Operation not supported
    

    Creating the file using dd (if=/dev/zero or if=/dev/urandom) works, but if I'm trying to create large files, tens of GBs in size, it takes several hours to complete.

    Running Ubuntu 14.04. Using an ext4 partition, specifying a file-type doesn't appear to alter the outcome.

    Working fine on my CentOS6 machines, just not Ubuntu.

    • Admin
      Admin over 9 years
      which file system you are using?
    • Admin
      Admin over 9 years
      Also update us the type of file you are creating.
    • Admin
      Admin over 9 years
      Using ext4, file type doesn't appear to matter. Whether I'm creating a blank file, a .txt, an .img, I receive the same error.
  • John J Johnson
    John J Johnson over 9 years
    It was in regards to creating a dm-crypt/LUKS container, operating under the assumption that creating a container using /dev/urandom would be more secure than creating one with /dev/zero and gradually filling it with data. I've since learned using fallocate wouldn't have solved my problem regardless, as the slow speed was simply a limitation of how fast the pRNG of /dev/urandom works, but I still have no idea why fallocate itself refuses to work. Cheers for the response though, accepted as I imagine after all this time it's the best response I'll get haha.
  • unfa
    unfa about 5 years
    I wonder if fallocate can't fallback to do the same thning? That'd make sense to me.