Files
Linux/存储/磁盘清理.md
offends cee91802b3
Some checks failed
continuous-integration/drone Build is failing
synchronization
2025-08-25 15:57:40 +08:00

37 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

> 本文作者:丁辉
# 磁盘清理
- Wipefs 清理
```bash
wipefs -af /dev/sdb
```
- **`wipefs`**: 这是一个用于清除存储设备上的文件系统、RAID 或分区表标记(如 NTFS、FAT、EXT4 等)的命令。它可以使设备“空白”,但不会销毁设备内的数据。
- **`-a`**: 这个选项指示 `wipefs` 清除所有可识别的标记类型。这是确保从设备中删除所有已识别的文件系统和卷标记的一种方式。
- **`-f`**: 这个选项强制执行删除操作,不需要对每个删除操作进行确认。这使得过程不需交互,适用于脚本或其他自动化环境中。
- Dd 清理
- 将前100MB的磁盘空间写为零这可能用于快速清除磁盘的开始部分常见于需要删除分区表或启动信息的场景。
```bash
dd if=/dev/zero of=/dev/sdb bs=1M count=100
```
- 将磁盘上原有的数据被彻底删除,常用于数据隐私保护。
```bash
dd if=/dev/zero of=/dev/sdb bs=1M status=progress
```
- Sgdisk 清理
```bash
sgdisk -Z -g /dev/sdb
```
- `sgdisk`: 这是一个用于处理GPTGUID Partition Table分区表的命令行工具。
- `-Z`: 这个选项用于清除所有分区的备份GPTGUID Partition Table
- `-g`: 这个选项用于生成一个空的GPT分区表。