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的更多相关文章

随机推荐

  1. HBase优化相关

    1.HBase预分区 HBase在创建表时,默认会自动创建一个Region分区.在导入数据时,所有客户端都向这个Region写数据,直到这个Region足够大才进行切分.这样在大量数据并行写入时,容易 ...

  2. jz2440-uboot-201204版本移植【学习笔记】【原创】

    平台:jz2440 作者:庄泽彬(欢迎转载,请注明作者) 说明:韦东山二期视频学习笔记 交叉编译工具:arm-linux-gcc (GCC)4.3.2 PC环境:ubuntu18.04 一.uboot ...

  3. python 三维数组找最小值

    #声明三维数组 num=[[[,,],[,,],[,,]], \ [[,,],[,,],[,,]]] value=num[][][]#设置main为num数组的第一个元素 ): ): ): if(va ...

  4. auth权限认证详细讲解

    auth权限认证详细讲解 一.总结 一句话总结:四表两组关系,一个多对多(权限和用户组之间)(多对多需要3个表),一个一对多(用户和用户组之间) 1.实际上使用Auth是需要4张表的(1.会员表 2. ...

  5. linux系统时间获取方式

    Linux 操作系统计算系统时间:主要函数:time  localtime  gmtime  asctime  ctime  mktime                    difftime  s ...

  6. UVA-11212 Editing a Book (IDA*)

    题目大意:将一个数字序列以最少的剪切次数粘贴成另一个数字序列. 题目分析:很显然,最坏的情况是需要n-1次剪切,搜索层数不多,但每一层的状态数目又非常庞大,适宜使用IDA*.考虑每一个序列后续不正确的 ...

  7. 208. Implement Trie (Prefix Tree) -- 键树

    Implement a trie with insert, search, and startsWith methods. Note:You may assume that all inputs ar ...

  8. Collections中的各种方法

    一.各种方法介绍 Counter 统计个数   elements  most_common  subtract defaultdict 字典默认值 ChainMap  合并多个映射对象(字典) Ord ...

  9. Qt enum使用总结

    一.enum 自省 const QMetaObject &mo = [ClassName]::staticMetaObject; int index = mo.indexOfEnumerato ...

  10. 在JavaScript中进行文件处理,第二部分:文件读取

    译注:原文是<JavaScript高级程序设计>的作者Nicholas Zakas写的,本翻译纯属为自己学习而做,仅供参考.原文链接:这里 在我的前一篇blog中,我介绍了在JavaScr ...