ansitest/ZFS/mkgpt.sh

33 lines
780 B
Bash
Raw Normal View History

2021-04-12 14:40:45 -05:00
#!/bin/bash
2021-04-12 15:04:54 -05:00
# DEPENDS: smartctl, parted, fdisk
2024-06-02 12:25:01 -06:00
echo "Parameter: Supply short device name [sdb], etc"
echo "MAKE SURE you supply the right disk device - author takes NO RESPONSIBILITY for data loss!"
echo "Use at your own risk!"
2021-04-12 14:40:45 -05:00
argg=$1
2024-06-02 12:25:01 -06:00
[ $(which parted |wc -l) -gt 0 ] || apt-get install -y parted
2021-04-12 15:04:54 -05:00
#source ~/bin/failexit.mrg
# failexit.mrg
function failexit () {
echo '! Something failed! Code: '"$1 $2" # code # (and optional description)
exit $1
}
2021-04-12 14:40:45 -05:00
smartctl -a /dev/$argg |head -n 16
fdisk -l /dev/$argg
2021-04-12 15:04:54 -05:00
ls -l /dev/disk/by-id |grep $argg
2021-04-12 14:40:45 -05:00
2024-06-02 12:25:01 -06:00
echo "THIS WILL DESTRUCTIVELY APPLY A GPT LABEL to /dev/$argg - ARE YOU SURE - Enter to proceed OR ^C"
2021-04-12 14:40:45 -05:00
read
parted -s /dev/$argg mklabel gpt || failexit 99 "! Failed to apply GPT label to /dev/$argg"
fdisk -l /dev/$argg
2024-06-02 12:25:01 -06:00
exit;