Giter Club home page Giter Club logo

bmaptool-scan's Introduction

bmaptool-scan

Scan for unallocated blocks in a disk image, and export this information for further use by bmaptool, either by punching holes in the image or by generating a bmap file.

Usage

The script needs quite some Perl packages, which you can easily install using cpanm:

$ cpanm XML::Writer IPC::System::Simple Number::Bytes::Human Switch Clone

Afterwards, run the script on an image, selecting either --bmap or --sparse mode of operation:

# modprobe loop
# bmaptool-scan --bmap $FILENAME.img > $FILENAME.bmap

Running the script as root is necessary to losetup the image, which also needs to have the loop kernel module loaded.

If you're running the script through sudo while using local::lib, it is possible that the PERL5LIB variable is scrubbed and packages are not found. A workaround:

$ sudo PERL5LIB=$PERL5LIB bmaptool-scan ...

Motivation

See this blog post for an explanation. The short version: bmaptool create relies on file sparseness to generate a bmap file, but these semantics do not map what bmaptool uses them for (return 0 upon read vs. skip writing and return garbage upon read). This script parses the underlying file systems in order to discover the actually unused blocks, which can be safely skipped when writing an image.

TODO

  • Add support for partition images (currently only full-disk images containing partitions are supported).
  • Add support for more file systems.
  • Detect funky partition tables (hybrid images, overlapping partitions), and abort.
  • More robust way of parsing partition table (i.e. don't rely on fdisk output).

bmaptool-scan's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.