jammed dirname.py on top of mount.py
Trouble’s struck !!. Ubuntu’s libATA has stopped functioning and my partitions are now seen as IDE subsystems once again. Hence we have a conflict between udev rules and device names leading to automount getting <censored>. I seriously can’t be bothered by this. Considering that I try to behave as much as a sysadmin as possible, I tried to whip up a script that would mount the device specified as I have no idea what filesystems my 3 identical (in appearance) external drives have on them. I think one has reiserfs, another has ext3 and the third has fat32 on it. I tried to find out the command that would let me know about the fs I have on my external drive without actually mounting it. fdisk didn’t help and I was stuck with waiting for the new kernel 2.6.20-16-generic to be fixed. Later that day I did:
man -k locate
The first line in there was:
blkid (8) - command-line utility to locate/print block device attributes
Was this command the solution to my troubles? It indeed was. I then whipped up a script in no time. Here it is:
#!/usr/bin/python
#mountcreatingdir.py
#Author:Shriphani Palakodety
import commands
index = 1
while True:
dir = "/mnt/usbdisk" + str(index)
string = commands.getoutput('mkdir %s' % dir)
if string == "":
continue
else:
index = index + 1
device = raw_input('Enter the name of the device you want to mount: ')
a = commands.getoutput('blkid %s' % device)
import string
number = string.find(a, " T")
print number
requirement = a[number+6:]
s = commands.getoutput('mount -t %s %s %s' % (requirement, device, dir))
print s
That’s about it.



0 comments
Kick things off by filling out the form below.
Leave a Comment