DD wipe command Disk empty shell script, notebook desktop Mac Universal

Source: Internet
Author: User



Tutorial target: DD Wipe command disk empty shell script, notebook desktop Mac Universal


Date: August 20, 2015

Contact e-mail: [Email protected]

Q q Group: 1851 15701

51CTO Blog Home: http://990487026.blog.51cto.com




Production demand:

The number of companies reached a certain number, there will be people flow, and then the attached PC or SERVER,MAC, of course, to completely empty the data inside, install the new WINDOWS,LINUX,MAC system inventory, left to the next ready to use the staff.

The use of this script can greatly reduce the labor force, leaving the computer to get over, insert the prepared U disk, as long as there is computer knowledge, only need to enter Yes or no, you can complete the task of computer disk emptying, greatly improve work efficiency.


One, get started:

1, you need a 8G USB flash drive

2, a Linux distribution CD-ROM, or a USB flash drive with Linux release installed to install Linux to the above 8G USB flash drive



ready!




Second, find a Redhat,centos,frdora release, install to the USB flash drive, in the installation, please note that you must use manual to partition, do not use the default disk volume partition.

1,/boot partition

2,/root partition

3,/home partition

Specifying these three partitions is sufficient







Third, the system is recommended to install the desktop, after the installation is complete, modify the Inittab run level is 3, the default is not open the desktop, want to open on.

Insert USB drive, boot from USB stick

Vim/root/.bashrc

Add a line at the bottom: Bash disk.sh

Save Exit!

vim/root/disk.sh


Copy the contents of the script below and save it.


This allows you to display the disk emptying command directly using root.



Note: When the script runs, there will be a false impression of the card, in fact, it is not stuck, but DD name in the execution of the time do not output any information, after the execution, will show how much time, the speed of the erase is how much.

The disk light is always on until it is empty



============ script starts ===============================

#!/bin/bashclearsetterm -blank 0dateecho  "" Rm -rf diskreadyrm -rf temp1rm  -rf disklisttouch diskreadytouch disklistfdisk -l &>> temp1   for i in {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,r,s,t,u,v,w,x,y,z}   do       # umount disk device        for j in {1..10}      do                   umount /dev/sd$i$j  &>/dev/null      done       #  check once device      mount |grep  "^/dev/sd$i"  & >/dev/null       stat1= ' echo $? '               #check  this device exits       grep  "sd$i"  temp1        stat2= ' echo $? '                 #stat1  localhost disk device         if [  $stat 1 -eq 0 ];then            echo -e   "\033[40;33mskip localhost disk device sd$ I\033[0m\n\n "        else                  #stat2  check this device physcis  disk           if [  $stat 2 -eq  0 ];then                 echo -en "\033[47;30mare you sure destory data for sd$i [y/n] ?\033[0m     "                  read  key                     echo  ""                            case  $key  in             y)                    #add  duty into  lisst             echo  "Sd$i"  &>> diskready                  cat temp1 | grep  "Disk /dev/sd$i"  &>> disklist                 ;;              n)               echo -e  "\033[44;31mgive up destory  Data of sd$i \033[0m\n\n "              ;;              *)               echo -e  "\n\ninput error ,program  Exiting\n\n "                  exit 99                  ;;              esac            fi        fidone            # operation disk       cat disklist  | grep  "S"  &>/dev/null      if [ $? - eq 0 ] ;then                echo -e  "\033[47;31;7m========make sure your operate disk list= =========\033[0m "            cat disklist            echo -en  "\nare you sure  Destory This Disk data [y/n] ?    "            read list                     case  $list  in            y)                 for o in  ' Cat diskready '                 do                echo  "destorying data  $o,  please wating ..."                 dd bs=4096 if=/dev/zero of=/ dev/$o                # wipe  -kq /dev/$o                 done               ;;            n)             echo  "quiting "             exit           ;;            *)             echo  "Input error ,quiting"             ;;            esac      fi      rm -rf diskreadyrm -rf temp1rm -rf disklistecho   "dateread -p " finished ,do you want to reboot this  computer [y/n] ?  " stat3case  $stat 3&NBSp;iny) echo  "reboot your computer ,please waiting&nbsp, ..." reboot; N) echo  "Exit" sleep 1clearexit;; *) echo  "Input error ,quit" sleep 1clearexit;; Esac




============ Script End ===============================

Script is I step out of the school door, when I wrote, not very good, but very practical.


The careful classmate will find that this script can not only use the DD command to empty the disk, but also use the wipe command to clear the disk,

Wipe command I commented, you want to use, you have to manually install a wipe tool.


As for the DD command and the wipe command, compare the safety factor with the emptying speed to see how you compromise speed and safety.


Reference: Use script default DD command, 160G HDD, 70M per second,

With the wipe command, you need to wait about two days.

The DD command is much faster than wipe.


As for the speed of why there is such a big difference, we go to Google.



Thank you for browsing, such as the question of this article, please email [email protected], open source community, you are more exciting!











DD wipe command Disk empty shell script, notebook desktop Mac Universal

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.