# Accessing USB drive [SOLVED]

## NathanZachary

Hello all,

After very recently getting the answer I needed about mounting my CDRW/DVD drive, I have run into one other problem.  I use a couple USB flash drives, and they go back and forth between a Windows machine at my Uni and my Gentoo machines at my house.  Nearly all of the data on the drive was put on it on the Windows machine, so it uses NTFS.  Is there a way to use the flash drive on both the Windows and Linux computers?

For instance, if I wanted to put a .ppt file (made in OpenOffice on my Linux machine) onto the drive and open that file on a Windows machine at school (or vice-versa), would that be possible?  If so, how?

Thanks preemptively,

Zach

----------

## didymos

Depends on whether you want read/write support.  If you do, you need the ntfs-3g driver package. Otherwise, the in-kernel NTFS driver should suffice.  I'm not sure what drivers will be needed for the drives themselves, mainly because I don't know what they actually are and who made them.

----------

## PaulBredbury

emerge ntfs3g. Write udev rules.

----------

## NathanZachary

I have a 1.0GB SanDisk Mini Cruzer, and an 8.0GB Corsair VoyagerGT.

----------

## didymos

For both: no problem, just need "USB Mass Storage support" and "SCSI disk support" in the kernel or as modules.  This is true of most USB flash drives, but there is the occasional odd device that needs additional code.  Add ntfs-3g, and you should be good.

----------

## NathanZachary

Alright, I'll give it a try when I get home from work today.  Thanks again for your help!  :Smile: 

----------

## NathanZachary

Alright, I merged ntfs3g (which also emerged FUSE), and I still get the error.  When I insert a USB flash drive, it says "Invalid filesystem type."  Any ideas?  Do I need to follow the instructions for writing udev rules?  I was under the impression that merging ntfs3g would eliminate the need.

----------

## didymos

ntfs-3g just provides filesystem support, like any other kernel FS driver.  You still need to specify what the machine is supposed to do with this or that device.  You must have some configuration set somewhere for those drives.  The questions are: where and what?  The other question is this: still get the error?  This is the first time you mentioned any error messages.  I don't know a lot about ntfs3g.  I have no need for it, so I've never used it.  Maybe what you need is here:

http://www.ntfs-3g.org/support.html#questions

----------

## NathanZachary

Ah, you are right; I never mentioned the error, and I thought I had.  Sorry about that.  I will try to read the support page at NTFS-3G's site.  Hopefully I will find the answers that I need there.  Also, there really shouldn't be a difference between using a USB flash drive and a USB HDD right?  Considering they are treated in a similar fashion, the only thing I might need is a driver for it?

----------

## PaulBredbury

 *gentoo_zach wrote:*   

> Invalid filesystem type

 

I use in /etc/fstab

```
/dev/windows1  /mnt/windows  ntfs-3g  noauto  0 0
```

And in /etc/udev/rules.d/10-local.rules

```
SUBSYSTEMS=="scsi", ATTRS{model}=="ST3320620AS*", NAME="%k", SYMLINK+="windows%n"
```

----------

## shaumux

If you are using (KDE or Gnome)+HAL then i think it would do the job automatically of identifying the filesystem and mounting it automatically.

Also when do you get that error, do you try to manually mount the drive?

If so what parameters do you give with mount?

Do you have the fuse driver in the kernel disabled?

afaik ntfs-3g would not work with the kernel fuse driver enabled.

----------

## NathanZachary

This computer has sda1 as a partition for Windows, and then sda2, sda3, and sda4 for the Gentoo installation.  Interestingly, without modifying anything, I can see all the files on the Windows partition (NTFS).  However, when I go to look at the flash drives, or a USB HDD, it says "invalid filesystem type."  :Confused: 

----------

## shaumux

What do you mean look for the flah drive.

Where does it say invalid filesystem?

----------

## NathanZachary

When I insert the USB flash drives (or my USB external HDD), HAL pops up the dialogue box that allows one to open and view the contents of the drive.  When I click to view the contents, it gives the error:

"Invalid filesystem type."

----------

## shaumux

Ok

Make sure the FUSE and NTFS driver option in the kernel is disabled.

If not then disable those and recompile and reinstall the kernel

Backup the file /sbin/mount.ntfs if it already exists.

Now Do this

```
ln -s /usr/bin/ntfs-3g /sbin/mount.ntfs
```

There are other ways to make it work given in gentoo-wiki here

----------

## NathanZachary

So you want the FUSE and NTFS support in the kernel DISABLED???  I thought you would want those in there.  Okay, let me try disabling those and recompiling my kernel.

----------

## NathanZachary

Alright, so I did that, but I still get the invalid filesystem type error.  I guess I will read that wiki entry and try some of the troubleshooting steps that are given.

----------

## shaumux

 *gentoo_zach wrote:*   

> So you want the FUSE and NTFS support in the kernel DISABLED???  I thought you would want those in there.  Okay, let me try disabling those and recompiling my kernel.

 ntfs-3g requires the fuse module from portage tree which afaik is more recent but doesn't work with fuse module enabled in the kernel.

----------

## NathanZachary

Okay, well I disabled the FUSE and NTFS support within the kernel, and I have the latest versions of FUSE and NTFS-3G merged from Portage.  However, I still get the error, so I will try to read the information in the wiki, and will hopefully get my USB flash drives and external HDDs up and running.  I have read that some people actually define the drives in their fstab or create udev rules, but to me, it seems like HAL should take care of the automounting and setup of those drives.  Is that a correct assumption?

----------

## shaumux

Yes HAL should be be able to use the correct modukes and setup everything to get drives up and running but sometimes it makes a mistake in identifying the filesystem and may try to load it as another filesystem which is probably your case.

Another thing is that sometimes a corrupted file in the partition can stop it from mounting.

