![通过定期删除大量文件来清除可用磁盘空间?](https://linux22.com/image/1155086/%E9%80%9A%E8%BF%87%E5%AE%9A%E6%9C%9F%E5%88%A0%E9%99%A4%E5%A4%A7%E9%87%8F%E6%96%87%E4%BB%B6%E6%9D%A5%E6%B8%85%E9%99%A4%E5%8F%AF%E7%94%A8%E7%A3%81%E7%9B%98%E7%A9%BA%E9%97%B4%EF%BC%9F.png)
我正在寻找一种更好的方法来安全地清理 Ubuntu 系统中的可用空间。我发现此链接还有一些关于清除可用磁盘空间的宝贵建议。我尝试过free disk space
启用选项的 bleachbit 方法。这种方法有两个问题,一个非常慢,另一个它会很快耗尽可用磁盘空间。
我每三天使用 bleachbit 清理一次系统,并free disk space
禁用此功能。此过程每次使用平均会删除数千个文件,而且整个过程非常快。
这更像是一个理论问题;如果我在一个月内执行此清理过程,我大约会删除大约 10000 个文件/月。清理后我是否仍需要清除可用空间?我的想法是,当我删除一些文件时,将在其位置创建新文件。重复此过程时,新文件将覆盖已删除的文件,从而使文件恢复变得不可能。
我的想法正确吗?这可以被视为在 linux/ubuntu 系统中清除可用空间的安全方法吗?
答案1
擦除分区或文件系统的部分内容
删除之前写入的所有痕迹(在现在的自由空间中)并不是一个好主意。
如果其他文件仍然存在,这些文件对于入侵者来说可能非常有趣。
具有日志功能的现代文件系统通常会将信息存储在多个位置,在这种情况下,擦除用于文件的内存空间是不够的。
看man shred
CAUTION: Note that shred relies on a very important assumption: that
the file system overwrites data in place. This is the traditional way
to do things, but many modern file system designs do not satisfy this
assumption. The following are examples of file systems on which shred
is not effective, or is not guaranteed to be effective in all file sys‐
tem modes:
* log-structured or journaled file systems, such as those supplied with
AIX and Solaris (and JFS, ReiserFS, XFS, Ext3, etc.)
* file systems that write redundant data and carry on even if some
writes fail, such as RAID-based file systems
* file systems that make snapshots, such as Network Appliance's NFS
server
* file systems that cache in temporary locations, such as NFS version 3
clients
* compressed file systems
In the case of ext3 file systems, the above disclaimer applies (and
shred is thus of limited effectiveness) only in data=journal mode,
which journals file data in addition to just metadata. In both the
data=ordered (default) and data=writeback modes, shred works as usual.
Ext3 journaling modes can be changed by adding the data=something
option to the mount options for a particular file system in the
/etc/fstab file, as documented in the mount man page (man mount).
In addition, file system backups and remote mirrors may contain copies
of the file that cannot be removed, and that will allow a shredded file
to be recovered later.
擦除整个分区(及其文件系统)或整个驱动器
shred
当您擦除整个分区或整个大容量存储设备(整个驱动器)而不是单个文件或文件之间的驱动器空间时,可以更好地使用其他覆盖工具/方法来使旧信息更难读取。
加密整个文件系统
但我认为最好的方法是用非常好的密码。这样,没有密码就无法读取任何内容,无论是当前文件还是已删除的文件。
警告:如果您忘记了密码,您的数据也会丢失。如果文件系统损坏,则很难恢复。因此你需要一个好的备份,将其存储在安全的地方,并建立良好的备份程序,以保证备份保持最新。
Ubuntu 的安装程序有一个选项“带加密的 LVM”,它使用 LUKS 加密根文件系统。这通常被称为“加密磁盘”。请参阅此链接,