Page 1 of 1

Create a big file

Posted: Sat Aug 15, 2015 7:09 pm
by mister_v
Hi,

I want to create a big file 20G,
I tired it with fallocate, but it didn't work:

Code: Select all

fallocate -l 20G /path/file
fallocate failed: Operation not supported
Does any one know how to do it?
I want to create a file container to use with dm-crypt.

Re: Create a big file

Posted: Sat Aug 15, 2015 7:26 pm
by Chris
If sparse files are ok for you,
Like in your case: you want to create an image in order to populate it with a file system.

Code: Select all

dd if=/dev/zero of=/path/file bs=1G seek=20 count=0
If you check it with ls, you'll see its real size is 0 Bytes

Code: Select all

ls -lsh
You can now create th crypto container for dm-crypt

Code: Select all

cryptsetup -y luksFormat /path/file
Open it:

Code: Select all

cryptsetup luksOpen /path/file volume1
and create the flie-system

Code: Select all

mkfs.ext4 -j /dev/mapper/volume1
after that you can mount it and use it

Code: Select all

mount /dev/mapper/volume1 /mnt/crypto