That happened to me a few days ago when i tried to mount My phone which is mouted as an USB drive but HAL even refused to recognise it turnes out that some info or file was corrupted.

I tried tomount it manually and it mounted but then i analysed the dmesg log and found the problem i just copied my info to the PC after manually mounting and formatted it.

After you get the error messages you should check dmesg | tail to check if any errors or warninggs or any info pops up there.

Also just some side Info to go with it you have to load the FUSE module from portage tree before you can use ntfs-3g

Either modprobe fuse

or add it to /etc/modules.autoload.d and then reboot for it to be loaded automatically when you boot.

If you try to manually mount the drive or include it in fstab the filesystem type has to be given as ntfs-3g and not ntfs

----------

## shaumux

Ok

I tried and was able to reproduce the error.

The problem is HAL recognises its a an NTFS but doesn't know what to use to mount it.

Here's what I did for use with KDE+HAL.

Disable FUSE and NTFS from the kernel(recompile and Copy new kernel and boot with new Kernel).

Get dbus and hald started.

Install FUSE and ntfs-3g from portage.

Load fuse module and add it to /etc/modules.autoload.d/kernel-2.6 so it gets autoloaded everytime I boot.

Next to make HAL use ntfs-3g for NTFS i executed the command I mentioned above

ln -s /usr/bin/ntfs-3g /sbin/mount.ntfs

Then it worked fine.

----------

## NathanZachary

I did all of those things and still wasn't able to view any of the files on the USB drive.  :Sad: 

----------

## NathanZachary

Isn't it odd though that I can view all of the files on the NTFS Windows partition of the HDD, but I can't with the USB drives?  That would lead me to believe that it is a problem with the USB drives being mounted rather than a problem with FUSE or NTFS-3G.

----------

## shaumux

What does dmesg | tail say just after you try to open the USB drive?

Did you boot into new kernel before trying?

Did dbus and hald start properly?

----------

## shaumux

You can try to put entries for the USB drive in fstab with ntfs-3g as fs type in fstab and see if it gets mounted?

What happens when you try to manually mount the drive with the mount command?

----------

## NathanZachary

Here's what dmesg | tail says after I try to access the USB drive:

```

zach@tux_lappy ~ $ dmesg | tail

usb-storage: -- transfer complete

usb-storage: Bulk command transfer result=0

usb-storage: Attempting to get CSW...

usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes

usb-storage: Status code 0; transferred 13/13

usb-storage: -- transfer complete

usb-storage: Bulk status result = 0

usb-storage: Bulk Status S 0x53425355 T 0x2c R 0 Stat 0x0

usb-storage: scsi cmd done, result=0x0

usb-storage: *** thread sleeping.

```

----------

## shaumux

There seeme to be nothing wrong in that

Try dmesg after you use the USB drive and heck if there are any more lines related to the usb drive just above those.

----------

## NathanZachary

I can't use the USB drive because whenever I try to open it, it simply says "Invalid filesystem type," and won't let me view any of the drive contents.

----------

## shaumux

i meant after you got that message

----------

## NathanZachary

Those were the lines after I got the error message.

```

zach@tux_lappy ~ $ dmesg | tail

usb-storage: -- transfer complete

usb-storage: Bulk command transfer result=0

usb-storage: Attempting to get CSW...

usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes

usb-storage: Status code 0; transferred 13/13

usb-storage: -- transfer complete

usb-storage: Bulk status result = 0

usb-storage: Bulk Status S 0x53425355 T 0x39 R 0 Stat 0x0

usb-storage: scsi cmd done, result=0x0

usb-storage: *** thread sleeping.

```

Something interesting I noticed, though, was that when I added a line to my fstab, the error message changed.  I added the following line to fstab:

```

/dev/sdb1              /mnt/usbflash   ntfs-3g         user            0 0

```

When I did that, the error message changed to:

```

Error opening partition device: Permission denied

Failed to startup volume: Permission denied

Failed to mount '/dev/sdb1': Permission denied

```

Now, I really wouldn't like to have to define the device in my fstab anyway, because I thought that HAL and D-BUS would take care of that for me.  Also, I don't want to have to define each individual USB mass storage device because I have about 10 different ones (including external HDDs).

----------

## irgu

See http://ntfs-3g.org/support.html#useroption2

----------

## NathanZachary

Well that answers why the error message changes when I add the entry in fstab, but not why HAL doesn't automatically (and correctly) mount the USB flash drives / external HDDs.  Is there some type of config file for HAL that would need to be modified to let HAL know to use NTFS-3G for removable disks?  Like I said before, the odd thing is that I have no problem at all viewing / reading / writing content to the NTFS partition of the internal HDD, but when I try to plug in any external device, that's when I get the "Invalid filesystem type" error.  Therefore, wouldn't it make logical sense that it is not a problem with ntfs-3g, but rather something having to do with the mounting of a removable device?

----------

## NathanZachary

Hmmmmmm, I just clicked on properties about the USB flash drive, and for some reason it says that the filesystem is vfat, not ntfs.  It appears that my USB flash drives are all using FAT32 as the filesystem, but I could have sworn I formatted them to NTFS.  However, let's just assume that they remain FAT32; is there a way to read/write to that filesystem?  I thought vfat only offered FAT16 support, not FAT32?

----------

## didymos

No, vfat can do FAT32.  FAT32 was basically an upgrade to the original vfat in Win95.  It was in one of the service packs.  Probably OSR2.  I can't remember. Anyway, the linux FS driver just added the support for it and kept calling the driver vfat.

----------

## NathanZachary

I got it all taken care of.  I just recompiled the kernel with vfat support and everything works smoothly.  Man, sometimes I wonder if my brain works at all.  Thanks to everyone for the help.

----------

