# block-shift **Repository Path**: peace-yang/block-shift ## Basic Information - **Project Name**: block-shift - **Description**: 通用的磁盘级迁移工具 - **Primary Language**: Go - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2025-06-08 - **Last Updated**: 2026-08-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # block-shift 磁盘迁移工具,用于磁盘级别备份、迁移。让磁盘迁移如文件传输般简单。 ## 特性 - 操作简单,命令行美观 - 高性能分片传输,支持并发 - 支持 zstd 压缩,降低网络带宽占用 - 支持断点续传,重启后自动跳过已完成分片 - 系统信息采集(os、cpu、memory、disk、network) ## 快速开始 ### 配置 编辑 `config.json`: ```json { "Agent": "127.0.0.1:8700", "Target": "127.0.0.1:8800", "TaskTimeout": 1000, "GoroutineNum": 4, "EnableMonitor": false, "EnableCompress": true, "EnableCheckpoint": true, "CheckpointDir": "/var/run/block-shift", "ListenAddr": ":8800", "UseHttps": false, "Version": "0.0.1" } ``` ### 目标端启动 ```bash cd target/ && go build && ./target ``` ![Target](examples/target.png) ### 源端启动 #### 查看设备信息 ```bash cd agent/ && go build # 查看系统信息 ./agent inspect os ./agent inspect cpu ./agent inspect disk ``` #### 迁移磁盘 ```bash ./agent replicate --source_dev /dev/sda --target_dev /dev/sdb ``` ![Agent-Replicating](examples/agent-replicating.png) ![Agent-Replicated](examples/agent-replicated.png) ## 命令行 ``` $ ./agent -h A linux migration tool for disk roaming. Usage: block-shift [flags] block-shift [command] Available Commands: help Help about any command inspect Inspect local system replicate Replicate disk to remote host validate Validate target info version Print the version number of block-shift Flags: -a, --author string author name (default "YOUR NAME") --config string config file path (default "./config.json") -h, --help help for block-shift -l, --license string license for the project --viper use Viper for configuration (default true) ``` ## 内存占用 2核2G内存的阿里云虚拟机测试上,默认配置,4MB分片,4个工作协程\ CPU+40%,进程内存占用峰值 220+MB 左右。 ## 外部引用 - github.com/gin-gonic/gin - github.com/go-resty/resty/v2 - github.com/schollz/progressbar/v3 - github.com/shirou/gopsutil/v3 - github.com/spf13/cobra - github.com/klauspost/compress — zstd 压缩 - github.com/zeebo/xxh3 — xxh128 校验