Sunday, May 27, 2007

Linux USB Floppy Drive

I started out today trying to get my USB Floppy Drive to work with Ubuntu 7.04 Fiesty. It was recognized but I couldn't get the floppies themselves to format or gain ownership of the floppies after they were mounted. To solve this I wrote a short little bash script called makefloppy. All it does is take a floppy that was partitioned using fdisk on drive /dev/sde and format it and gives me ownership of it. Now when the floppy is inserted, it mounts and opens and I have full access to it. It needs to be executable and ran as sudo to work. Here is the bash script I wrote:
#!/bin/bash
#A little bash script to make floppies mine for use.
# First use fdisk to create the partition on the floppy.
#Then use mke2fs to format it
mke2fs /dev/sde
#Now mount, change ownership, then unmount
mount -t ext2 /dev/sde /media/disk
chown -R edward:edward /media/disk
chmod -R 755 /media/disk
umount /dev/sde
#Remove and resinsert the floppy, it's mine now

No comments: