{"id":17101399,"url":"https://github.com/hackerb9/lba2file","last_synced_at":"2025-07-10T10:33:35.897Z","repository":{"id":113746313,"uuid":"170629569","full_name":"hackerb9/lba2file","owner":"hackerb9","description":"Given a raw sector number on a disk, report which file uses that sector","archived":false,"fork":false,"pushed_at":"2020-05-28T22:59:51.000Z","size":19,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-29T02:44:28.093Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hackerb9.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-14T04:56:33.000Z","updated_at":"2024-11-25T12:56:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"b0b70884-ae91-4e55-a9dc-baf01ee4d980","html_url":"https://github.com/hackerb9/lba2file","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hackerb9/lba2file","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackerb9%2Flba2file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackerb9%2Flba2file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackerb9%2Flba2file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackerb9%2Flba2file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hackerb9","download_url":"https://codeload.github.com/hackerb9/lba2file/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackerb9%2Flba2file/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264566449,"owners_count":23629172,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T15:25:03.940Z","updated_at":"2025-07-10T10:33:35.890Z","avatar_url":"https://github.com/hackerb9.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lba2file\nGiven a raw sector number on a disk, report which file uses that sector\n\n## Usage\n\n```\nlba2file  [-b]  \u003csector number\u003e  /dev/sdX\n    -b: Use byte address instead of sector\n```\n\n## Example usage with S.M.A.R.T.\n\nIf your hard drive has a bad sector, you may want to find out what file is corrupted before you remap the sector by writing zeros to it. You can do so easily using smartctl and lba2file.\n\n```\nkremvax$ sudo smartctl -C -t short /dev/sdd    \nkremvax$ sudo smartctl -a /dev/sdd | grep '^# 1'\n# 1  Short captive   Completed: read failure   90%   20444   1218783739\n```\n\nThe final number 1218783739 is the disk address in sectors, not bytes:\n\n```\nkremvax$ sudo lba2file 1218783739 /dev/sdd\nDisk Sector 1218783739 is at filesystem block 152347711 in /dev/sdd1\nBlock is used by inode 31219834\nSearching for filename(s)...\nInode           Pathname\n31219834        /home/mryuk/2020-11-03-3045-us-la-msy.jpg\n31219834        /home/mryuk/web/2020-11-03-3045-us-la-msy.jpg\n```\n\n## Discussion\n\nMy script defaults to a sector address (often called \"LBA\") rather than bytes. This is because LBA is what tools like `smartctl` will report when there is a bad block on the drive. However, if you want to specify an address in bytes instead of sectors, just give the -b flag.\n\nTo test that this script is working you can do the reverse, looking up the LBA from the filename using `hdparm --fibmap /foo/bar`.\n\n## Alternatives\n\nYou can do the calculations by hand, if you wish. See the answer to https://superuser.com/questions/490787/reverse-lookup-of-inode-file-from-offset-in-raw-device-on-linux-and-ext3-4/\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackerb9%2Flba2file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhackerb9%2Flba2file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackerb9%2Flba2file/lists"}