Wipe all SAS disks
# wipe enclosure
screen -S badblocks
for DISK in $(lsblk -n -S | grep -v usb | cut -d" " -f1); do
echo ${DISK}
wipefs -a /dev/${DISK}
badblocks -svw -b 16384 -c 65536 /dev/${DISK} -o /tmp/badblocks.${DISK}.log 2> /tmp/badblocks.${DISK}.out &
done
# show progress
grep done /tmp/badblocks.sd*.out
grep 0xaa /tmp/badblocks.sd*.out
# show errors
grep done /tmp/badblocks.sd*.log
<strong>Wipe all SAS disks (onliner)</strong>
<code>
lsblk -d -n -o NAME,TRAN | grep -v usb | cut -d' ' -f1 | xargs -I {} sudo wipefs -af /dev/{}# extract audio from video file
IFS=$(echo -en "\n\b")
for i in $(ls /media/${USER}/*/*); do
avconv -i $i -vn -c:a copy /tmp/${i##*/}.mp3
done
# join multiple PDF files
cd /media/*/Linux-Magazin*/pdf
for DIR in $(ls); do
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=/tmp/lm2013-${DIR}.pdf ./${DIR}/*.pdf
done
# lm
for i in $(ls *.jpg); do
convert -page A4 -density 72 $i $i.pdf
done
rm /tmp/lm20*.pdf
for x in {01..12}; do
pdftk lm13/c/cover-${x}-*.pdf lm13/pdf/${x}/*.pdf cat output /tmp/lm2013-${x}.pdf
done
# wipe enclosure
# 2th
for i in $(lsblk | grep 931 | cut -d" " -f1 | grep -v 1); do
echo /dev/$i
#wipefs -a /dev/$i
#badblocks -svw -b 4096 -c 8192 /dev/$i -o badblocks.$i.log > badblocks.$i.out &
ionice -c 3 dd if=/dev/zero of=/dev/$i bs=32M > dd.$i.out &
#smartctl -t short /dev/$i
done
for i in $(lsblk | grep 931 | cut -d" " -f1 | grep -v 1); do
DEV=/dev/${i}
DEV_SN=$(smartctl -i ${DEV} | egrep "Device Model|Serial Number" | cut -d":" -f2 | awk '$1=$1' | paste -d" " - - | tr -s " " "_")
OUTPUT="${DEV_SN}.txt"
echo ${OUTPUT}
sudo smartctl -d sat -a ${DEV} > "${OUTPUT}"
egrep "Error.*occurred|Raw_Read_Error_Rate|Power_On_Hours|overall-health|self-tests|# 1" "${OUTPUT}"
done
for i in $(lsblk | grep 931 | cut -d" " -f1 | grep -v 1); do
parted -s -- /dev/${i} mklabel gpt
echo -n "/dev/${i} "
done
for i in $(lsblk | grep 931 | cut -d" " -f1); do
parted /dev/${i} -s mklabel msdos
parted /dev/${i} -s mkpart primary ext4 0% 100%
mkfs.ext4 -L $(smartctl -i /dev/${i} | egrep "Serial Number" | cut -d":" -f2 | awk '$1=$1') /dev/${i}1
done
# geth Health status
for DISK in $(lsblk -n -S | grep -v usb | cut -d" " -f1); do
DEV=/dev/${DISK}
smartctl -H ${DEV} | grep Health
done