Suppose i create one file and store that file on the hard drive. Is it possible to find the location of the file on hard drive in the terms of sector. Like the file is stored at the sectors 33,34 ...
debugfs: stats [...] Block size: 4096 [...] ~$ sudo dd if=/dev/hda7 bs=4096 skip=751206 count=1 | od -c | head -3
1+0 records in
1+0 records out
4096 bytes (4.1 kB) copied, 7.8941e-05 seconds, 51.9 MB/s
0000000 r o o t : x : 0 : 0 : r o o t :
0000020 / r o o t : / b i n / b a s h \n
0000040 d a e m o n : x : 1 : 1 : d a e ~$ sudo fdisk -lu /dev/hda | grep hda7 /dev/hda7 17543043 31214294 6835626 83 Linux ~$ sudo dd if=/dev/hda bs=512 skip=$((751206*8+17543043)) count=8 | od -c | head
-3
8+0 records in
8+0 records out
4096 bytes (4.1 kB) copied, 0.00174803 seconds, 2.3 MB/s
0000000 r o o t : x : 0 : 0 : r o o t :
0000020 / r o o t : / b i n / b a s h \n
0000040 d a e m o n : x : 1 : 1 : d a e
Before you proceed with the questions for the Linux internals, please DO GET a book of the general organization of the kernel, read and understand it.
My favourite for starters:
Daniel Pierre Bovet, Marco Cesati, Understanding the Linux Kernel, 3rd ed, O'Reilly, ISBN 0-596-00565-2.
This book explains also the file system general organization. The exact response to your question depends on the partitioning of the disk and the file system type and parameters.
You can't tell unless you know the file system used.
There are many file systems Linux can use. Some are even compressed and maybe a file can start in the middle of a sector. Moreover even if you know where a file starts it can get very complicated to find where it continues, as with nearly all file systems files can get segmented.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.