mountfat

Submitted scripts and programs
Forum rules
Your own work only.
User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

mountfat

Unread post by GekkoP » Fri Apr 18, 2014 1:11 pm

This script helped me solve some transfer speed issues I had with my FAT32 usb. I based mountnetware on this one.

Code: Select all

#!/bin/sh
#
# Script to properly mount USB FAT16/32.
#
# I only use one USB key at the time, so the script
# umounts everything in /media/usb* on purpose.
# It is possible to specify a different device.

if [ ! -z $1 ]; then
    echo "you specified a device"
    check=$(fdisk -l | grep FAT | grep $1 | awk '{print $1}')
    if [ ! -z $check ]; then
	device=$1
    else
	echo "no FAT16/32 on "$1
	exit 1
    fi
else
    # get device i.e. /dev/sdb1
    device=$(fdisk -l | grep FAT | grep sdb | awk '{print $1}')
fi

# log device
echo "found USB FAT16/32 on $device"

# create /media/usb if needed
if [ ! -d "/media/usb" ]; then
    mkdir -p /media/usb
fi

# umount possible automounted devices
umount /media/usb* 2>/dev/null

# mount
mount -t vfat $device /media/usb -o async,uid=1000,gid=1000,utf8,dmask=027,fmask=137

# log done
echo "$device mounted on /media/usb"

User avatar
wuxmedia
Grasshopper
Posts: 6454
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: mountfat

Unread post by wuxmedia » Fri Apr 18, 2014 1:17 pm

Very nice, I see it also mounts it as user, very handy...
that always gets me with mounting stuff.
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: mountfat

Unread post by GekkoP » Fri Apr 18, 2014 1:20 pm

Oh, yes, I use it with sudo mostly.

Post Reply