shred_linux_unix
Sometimes you need to destroy or wipe data from hard drives (for example, before you sell your old hard drives on eBay) so that nobody else can access them. Simply deleting data (e.g. with rm) is not enough because that just removes the file system pointer, but not the data, so it can easily be undeleted with recovery software. Even zero'ing out your hard drive might not be enough. Here's where shred comes into play - shred can overwrite the files and partitions repeatedly, in order to make it harder for even very expensive hardware probing to recover the data.
I do not issue any guarantee that this will work for you!
1 Preliminary Note
shred can be used to wipe files and also partitions and hard drives. If you take a look at shred's man page...
man shred
... you might notice the following:
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 system 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).
This is something you need to worry about only if you use shred to wipe files. However, as I want to wipe hard drives, I will use shred for whole partitions or hard drives in this tutorial.
2 Using shred
If you want to wipe your system partition, you must boot into a live system (such as Knoppix, the Ubuntu Live-CD, your hoster's rescue system, etc.). This is not needed if you don't want to wipe your system partition.
shred should already be installed (you can check with
which shred
); if it isn't you can install it as follows (Debian/Ubuntu/Knoppix):
apt-get install coreutils
As I said before, I want to use shred on partitions and hard drives. So, for example, to wipe the partition /dev/sda5, you can use
shred -vfz -n 10 /dev/sda5
-v: show progress
-f: change permissions to allow writing if necessary
-z: add a final overwrite with zeros to hide shredding
-n: overwrite N times instead of the default (3)
So this would overwrite /dev/sda5 ten times.
You can also use shred for RAID partitions, e.g.
shred -vfz -n 10 /dev/md1
And to wipe a full hard drive like /dev/sda, you can use
shred -vfz -n 10 /dev/sda
Please note that shred can take a long time, depending on the size of your partitions/hard drives and the number of runs (-n).
shred_linux_unix的更多相关文章
随机推荐
- CentOS7.2 安装Chrome
/etc/yum.repos.d/目录下新建文件google-chrome.repo,向其中添加如下内容: [google-chrome] name=google-chrome baseurl=htt ...
- ZooKeeper增加Observer部署模式提高性能(转)
除了Leader和Follow模式之外,还有第三种模式:Observer模式. Observer:在不伤害写性能的情况下扩展ZooKeeper. 虽然通过Client直接连接到ZooKeeper集群的 ...
- 如何解决Nginx php 50x 错误
SEO反馈百度爬虫经常504,一般情况下是由nginx默认的fastcgi进程响应慢引起的,但也有其他情况,这里我总结了一些解决办法供大家参考. 方法/步骤 一般50x状态码问题分析: Nginx ...
- [参考]用递归的方法获取 字符 对应的 二进制字符串 (C/C++)
将字符转换为16进制字符串.十进制字符串可以参考这里:https://www.cnblogs.com/stxs/p/8846545.html 代码及调试结果 举例:字符'a',查ASCII码表它对应的 ...
- markdown哈哈
function box(){ 世界你好 }
- PHP--------微信网页开发实现微信扫码功能
今天说说微商城项目中用到的扫一扫这个功能,分享一下,希望对各位有所帮助. 前提:要有公众号,和通过微信认证,绑定域名,得到相应信息,appid,appsecret等. 微信开发文档:https://m ...
- poj-2096-期望/dp
http://poj.org/problem?id=2096 有n种病毒,s个服务器,每天等概率的在某个服务器上发现某一种病毒,问发现所有种类病毒且覆盖所有的服务器的期望天数. 利用全期望公式可以将期 ...
- uva-11021-全概率公式
https://vjudge.net/problem/UVA-11021 有n个球,每只的存活期都是1天,他死之后有pi的概率产生i个球(0<=i<n),一开始有k个球,问m天之后所有球都 ...
- 伸展树的基本操作——以【NOI2004】郁闷的出纳员为例
前两天老师讲了伸展树……虽然一个月以前自己就一直在看平衡树这一部分的书籍,也仔细地研读过伸展树地操作代码,但是就是没写过程序……(大概也是在平衡树的复杂操作和长代码面前望而生畏了)但是今天借着老师布置 ...
- oracle非空约束
ALTER TABLE TB_ZJGL_DWSB_GRMX_LOG MODIFY HJQX NULL;