I learned that number of inode and datablock is assigned when created,
but for example, if we want "text.txt" this file to be stored in inode number 20 or datablock number 20, can we do it?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
That would be using the raw device (for a given block number).
Opening a specific inode is a different matter. That is neither a conventional raw-device operation nor a file-system operation. You might want to do this to recover a deleted file; there are a few tools which can do this. But writing to a given inode is not a good thing to do (unless you are writing a device driver), because that bypasses the rest of the system, with its integrity checks.
Use lsof to determine the inode number of the file install icat (Google icat-sleuthtools)... for ubuntu it's apt-get install sleuthtools then use icat to copy the file to the new location: icat -hf ext /dev/xxx > /path/to/copy.file