TechTip: Find Physical Location of a file on disk
When you create a file, it’s stored in different blocks/locations of the filesystem/disk depending upon the size of the file. Though you don’t need to know the physical location of the disk in normal scenarios, but you might need it in things like, to understand the filesystem layout and how file is stored on the filesystem or to do performance tests.
Finding the physical location of the file can be achieved by following commands:
- filefrag: This command will give you information about the filesystem type, file size, blocks occupied and details about the block.
- debugfs: This command will give you all the information, what is stored in the inode and some more information about the storage of the file on the disk block.
# filefrag -v apache-maven-3.0.4-bin.tar.gz Checking apache-maven-3.0.4-bin.tar.gz Filesystem type is: ef53 Filesystem cylinder groups is approximately 1041 Blocksize of file apache-maven-3.0.4-bin.tar.gz is 4096 File size of apache-maven-3.0.4-bin.tar.gz is 4873043 (1190 blocks) First block: 29080227 Last block: 29995919 Discontinuity: Block 1 is at 29080230 (was 29080227) Discontinuity: Block 2 is at 29080233 (was 29080230) Discontinuity: Block 3 is at 29080383 (was 29080233) Discontinuity: Block 5 is at 29080390 (was 29080384) Discontinuity: Block 9 is at 29080458 (was 29080393) Discontinuity: Block 11 is at 29080462 (was 29080459) Discontinuity: Block 12 is at 29080521 (was 29080463) Discontinuity: Block 14 is at 29080528 (was 29080522) Discontinuity: Block 16 is at 29080532 (was 29080529) Discontinuity: Block 22 is at 29080539 (was 29080537) Discontinuity: Block 24 is at 29081169 (was 29080540) Discontinuity: Block 25 is at 29081801 (was 29081169) Discontinuity: Block 26 is at 29081822 (was 29081801) Discontinuity: Block 29 is at 29082798 (was 29081824) Discontinuity: Block 31 is at 29088883 (was 29082799) Discontinuity: Block 33 is at 29089637 (was 29088884) Discontinuity: Block 36 is at 29089652 (was 29089639) Discontinuity: Block 40 is at 29990970 (was 29089655) Discontinuity: Block 152 is at 29991090 (was 29991081) Discontinuity: Block 280 is at 29993586 (was 29991217) Discontinuity: Block 536 is at 29993906 (was 29993841) Discontinuity: Block 1046 is at 29995776 (was 29994417) apache-maven-3.0.4-bin.tar.gz: 23 extents found, perfection would be 1 extent
# debugfs -R "stat /home/manish/apache-maven-3.0.4-bin.tar.gz" /dev/sda3 debugfs 1.39 (29-May-2006) Inode: 14535065 Type: regular Mode: 0644 Flags: 0x0 Generation: 485977245 User: 0 Group: 0 Size: 4873043 File ACL: 0 Directory ACL: 0 Links: 1 Blockcount: 9544 Fragment: Address: 0 Number: 0 Size: 0 ctime: 0x5045dbe1 -- Tue Sep 4 16:15:53 2012 atime: 0x5045dbee -- Tue Sep 4 16:16:06 2012 mtime: 0x4f153600 -- Tue Jan 17 14:19:04 2012 BLOCKS: (0):29080227, (1):29080230, (2):29080233, (3-4):29080383-29080384, (5-8):29080390-29080393, (9-10):29080458-29080459, (11):29080462, (IND):29080463, (12-13):29080521-29080522, (14-15):29080528-29080529, (16-21):29080532-29080537, (22-23) :29080539-29080540, (24):29081169, (25):29081801, (26-28):29081822-29081824, (29-30):29082798-29082799, (31-32):29088883-29088884, (33-35):29089637-29089639, (36-39):29089652-29089655, (40-151):29990970-29991081, (152-279):29991090-29991 217, (280-535):29993586-29993841, (536-1035):29993906-29994405, (DIND):29994406, (IND):29994407, (1036-1045):29994408-29994417, (1046-1189):29995776-29995919 TOTAL: 1193
*** To know more about Filesystem inodes, refer to this article: Understanding Linux / Unix Filesystem Inode
References:
If you enjoyed this post, make sure you subscribe to my RSS feed!!!!