- C 70.3%
- Python 11.2%
- Shell 9.8%
- C++ 8%
- Makefile 0.5%
- Other 0.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
Snapshot(freeze_fs=True) sets the freeze flag so a mounted ext4 is clean at the snapshot instant; a device with no freezable filesystem raises UnsupportedDevice(FreezeUnsupported). Python bindings, fake driver and tests updated; kernel probe/Makefile and CI tweaks and a kernel watch script included. |
||
| bindings | ||
| docker | ||
| docs | ||
| examples | ||
| kernel | ||
| lib | ||
| LICENSES | ||
| packaging | ||
| results | ||
| scripts | ||
| tests | ||
| tools | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| AGENTS.md | ||
| CLAUDE.md | ||
| COMPARISON.md | ||
| dkms.conf | ||
| FEATURES.md | ||
| LICENSE | ||
| LICENSING.md | ||
| LIMITATIONS.md | ||
| Makefile | ||
| README.md | ||
| sandbox.sh | ||
scradle: freeze-free, mount-transparent block snapshots for Linux
Point-in-time snapshots of live, mounted block devices. No freeze, no unmount, no topology change, nothing copied until something writes.
backup agent production I/O
│ │
│ reads │ writes
▼ ▼
/dev/scradle0 ◀────── serves ──────┐ ┌───────────────┐
(snapshot) │ │ interposer │
│ └───────┬───────┘
┌───────┴──────┐ │ preserve first
│ COW store │◀──────┘
└──────────────┘ │
▼
┌─────────────────┐
│ /dev/sda1 │
│ never written │
└─────────────────┘
A kernel module, a control CLI, a C++ integration library with Python bindings, and a QEMU test harness.
| Suite | Result | Coverage |
|---|---|---|
| Functional | 30/30 kernels | 3.10 (RHEL 7) → 7.2-rc5 |
| Crash | 30/30 kernels | power-cut scenarios, two boots per case |
| Fault injection | 21/21 | 6.12.41 debug kernel |
Quick start
curl -fsSL https://cdn.shadowcradle.com/download/linux-scradle/install.sh | sudo bash
sudo scradlectl attach /dev/sda1
sudo scradlectl snapshot /dev/sda1 /var/tmp/scradle.cow 1G --ceiling=32G
sudo dd if=/dev/scradle0 of=/backup/sda1.img bs=4M
sudo scradlectl release /dev/sda1
sudo scradlectl detach /dev/sda1
The COW file must live off the protected disk (another partition of the same
disk is refused too, EINVAL), unless you
opt in with --on-device (cow_on_device=True in the library), which needs
ext4 or XFS and a fixed size and gives up the guarantee that scradle never
writes to the device it protects; see COMPARISON.md. The
installer detects your distribution, installs or updates the package and runs a
self test; see ONE-LINER.md. Ten minutes from zero to
a backup: QUICKSTART.md.
The snapshot is an ordinary block device. dd, qemu-img, partclone,
mount and fsck all work on it.
Why a kernel module
Constraints: no filesystem freeze, no mount disruption, no change to the user's disk layout. Those rule out every driverless option.
| Approach | No freeze | No mount disruption | No new driver | Any layout |
|---|---|---|---|---|
| Btrfs / ZFS / LVM native snapshots | yes | yes | yes | no, only those layouts |
FIFREEZE + copy |
no | yes | yes | yes |
Transient dm-snapshot insertion |
yes | no, remaps a live mount | yes | yes |
| eBPF | yes | yes | yes | tracking only, cannot redirect writes |
| bio interposition (this module) | yes | yes | one small LKM | yes |
eBPF is the decisive one. Block-layer hooks are observational: they report that a write happened, they cannot hold it back while the original block is copied aside. Copy-on-write without a freeze requires sitting in the write path, and that requires kernel code.
Use this for the layouts nothing else covers: bare ext4 or XFS on a plain partition. On Btrfs, ZFS and LVM, native snapshots are simpler, older and better tested.
The snapshot instant
WRITE_ONCE(dev->snap_active, true); /* that is the whole gate */
One store. No drain, no quiesce, no freeze. Writes arriving after it preserve the old chunk before landing.
Feature map
Full detail in FEATURES.md.
ATTACH ─────────────────────────────────────────────────────┐
├─ change tracking (always) CBT_GET, EXTENTS_GET │
├─ persistent CBT survives reboot │
└─ write-intent log bounds crash damage │
│
SNAP_CREATE ────────────────────────────────────────────┐ │
├─ freeze the filesystem FREEZE_FS │ │
├─ persist across reboot COW_PERSIST │ │
├─ writable overlay WRITABLE │ │
├─ compress the store COW_COMPRESS │ │
├─ store on the traced device COW_ON_DEVICE │ │
└─ one instant, many devices SNAP_CREATE_GROUP │ │
│ │
skip work you do not need ──────────────────────────────┤ │
├─ free-space map FREESPACE_SET │ │
├─ exclusion ranges EXCLUDE_SET │ │
└─ bandwidth ceiling cow_throttle_kbps │ │
│ │
recover ────────────────────────────────────────────────┘ │
└─ roll the device back ROLLBACK (build-off) ──┘
Guarantees
| Property | Enforcement |
|---|---|
| The traced device is never written | Every path except ROLLBACK, a build option, default off |
W ⊆ B |
The reported change set is always a superset of actual changes |
| Fail closed | A snapshot that cannot preserve a chunk is failed, not served |
| Refuse, never guess | Every persisted record is validated and rejected with a named reason |
A failed snapshot is fenced. Reads return EIO rather than a mix of pre- and
post-snapshot data.
Two interposition strategies
Selected at build time by compile probe, never by version number. Enterprise kernels backport aggressively and their version numbers lie.
INTERPOSE_FOPS |
INTERPOSE_MAKE_REQUEST |
|
|---|---|---|
| Kernels | 5.9 and newer | 3.10 through 5.8 |
| Hook | disk->fops->submit_bio |
q->make_request_fn |
| Re-submit | submit_bio_noacct() |
generic_make_request() |
| Needs kallsyms | yes, for blk_mq_submit_bio |
no |
| Return | void (5.16+) or blk_qc_t |
blk_qc_t (4.5+) or void |
grep interpose /proc/scradle-info # fops | make_request
Some probes compile with -Werror and assert that exactly one of a pair
matched. An API that changed signature while staying callable produces a
warning, not an error, and guessing wrong wrote the COW store at a byte
offset equal to the address of a stack variable. See
KERNEL-SUPPORT.md.
Enterprise kernels
| Distro | Kernel | Toolchain | Functional | Crash |
|---|---|---|---|---|
| CentOS 7 / RHEL 7 | 3.10.0-1160.99.1.el7 | gcc 4.8.5, docker/Dockerfile.el7 |
195/209 | 74/74 |
| RHEL 8 / Rocky 8 | 4.18.0-553.154.1.el8_10 | ordinary | 202/209 | 74/74 |
scripts/fetch-kernel.py fetch el7 # vault.centos.org
scripts/fetch-kernel.py fetch el8 # Rocky 8.10 mirror
Pinned to exact builds. RHEL backported across each line for a decade, so a result on one point release is not a result on another. The skips are era limits, each naming its own reason (no io_uring, no discard on virtio-blk before 5.0, filesystem drivers the kernel lacks).
Testing
tests/run_qemu.py --docker # functional, running kernel
tests/run_qemu.py --docker --crash # power-cut scenarios
tests/run_matrix.py --fetched-only --jobs 4 # every provisioned kernel
Nothing is installed on the host and no module is ever loaded into the host kernel. A driver bug panics a guest and nothing else.
A kernel WARNING or oops fails a run even when every test passes. That is how the driver-core glue-directory refcount race on 3.10 was found.
Feature probes are cached between runs (.probe-cache, keyed on the kernel,
probe.sh content and the compiler). A full matrix went from 129 to 53
minutes.
What to attach
A whole disk or a single partition. The choice decides what the snapshot is.
| Attach | /dev/scradle0 is |
Mount with |
|---|---|---|
/dev/sda1 |
that partition's contents | mount /dev/scradle0 /mnt |
/dev/sda |
the whole-disk image, table included | mount /dev/scradle0p1 /mnt |
Attach the partition when backing up a filesystem. Writes to other partitions
of the same disk then set no changed bit and copy nothing into your store.
Under whole-disk tracing a busy neighbour on /dev/sda2 inflates every
incremental of /dev/sda1 and can fill, and so invalidate, its snapshot.
Several partitions of one disk may be traced at once on different slots, with
independent snapshots. Two attaches whose regions overlap are refused with
EBUSY (a whole disk plus one of its own partitions, or the same target
twice). A bio can only be gated once.
Layout
kernel/
scradle_uapi.h stable userspace ABI, copied verbatim into the agent build
compat.h 3.10 to 7.2 API differences, all in one place
probe.sh build-time feature probing; version numbers are not trusted
main.c module init and the /dev/scradle-ctl ioctls
tracer.c bio interposition, CBT, the COW gate
cow.c the COW store, on-device mode, persistence
complz.c the in-module LZ77 codec
overlay.c the writable-snapshot overlay
freespace.c exclusion and free-space range maps
rollback.c merge back onto the origin (SCRADLE_ROLLBACK=y)
rawfile.c preallocated, FIEMAP-resolved files written as raw bios
snapdev.c the snapshot block device
state.c wil.c persistent CBT and the write-intent log
params.c the sixteen module parameters
proc.c sysfs.c debugfs.c the three observability exports
lib/ C++ integration library (libscradle)
bindings/ Python bindings over it
tools/scradlectl.c operator CLI over the ioctl surface
tests/ QEMU harness, guest runner, perf suites
packaging/boot/ dracut and initramfs-tools hooks for boot-time attach
Contributing
Commits are short, lowercase, imperative, no prefixes:
checksum the cow store and verify it on read
never unhook a request-based disk
cache the feature probes between runs
CI runs lint, builds, the kernel matrix from tests/kernels.txt, then the
QEMU suites. Feature probes and kernel payloads are cached across jobs.
Status
Pre-production. 283 assertions across the functional and crash suites, both running on all 30 provisioned kernels.
Read LIMITATIONS.md before deploying. In particular:
- Tracing a request-based disk on 5.9+ pins the module until reboot. This
is deliberate: restoring a NULL
->submit_biounder load panics. ROLLBACKwrites the protected device. Build option, default off, and a merge validates the store's metadata, not its chunk data.- A reopened persisted store cannot verify its inherited chunks.
Documentation
| Document | Answers |
|---|---|
| FEATURES.md | Every feature: what it does, costs, refuses |
| LIMITATIONS.md | What it will not do |
| ARCHITECTURE.md | Interposer, store, snapshot device |
| KERNEL-SUPPORT.md | Range, probes, verification table |
| USAGE.md | Workflows, ioctls, parameters |
| INSTALL.md | Build, DKMS, packaging |
| TESTING.md | Suites and known coverage gaps |
| COMPARISON.md | Against dattobd |
By reader: users, Linux admins, developers. The full map is docs/INDEX.md.
Licence
GPL-2.0-only for the kernel module, AGPL-3.0-only for the userspace components. See LICENSING.md.