#!/bin/sh target_device="/dev/sdb1" device_uuid="$(blkid -s UUID -o value ${target_device})" bad_blocks_file="bad-blocks-${device_uuid}.badblocks" mount_point="/mnt" block_size=4096 badblocks -v -w -p 2 -s -t random -b ${block_size} -o "${bad_blocks_file}" "${target_device}" && mkfs --verbose --type ext4 -b ${block_size} -l "${bad_blocks_file}" "${target_device}" && echo "UUID=${device_uuid} ${mount_point} ext4 defaults,user 0 0" >> /etc/fstab