{"id":19212534,"url":"https://github.com/fasterthanlime/read-raw-ext4","last_synced_at":"2025-05-12T20:39:01.927Z","repository":{"id":140267218,"uuid":"612717530","full_name":"fasterthanlime/read-raw-ext4","owner":"fasterthanlime","description":"Code sample for \"Reading files the hard way Part 3\"","archived":false,"fork":false,"pushed_at":"2023-03-11T20:25:55.000Z","size":20,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-20T17:40:24.430Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fasterthanlime.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"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},"funding":{"github":["fasterthanlime"]}},"created_at":"2023-03-11T19:12:23.000Z","updated_at":"2024-04-23T16:08:07.000Z","dependencies_parsed_at":"2023-05-27T15:30:22.013Z","dependency_job_id":null,"html_url":"https://github.com/fasterthanlime/read-raw-ext4","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fasterthanlime%2Fread-raw-ext4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fasterthanlime%2Fread-raw-ext4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fasterthanlime%2Fread-raw-ext4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fasterthanlime%2Fread-raw-ext4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fasterthanlime","download_url":"https://codeload.github.com/fasterthanlime/read-raw-ext4/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253817595,"owners_count":21969007,"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-11-09T13:47:15.915Z","updated_at":"2025-05-12T20:39:01.906Z","avatar_url":"https://github.com/fasterthanlime.png","language":"Rust","funding_links":["https://github.com/sponsors/fasterthanlime"],"categories":[],"sub_categories":[],"readme":"# read-raw-ext4\n\nRust code sample to read an ext4 partition from Rust, for:\n\n  * \u003chttps://fasterthanli.me/series/reading-files-the-hard-way/part-3\u003e\n\n## Usage\n\nDon't.\n\nThis opens a raw ext4 partition, in read-only mode because I'm cautious, but\nstill, it needs to run as root and you should REALLY make sure it does what you\nthink it does before running it.\n\nSo:\n\n  * **If you lose data by running this, I can't be held responsible**\n  * This is only designed to work on Ext4 partitions\n  * This was tested exactly twice (on a 2019 Manjaro install and a 2023 Ubuntu install)\n\nWith that disclaimer out of the way, here's how I run it.\n\nFirst, we find out what our root partition is:\n\n```shell\n$ df -Th /             \nFilesystem     Type  Size  Used Avail Use% Mounted on\n/dev/sda3      ext4  548G   97G  424G  19% /\n```\n\nMine's `/dev/sda3`, and it's `ext4`, so this tool might work. Time to build it:\n\n```shell\n$ cargo build --release\n(cut)\n```\n\nAnd run it:\n\n```shell\n$ sudo RUST_BACKTRACE=1 ./target/release/read-raw-ext4 /dev/sda3\n(Directory) Inode {\n    mode: 40755,\n    size: 4096,\n}\n(Directory) Inode {\n    mode: 40755,\n    size: 12288,\n}\n(Regular) Inode {\n    mode: 100644,\n    size: 220,\n}\n---------------------------------------------\n127.0.0.1       localhost\n127.0.1.1       sonic\n\n# The following lines are desirable for IPv6 capable hosts\n::1     ip6-localhost ip6-loopback\nfe00::0 ip6-localnet\nff00::0 ip6-mcastprefix\nff02::1 ip6-allnodes\nff02::2 ip6-allrouters\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffasterthanlime%2Fread-raw-ext4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffasterthanlime%2Fread-raw-ext4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffasterthanlime%2Fread-raw-ext4/lists"}