menuimage

Description

Exit_Codes

Usage

Example

Options

Dependencies

License

Changelog

Download

My_Other_Sites

My_Programs

Comments

disk-wiper v1.3 [18 Mar 2016] by Dominic

Description

A Linux/GNU program to securely wipe, repartition and reformat, and then check disk drive[s] - typical usage scenario is before reselling or discarding a drive. Please be very careful when specifying the drive to be used; otherwise you may lose your data or hose your system!

disk-wiper.sh uses various open source utilities (primarily shred and badblocks) and is designed for wiping spinning-platter disks whether connected by USB, SATA, or PATA/IDE (I believe that for an SSD or flash drive the shredding action may be a waste of time and will shorten the life of the disk). The machine does not need to be rebooted before or after disk-wiper.sh runs, and you can continue using the machine while it runs. All partitions on the selected drive(s) must be unmounted.

disk-wiper.sh (which must run as root) shreds, repartitions and reformats whole disk drive(s) - including wiping the master boot record (MBR) - and then checks them for bad blocks. Shredding is the process of repeatedly writing random data to the drive so that any previous data on it cannot be recovered. Bad blocks are unreliable physical areas of the disk and although they can be identified and 'blocked' - which is done by this program - they are usually a sign of impending wider problems with the drive.

disk-wiper.sh may take a long time to complete. On my machine with a 320GB drive attached by USB2.1, and using the default options (i.e. perform shredding and bad-block checking), it needed 20.5 hours. While the initial 3 shredding passes are in progress you may be able to estimate the total time by calculating the expected time to complete one pass and multiplying by 8.7. I suggest you run it inside a screen session.

After running with a report of no bad blocks (exit code 0), the disk(s) can be regarded as being in perfect working order and passed to a third party as working drive(s) without fear of data recovery in normal circumstances (i.e. recovery would be difficult and limited at best - even with substantial resources).

Warning! disk-wiper.sh is not compatible with GPT-based disks!

Exit Codes

0 No problems, completed successfully, no bad blocks found
1 Illegal option specified on command line
2 Aborted by user at initial stage, or timed out without running
3 One or more bad blocks encountered on a drive
4 A fatal problem occurred shredding a drive
5 A fatal problem occurred partitioning a drive or wiping MBR
6 A fatal problem occurred checking drive partitioning
7 A fatal problem occurred reformatting a drive
8 A fatal problem occurred checking the drive for bad blocks

Usage

disk-wiper.sh [options] disk1 [disk2] [disk3] [disk4] [disk5]

Example

disk-wiper.sh -t ext3 /dev/sdb /dev/sdc

Options

-f - skip warning question at beginning
-h - show help and exit
-l - show changelog and exit
-q - quiet, suppress most non-error output
-s - skip disk shredding (faster, unprotected vs data theft) - note that the drive will still be wiped, repartitioned and reformatted
-t format - specify format as ext2/ext3/ext4 (default: ext4)
-x - skip bad-block check (faster, may leave undetected faults)

Dependencies

awk bash badblocks cat dumpe2fs e2fsck grep lsblk [mdadm] mke2fs partprobe [pvs] sed sfdisk shred (but runs ok without dependencies in square brackets, others are checked at runtime)

License

Copyright 2016 Dominic Raferd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Changelog

1.3 [18 Mar 2016] - stop if attempt is made to operate on disk with GPT partition table
1.2 [18 Jun 2015] - add mbr-wiping, remove DOS-compatible partitioning (sfdisk -D), improved help, add changelog, remove usb-suspend code (which no longer works in current kernels)
1.0810 [10 Aug 2012] - long-standing version

Download disk-wiper.sh

My Other Sites

My Programs

Here is a selection of some (other) programs I have written, most of which run from the command line (CLI), are freely available and can be obtained by clicking on the links. Dependencies are shown and while in most cases written for a conventional Linux server, they should run even on a Raspberry Pi, and many can run under Windows using Cygwin. Email me if you have problems or questions, or if you think I could help with a programming requirement.

Backup Utilities

Debian/Ubuntu kernel and LVM Utilities

Dellmont / Three / Giffgaff / Vodafone - VoIP and Mobile Phone Account Utilities

Miscellaneous Programs

Comments

No comments yet
*Name:
Email:
Hide my email
*Text:
 
Powered by Scriptsmill Comments Script