Create a big file

Post Reply
mister_v
Posts: 137
Joined: Sat Jun 20, 2009 5:42 pm

Create a big file

Post 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.
Chris
Site Admin
Posts: 127
Joined: Mon Jul 21, 2008 9:45 am
Location: Leuven, Belgium
Contact:

Re: Create a big file

Post 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
Post Reply