#!/bin/bash if [ "$1" = "" ]; then echo -n "Please specify target device (i.e. /dev/sdb): " read disk else disk="$1" fi if [ "$disk" = "" ]; then echo "Please specify target device (i.e. /dev/sdb)" exit fi if [ "$disk" = "/dev/sda" ]; then echo "Isn't this your system disk? Not a good idea to reformat. " exit fi if [[ "$disk" =~ "\/dev\/sd\w" ]]; then echo "Using disk $disk" else echo "Incorrect disk specification" exit fi if [ "$1" = "-help" ]; then echo "This script prepares a disk for usage in Bubba|Storage." echo "Usage: bubbastorage /dev/sd? " exit fi echo "Creating partitions.." sfdisk $disk partition=$disk"1" echo "Formatting.." mkfs.ext3 $partition echo "Clearing the 30 times fs check.." tune2fs -c 0 $partition echo "Mounting. ." mount $partition /mnt echo "Changing owner.." chown nobody:users /mnt echo "Changing access rights.." chmod a+rw /mnt echo "Removing lost+found.." rm -rf /mnt/lost+found echo "Unmounting.." umount /mnt echo "Done!"