10 Replies Latest reply on Dec 14, 2012 11:57 AM by agrahambell

    Unable to mount USB Stick on RPi

    mgt6910

      I have copied some music files to a USB stick using Linux Mint, (on Mint

      it auto-mounted with no problems),and I would

      like to mount it on RPi. Details of what I have tried are appended. Any

      help would be welcome (I need this sorted by Christmas, or my grandsons won't receive a present !!)

       

      As root (sudo bash) on RPi,I inserted the USB Stick:

       

      tail -f /var/log/messages

      =================================================================

      new high-speed USB device number 11 using dwc_otg

      new USB device found, idVendor=0781, idProduct=5567

      Product: Cruzer Blade

      Manufacturer: SanDisk

      Serial Number: 20060266511169034397

      scsi2 : usb-storage 1-1.1.2.4.4:1.0

      scsi 2:0:0:0: Direct-Access  Sandisk Cruzer Blade    1.26 PQ: 0  ANSI: 5

      sd 2:0:0:0:  [sda] 62530624 512-byte logical blocks:  (32.0 GB/ 29.8 GiB)

      sd 2:0:0:0:  [sda] Write Protect is off

      sd 2:0:0:0:  [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA

         sda: sda1

      sd 2:0:0:0:  sd 2:0:0:0:  [sda] Attached SCSI removable disk

      ==================================================================

       

      Following instructions found at :

          http://raspi.tv/2012/mount-a-usb-flash-drive-on-raspberry-pi

       

          I entered:

              mkdir /media/my32gb

              mount -t vfat -o rw /dev/sda1 /media/my32gb

       

          which failed with :

              mount: /dev/sda1 is not a valid block device

        • Re: Unable to mount USB Stick on RPi

          As you can see from the messages log, your device is being detected and sda1 is seen. The device should then be created automatically for you to mount with the command you used.

           

          can you try the following after the mount command fails

           

          root@raspberry-pi:~# ls -l /dev/sda*

           

          you should get a result something like this:

           

          brw------- 1 root root 8, 0 Dec  6 18:23 /dev/sda

          brw------- 1 root root 8, 1 Dec  6 18:23 /dev/sda1

           

          if instead you get something more like

           

          /bin/ls: cannot access /dev/sda*: No such file or directory

           

          then that would be the problem..

           

          You can investicate further:

           

          root@raspberry-pi:~# cat /proc/partitions

          major minor  #blocks  name

           

          179        0    3872256 mmcblk0

          179        1      97656 mmcblk0p1

          179        2    1833607 mmcblk0p2

          179        3    1940992 mmcblk0p3

             8        0  488386584 sda

             8        1    8388608 sda1

           

          the 8 & 1 here should match the 8, 1 I highlighted in the ls command above.  If they either don't match, or the ls command returned 'No such file or directory' then you can try this

           

          root@raspberry-pi:~# mknod /dev/sda b 8 0

          root@raspberry-pi:~# mknod /dev/sda1 b 8 1

          root@raspberry-pi:~# ls -l /dev/sda*

          brw-r--r-- 1 root root 8, 0 Dec 10 20:33 /dev/sda

          brw-r--r-- 1 root root 8, 1 Dec 10 20:33 /dev/sda1

           

          just be sure to replace the 8 & 1 with whatever's listed in the output of cat /proc/partitions

           

          Then retry the mount command..

           

          Even assuming this all works, try rebooting the Pi and see if you can just remount the usb stick. You may find that the /dev/sda* entries have disappeared and are not being correctly re-created for some reason.

           

          Also, let us know what SD Card iamge and version you're using on the Pi when the problem happens, someone may be able to give you some more directly useful help if we know a little bit more.

          • Re: Unable to mount USB Stick on RPi
            John Beetem

            When I've used a USB Flash drive on RasPi with Debian "Squeek", it OS automatically mounts the USB Flash drive in "/media".  So I do "ls /media" to see what it's been named.  Then I copy to/from "/media/<whatever>".  I suppose I should unmount it and mount it somewhere else and give it a proper name, but I never learned those commands and what I do now works well enough.

              • Re: Unable to mount USB Stick on RPi

                yes, normally udev will create the device nodes in dev and the drive will be mounted for you.

                 

                However, "mount: /dev/sda1 is not a valid block device" strongly suggests that the major/minor numbers for the device node do not match the kernel's idea of what the major/minor numbers really are.

                 

                That's unusual and would suggest udev is broken or out of sync with whatever the kernel is doing, or even that udev is not running and stale entries from a static /dev are in use.

                 

                Either way, comparing the contents of /proc/partitions with the device node should at least give us a starting point.

                 

                The only other thing I can think of is that there's some usb or power issue causing the device to rapidly appear and disappear and it's at least partially gone by the time mount tries to access it.

                 

                More info needed though...

                  • Re: Unable to mount USB Stick on RPi
                    wallarug

                    my steps would be the following (never failed me.):

                     

                    1. Power up Raspberry Pi with device plugged in.

                    2. Log into RPi

                    3. Type in (at the prompt)

                    fdisk -l

                    4. Looking at the information on the screen, there should be two devices with about two partitions each. The marked /dev/sda1 (or any number) is your USB drive.  Some USB drives have mulitple partitions, use (in the next step) the partition with the largest amount of space.

                    5. now that you know what your device is called, we can mount it to any folder or location of your choosing.

                    mount /dev/sda1 /media

                    This will mount the usb device called '/dev/sda' with partition '1' to the folder '/media'.

                     

                    This is how I mount my drives.  After you know what it is called, you can use the same command in step 5 each time you want to use the device.

                     

                    Hope this helps.

                      • Re: Unable to mount USB Stick on RPi
                        mgt6910

                        My idea is to produce a (relatively) crashproof system for my grandsons. I plan to give them 3 copies of the latest Wheezy  on 8Gb cards. Every time they  forget to shut down and a card becomes unusable, they change to another card.  To allow them to keep their files off the system-card, my idea was to make a softlink from the  /home folder to the USB stick.

                        For this to work, the USB-stick needs to be auto-mounted with a fixed name that can be used for the softlink, without

                        the kids having to type in a list of commands supplied by granpa (so uncool !). 

                         

                        What I am seeking to avoid is a procedure that obliges them to poke around inside /media, as opposed to just using pi's home. They should be

                        able to switch system-cards and USB sticks, without any need to type in commands (they will have 2 complete pi systems, and  I would like them to be able to just swap sticks to see what the other one has been developing).

                         

                             Many thanks for the suggestions, I will follow them up ASAP. I guess that someone into bash-scripting could create a script that looks

                        in /media and makes a softlink  /home/pi to whatever is auto-mounted there.   That's above my pay-grade I'm afraid (starting pi before /home/pi exists seems a bit iffy !)

                          • Re: Unable to mount USB Stick on RPi
                            wallarug

                            Shouldn't be too hard to achieve.

                             

                            Only one file needs to editted and one needs to be created.  Here we go...

                             

                            1. log onto raspi

                            2. type in:

                            sudo nano /etc/rc.local

                            3. add to this file by going down to the bottom, and then BEFORE the 'exit0', add the line:

                            su -c "/boot/startup.sh" root

                            4. Press CRTL+x, then 'y'

                            5. Create a new file called 'startup.sh' in the /boot directory like so:

                            sudo nano /boot/startup.sh

                            6.  In this file add the following commands so that the file looks like this:

                            sudo umount /dev/sda1

                            sudo mount /dev/sda1 /home/pi

                            7. For the last line, you might want to change the location from '/home/pi' to whatever you want.

                             

                            That should do it for you.  I have not tested this but I think it should work as long as you have the USB plugged in at boot, every time you start-up the SD card, the USB drive will mount.

                             

                            PS: Did you know that in the 'startx' environment, the USB drive mounts automatically?  It is only command line that it doesn't.

                              • Re: Unable to mount USB Stick on RPi
                                mgt6910

                                Many thanks for that information, I will try this ASAP. Keeping user-files off the SD-card will greatly simplify upgrading the system in the future. If I manage the mods you suggest, I will then try startx to see if it is compatible with the change.

                                  • Re: Unable to mount USB Stick on RPi
                                    mgt6910

                                    Yes, I think that fits the bill !  Many thanks for the advice.   ( I think that the USB stick was failing because of the USB hub (trust.com/15140,7-port 2A supply). On the second RPi-port, the stick seems reliable.)

                                     

                                    With the FAT32 format of the Stick, I could not set 755 permissions for the top-level directory, or lost+found.

                                    To solve this, I used gparted on Linux Mint to reformat the stick as ext3, and could then set the permissions.

                                     

                                    The mods were applied as suggested, and it works fine.  The umount command produces the message : umount: /dev/sda1: not mounted, which checks with your note about automount/startx, so I will remove that line.

                                     

                                    startx starts up OK, but I haven't yet created the Desktop folder which contains the icons....

                              • Re: Unable to mount USB Stick on RPi

                                Fergus Byrne wrote:

                                 

                                my steps would be the following (never failed me.):

                                 

                                1. Power up Raspberry Pi with device plugged in.

                                2. Log into RPi

                                3. Type in (at the prompt)

                                fdisk -l

                                Fergus, the one problem with this is that fdisk -l is just querying the /dev/sda /dev/sda1 etc device nodes directly (after getting it's list from /proc/partitions).

                                 

                                With mount giving an error message of "/dev/sda1 is not a valid block device", fdisk won't be able to read it either, and all you'd see is the sd card.

                                 

                                Otherwise, what you suggest is almost exactly what I use