-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(handler): add partclone handler #1155
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job :)
Instead of adding patches on top of unlob package available on nixpkgs, we keep our own package.nix version here so that it's easy to add new third party dependencies that new handlers may require. It also makes it easier to upstream it since we just have to submit the package.nix file to nixpkgs.
Partclone is a utility used for backing up and restoring partitions. Many cloning tools (such as Clonezilla) rely on it to create block-level images that include filesystem metadata. Right now only partclone version 2 is supported. end offset is computed from data available in partclone's super block. Extraction is performed by `partclone.restore`, which is part of `partclone` package on Debian based systems and Nix.
partclone is not available on OSX in nixpkg - https://github.com/onekey-sec/unblob/actions/runs/14124724723/job/39571274718?pr=1155 Would need to provide a patch for https://github.com/NixOS/nixpkgs/blob/e6057380b59bdf9a3693ca3ef45d67e6a95a0d66/pkgs/by-name/pa/partclone/package.nix. Will look into it. It will take some time since I need to spin up some VMs. |
I looked into partclone, it can't be built on OSX. It depends on libraries that are only available on Linux (e.g. We need the ability to tag handlers as unsupported on OSX so their test is not run when testing on that platform. Ideas welcome. |
Partclone is a program similar to the well-known backup utility "Partition Image" a.k.a partimage. Partclone provides utilities to save and restore used blocks on a partition and is designed for higher compatibility of the file system by using existing libraries, e.g. e2fslibs is used to read and write the ext2 partition.
Partclone now supports ext2, ext3, ext4, hfs+, reiserfs, reiser4, btrfs, vmfs3, vmfs5, xfs, jfs, ufs, ntfs, fat(12/16/32), exfat, f2fs, nilfs.
Partclone has two version. This handler supports the second one and automatically checks the endian value.
Create partclone image:
partclone.[file_system] -F -c -s [source_file] -o [output.img] -L /dev/stdout[default=/var/log/partclone.log]
Restore partclone image:
partclone.restore -W -r -s [source_fiile.img] -o [restored.img] -L /dev/stdout[default=/var/log/partclone.log]
Notes
-L
should be used since it will lead in the most cases to errors.img
The header has the following structure :
Unblob parses the header to determine the start and end offset by adding:
Block size
*Blocks per checksum
. Each N-Bytes a 4 byte checksum will occur (min: 1)Finally the
CRC32
value in the header does not the final XOR with0xFFFFFFFF
. This can lead to deviation if checked manually.[Sources]
https://github.com/Thomas-Tsai/partclone
https://partclone.org/
https://wiki.osdev.org/Ext2
https://piazza.com/class_profile/get_resource/il71xfllx3l16f/inz4wsb2m0w2oz
https://www.science.smith.edu/~nhowe/262/oldlabs/ext2.html
https://www.science.smith.edu/~nhowe/262/oldlabs/kernel/ext2_fs.h