Files
RescueBRU/customcd/files/root/rescuebru/blank.sh
2026-03-03 19:53:38 -05:00

39 lines
1.1 KiB
Bash

#!/bin/bash
# blank.sh
# Rescue CD Backup & Restore Utility device blanking utility
# version 7.2.5
# Rod Wright 1/19/2024
# Refer to CHANGELOG file for details.
# -----------------------------------------------------------------------------
PROG_NAME="blank.sh"
PROG_VERSION=7.2.5
PROG_REVISION=1
RBRU_INSTALL_PATH="/root/rescuebru"
source $RBRU_INSTALL_PATH/functions.sh
# test for required arguments
if [ "$#" -ne 1 ]; then
echo "blank.sh: Invalid number of arguments."
echo "Usage: blank <target>"
echo "target can be drive (/dev/sda) or partition"
echo "(/dev/sda1)."
echo "If target is a drive, all data including the MBR,"
echo "partition table, and any RAID signatures will be lost."
echo "If target is a partition, any filesystem on it will"
echo "be lost."
exit 1
fi
tgt_dev=$1
dd_bs=4096
# determine sizes of target
tgt_size=`blockdev --getsize64 $tgt_dev`
tgt_blocks=$(($tgt_size / $dd_bs ))
# now do the blanking
monitor "dd if=/dev/zero bs=$dd_bs count=$tgt_blocks conv=sync,noerror status=noxfer|pv -s $tgt_size|dd of=$tgt_dev bs=$dd_bs" "pausable"
exit $?