编译Substrate node-template执行cargo build --release时出现磁盘空间不足错误求助
Hey there, sorry you're stuck with this disk space hiccup while compiling the Substrate node-template. Let's work through some practical fixes to get your build back up and running:
1. First, verify your disk is actually full
Run this command to check available space across all your system's partitions:
df -h
Look at the /home row (since your project lives in ~/project/) — if the Use% column is hovering near 100%, that's exactly why you're hitting this error.
2. Clean up Cargo's build artifacts
Cargo piles up tons of intermediate build files in the target directory. Clear your project's local build cache first:
cargo clean
If you want to free up even more space, install the cargo-cache tool to prune global unused dependencies and old build artifacts:
cargo install cargo-cache cargo cache --autoclean
This will wipe out redundant files you don't need anymore.
3. Clear system-level junk from Kali
Free up space by removing unused packages and cached installation files:
sudo apt autoremove --purge sudo apt clean
You can also safely delete temporary files in /tmp (these are usually auto-cleaned, but manual cleanup gives an immediate boost):
sudo rm -rf /tmp/*
4. Redirect the target directory to a partition with more space
If your /home partition is permanently low on space, you can point Cargo's build output to another drive/partition using a symlink:
- Create a directory on the partition with free space (e.g.,
/data):sudo mkdir -p /data/substrate-target sudo chown $USER:$USER /data/substrate-target - Delete the existing
targetfolder in your project:rm -rf ~/project/substrate-node-template/target - Create a symlink linking your project to the new directory:
ln -s /data/substrate-target ~/project/substrate-node-template/target
Now when you run cargo build --release, all build files will go to the space-rich location instead.
5. Hunt down and delete large, unnecessary files
Use the ncdu tool to scan your /home directory and spot big files you can get rid of:
- Install it first:
sudo apt install ncdu - Run it on your home directory:
ncdu ~/
Navigate through the results to find old archives, unused projects, or other large files taking up space, then delete them to free up room.
内容的提问来源于stack exchange,提问作者CocDap

