fat32 formatter

Use this with USB sticks on the freebsd laptop

0

Votes

#!/bin/sh
fail() {
    echo $1
    exit 1
}
[ $(id -u) -eq 0 ] || fail "gotta run as root.."
[ $# -eq 1 ] || fail "Usage: $0 geom"
[ -e $1 ] || fail "No such geom: /dev/$1"
echo "OK, here's the current layout:"
gpart list $1
printf "Are you sure you wanna do this? [y/N] "
read yn
[ "$yn" == "y" ] || fail "Canceled by user"
gpart destroy -F $1 || fail "Destroying partition scheme failed"
gpart create -s gpt $1 || "Creating partition scheme failed"
gpart add -t mbr $1 || fail "Adding partition failed"
newfs_msdos -F32 "$1"p1 || fail "Formatting failed"
exit 0

Vote Here

You must earn at least 1 vote on your snippets to be allowed to vote

Terms Of Use

Privacy Policy

Featured snippets are MIT license

Gears & Masters

Advertise

DevOpsnipp.com © 2020

medium.png