You are not logged in.
I am trying to make a script that will mount any vfat or ntfs drive as /mnt/windows/c and so on.
Is there a way I can do this?
It must check all drives present in the computer and create the directories in /mnt if they don't exist.
The first step however is just to make it recognise the filesystem and tell me what it is. If someone can help me with that, then I think I can continue the rest on my own afterwards.
The script can be bash, perl or python. It doesn't really matter. However the fewer dependencies I have to install for it to work will be better, as this in the end will be used on a USB rescue system.
Thanks,
MadEye | Registered Linux user #167944 since 2000-02-28 | Homepage
Offline
Here's a snippet I have been using in larch for generating entries in /etc/fstab, you might be able to modify it for your purposes:
# Get all other partitions
sfdisk -d | grep "^/dev/" | sed "s|\(.*\):.*Id=\(..\).*|\1 \2|" | \
while read dev id; do
# Ignore if id is "Extended" or "LVM", these are not usable partitions
if [ "${id}" = "5" -o "${id}" = "8e" ]; then continue; fi
# See if swap
if [ "${id}" = "82" ]; then
printf "%-12s %-12s %-8s defaults,noatime 0 0\n" \
${dev} swap swap >>${DEST}
continue
fi
removable=""
part=$( basename ${dev} )
if [ $( cat /sys/block/${part:0:3}/removable 2>/dev/null ) -ne 0 ]; then
removable="_rmv"
fi
mountdir=${part}${removable}
printf "%-12s %-12s %-8s user,noauto,noatime 0 0\n" \
${dev} /mnt/${mountdir} auto >>${tmpfile}
mkdir -p ${MNT}/${mountdir}
done
It reads the output from 'sfdisk -d' to get the devices and partition types.
You might also like to have a look at blkid, or parted.
larch: http://larch.berlios.de
Offline