C3rd
Cleaning HDDs and monitor it
Posted: 24 Jun 2020, 1:21am - Wednesday
I've been assigned to clean up our server hardware and trying to create a monitoring how the progress going.
---------------- s04_wipe.sh ----------------------
#!/bin/bash
# s04
dd if=/dev/zero of=/dev/sdg status=progress
dd if=/dev/urandom of=/dev/sdg status=progress
---------------- s03_wipe.sh ----------------------
#!/bin/bash
# s03
dd if=/dev/zero of=/dev/sdf status=progress
dd if=/dev/urandom of=/dev/sdf status=progress
---------------- s02_wipe.sh ----------------------
#!/bin/bash
# s02
dd if=/dev/zero of=/dev/sde status=progress
dd if=/dev/urandom of=/dev/sde status=progress
---------------- s01_wipe.sh ----------------------
#!/bin/bash
# s01
dd if=/dev/zero of=/dev/sdd status=progress
dd if=/dev/urandom of=/dev/sdd status=progress
---------------- uat_wipe.sh ----------------------
#!/bin/bash
# uat
dd if=/dev/zero of=/dev/sdc status=progress
dd if=/dev/urandom of=/dev/sdc status=progress
---------------- db_wipe.sh ----------------------
#!/bin/bash
# database
dd if=/dev/zero of=/dev/sdb status=progress
dd if=/dev/urandom of=/dev/sdb status=progress
----------------os_wipe.sh ----------------------
#!/bin/bash
# os disk
dd if=/dev/zero of=/dev/sda status=progress
dd if=/dev/urandom of=/dev/sda status=progress
I ran it this way...
nohup bash s02_wipe.sh > sde.out 2>&1 &
then this is my monitoring script (monitor.sh) to check the status:
#!/bin/bash
echo "/dev/sdb: "
echo $(tail -n 1 -c 120 sdb.out) | rev | cut -d "s" -f1,2,3,4| rev
echo -e "\n"
echo "/dev/sdc: "
echo $(tail -n 1 -c 120 sdc.out) | rev | cut -d "s" -f1,2,3,4| rev
echo -e "\n"
echo "/dev/sdd: "
echo $(tail -n 1 -c 120 sdd.out) | rev | cut -d "s" -f1,2,3,4| rev
echo -e "\n"
echo "/dev/sde: "
echo $(tail -n 1 -c 120 sde.out) | rev | cut -d "s" -f1,2,3,4| rev
echo -e "\n"
echo "/dev/sdf: "
echo $(tail -n 1 -c 120 sdf.out) | rev | cut -d "s" -f1,2,3,4| rev
echo -e "\n"
echo "/dev/sdg: "
echo $(tail -n 1 -c 120 sdg.out) | rev | cut -d "s" -f1,2,3,4| rev
echo -e "\n"
then run it by:
watch -d "bash monitor.sh"
if you're needing like this, feel free to use my method.