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的更多相关文章
随机推荐
- 关于函数strtok和strtok_r的使用要点和实现原理(一)【转】
本文转载自:http://astute11.blog.51cto.com/4404646/1334198 strtok函数的使用是一个老生常谈的问题了.该函数的作用很大,争议也很大.以下的表述可能与一 ...
- git使用合集
1.git 克隆时重命名本地文件夹或目录 如:git clone https://github.com/torvalds/linux.git linux_kernel 2.git查看tag git t ...
- git clone时,提示warning: remote HEAD refers to nonexistent ref, unable to checkout
一.环境 发行版:Ubuntu 18.04.1 LTS 代号:bionic 内核版本:4.15.0-30-generic 二.背景 git clone https://source.codeauror ...
- ZOJ 2747 Paint the Wall(离散化+暴力)题解
题意:给你一个面,然后涂颜色,问你最后剩多少颜色,每种颜色面积. 思路:第一反应是二维线段树,代码又臭又长,可以做.但是这题暴力+离散化就可以过.可以看到他给的n只有100,也就是说最坏情况下会涂10 ...
- 【web】支持jsp+mvc访问
直接使用SpringMVC时配置访问jsp页面时很容易的事,但是由于spring Boot使用内嵌的servlet容器,所以对jsp的支持不是很好,而且也不建议使用jsp,但是为了满足这种返回jsp页 ...
- mac上 sublime的配置,支持c++11且支持输入
首先下载mac版本的 sublimetext3 下载链接: https://www.sublimetext.com/3 接着可以按照其他博客的方法来安装一些插件,便于我们的工作和学习 安装sublim ...
- flutter 安装详细教程
Flutter 是 Google 用以帮助开发者在 iOS 和 Android 两个平台开发高质量原生 UI 的移动 SDK.Flutter 兼容现有的代码,免费且开源,在全球开发者中广泛被使用. 安 ...
- 一个故意消耗内存的java程序MemoryEater
公司提供的测试服务器是vmware的,号称给我6G, 物理内存事实上是按需分配的. 等到真正拿到6G物理内存,黄花菜都凉了. 看到下面的文章,觉得故意用java程序侵占6G内存, 然后把侵占到内存的释 ...
- SpringMVC注解@RequestMapping @RequestParam @ResponseBody 和 @RequestBody 解析
SpringMVC Controller层获取参数及返回数据的方式: @RequestMapping @RequestMapping(“url”),这里的 url写的是请求路径的一部分,一般作用在 C ...
- Java网络编程和NIO详解7:浅谈 Linux 中NIO Selector 的实现原理
Java网络编程和NIO详解7:浅谈 Linux 中NIO Selector 的实现原理 转自:https://www.jianshu.com/p/2b71ea919d49 本系列文章首发于我的个人博 ...