Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ## Some commands and/or syntax are targeted for FreeBSD and more
- ## precisely NAS4Free 9.2.*.* series.
- ## The script will probably fail if used in Linux or more limited
- ## FreeBSD environments.
- ## You have been warned.
- ##
- ## The purpose of the script is to zero out the first and last 4Mb
- ## of the disk targeted for disks reporting 512byte sector-size.
- ## For disks that actually report a 4k sector size, it will wipe
- ## out the first and last 32Mb.
- ## Many disks still false-report a 512byte sector when they are in
- ## fact 4k drives, due to backwards (and isn't it always)
- ## compatibility with windows.
- ## The purpose is to wipe out the MBR and GPT partition tables and
- ## ZFS fingerprints that may exist on a drive.
- ## Ever have a drive with a single ZFS pool, but "zpool import"
- ## shows three or more possible pools to try to import from the
- ## drive (due to reuse/testing)? I have.
- ## After using this, the drive will appear to be blank. It isn't.
- ## But plugging the drive into windows, Linux, FreeBSD, or Android,
- ## it will appear to be, and can be partitioned and formatted for
- ## use as you see fit. Of course forensic scans of the disk would
- ## still return data from the previous usage, but for home users
- ## this simplifies readying the disk for use in a different
- ## capacity than previous.
- ##
- echo "What disk do you want"
- echo "to wipe? For example - ada1 :"
- read disk
- echo "OK, in 10 seconds I will destroy all data on $disk!"
- echo "Press CTRL+C to abort!"
- sleep 10
- diskinfo ${disk} | while read disk sectorsize size sectors other
- do
- echo Deleting MBR, GPT Primary, ZFS(L0L1)/other partition tables.
- /bin/dd if=/dev/zero of=/dev/${disk} bs=${sectorsize} count=8196
- echo Deleting GEOM metadata, GPT Secondary(L2L3).
- /bin/dd if=/dev/zero of=/dev/${disk} bs=${sectorsize} oseek=$(expr $sectors - 8196) count=8196
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement