how to store a file in continuous disk block in linux

block, filesystems, linux, store

Solution

Disk partitions are continuous regions of a disk.

So one way to do what you want to do is to resize your disk partitions and create a new one with gparted (gnome) or partitionmanager (kde) or similiar - of an appropriate size for your file.

You can then write directly to your new partition (not using and bypassing a filesystem) by using the file:

/dev/sdxn

Where sdxn = {sda1, sda2, ..., sdb1, ... ...} etc. is the letter/number of the partition.

Alternatively you can set aside an entire disk by writing directly to it (bypassing partition table alltogether) using the file:

/dev/sdx

Where sdx = {sda, sdb, sdc, ...} etc. is the letter of the disk.

Warning: Don't make a typo and write to the wrong one (that has a filesystem on it) or you will corrupt it. Best to make a symbolic link ln -s /dev/sdxn /home/fred/mydata, and then always write to mydata file.

Problem

I want store some data on the disk in linux. I want this data stored in continuous disk block in physical disk. If i in order write this data to a normal file, maybe the block that the file occupies is not continuous in physical disk. Is there any way to do this job?

Original source