OpenSUSE Linux Rants

OpenSUSE Linux Tips, tricks, how-tos, opinions, and news

My Resume  -  My LinkedIn Profile

June 30, 2006

Quick USB stick mounting tip for SUSE Linux

by @ 6:42 am. Filed under General SUSE, How-To, SUSE Tips & Tricks

M$ Jab of the Day

Evidently, M$ is laying off part of its sales force. They claim that it is “in order to be more efficient and responsive to customers.” It’s hard to be efficient and responsive to people who are running away from you at full tilt.

Interesting Tip of the Day:

For a long time, I have hated how I have to mount stuff manually in Linux. For some reason, for quite a long time, I could never quite keep track of how to get USB memory sticks mounted. The other day, I thought of something that has since worked quite well every time. I’d like to share it in hopes that it may help someone else have less of a headache when trying to remember how to mount USB drives (card readers, flash memory, usb sticks, etc.).

In your /proc directory, there is a file called partitions. To see which partitions are available to the system at any given time, you can do cat /proc/partition at a terminal. With no USB sticks plugged in, mine looks like this:


[2001][scott@desk:~]$ cat /proc/partitions
major minor  #blocks  name

   3     0  195360984 hda
   3     1      40131 hda1
   3     2    1959930 hda2
   3     3   29302560 hda3
   3     4  164055780 hda4
[2001][scott@desk:~]$

Now, when I plug in a USB stick (or card reader with a card inserted), this is what I get:


[2001][scott@desk:~]$ cat /proc/partitions
major minor  #blocks  name

   3     0  195360984 hda
   3     1      40131 hda1
   3     2    1959930 hda2
   3     3   29302560 hda3
   3     4  164055780 hda4
   8     0     124048 sda
   8     1     123888 sda1
[2020][scott@desk:~]$

Let’s see…. “One of these things is not like the other one…..” You can see that sda and sda1 were added. sda refers to the drive. It’s the sda1 that we care about. Just add /dev/ to the front of that to get the partition we want to mount. Our partition is /dev/sda1.

Next, we just pick a place to mount it to. As su I just create a directory called /media/usbstick or something similar. Then, you run your mount command as su with this syntax:

mount [usb stick partition] [target mount point]

If I were mounting the USB stick as /dev/sda1 onto the mount point /media/usbstick, this command would look like this:

mount /dev/sda1 /media/usbstick

The problem with doing it this exact way is that when you mount the USB stick partition as root, all of the files on the USB stick and the actual USB stick itself are owned by root, and not changeable by any other user. If you’re doing a read-only operation, it will work if you are doing it as a user other than root. However, as our mothers have properly taught us not to do things as root when not necessary, there should be a way to do fix this slight problem. There is.

As su, open your /etc/fstab file in your favorite text editor. Add a line, with this syntax:


[usb stick partition]            [target mount point]      auto       auto,user

If using /dev/sda1 as my usb stick partition and /media/usbstick as my target mount point, I would put this into my fstab:


/dev/sda1            /media/usbstick      auto       auto,user

The only thing you really need to know about this is that it makes it so that regular users can mount the USB stick. Of course, the user who mounts it is considered as the owner of the partition and its files (at least in the case of the USB stick).

Save your file and exit. Then, to mount it, just run the following command (as a normal user, even):

mount /media/usbstick

You will then notice that your user has full access to the USB stick.

To Review:

  1. cat /proc/partitions – find the partition of your USB stick
  2. make a mount point (perhaps in /media) to which you will mount the USB stick
  3. for user accessibility, edit your /etc/fstab file
  4. mount the usb stick

Most of the time, when you plug in a USB stick or card reader (with a card in it), SUSE will just pop open a window asking you if you want to see the contents of the device. However, in cases where that does not happen, or you are using a distribution that doesn’t do that, this trick should work.

If you know of a better way to do this (better = easier or less work), please do tell.

One Other M$ Jab of the Day

Another example of a wolf in sheep’s clothing.

“Fishenden told ZDNet UK that the conference was a good opportunity to address the ‘misconception, as he put it, that Microsoft was anti-open source.”

I really like the usage of the words “as he put it” in this li’l bit. Puts it all in perspective for us.

I’m not even going to get started on this one. Someone has already put out a really nice response. I whole-heartedly agree with them. Whoever wrote that deserves a huge raise.

12 Responses to “Quick USB stick mounting tip for SUSE Linux”

  1. Hans Fugal Says:

    There’s always automounting, and/or using udev to create a symlink based on which usb device it is (camera, pen drive, whatever) so you can have specific mountpoints in /etc/fstab.

  2. Christer Says:

    That must have been something I forgot on my previous list of awesome things about Ubuntu. In gnome I’ve never had to manually mount anything. USB flash drive, multiple digital cameras, etc.. plug in, auto-mounted & creates a link on the desktop. done. Actually, with the camera, it asks me if I want to import the photos as well.

    I still think you should give it a try 😉

  3. Gestahl Says:

    By default, SUSE does it as well (automounting all the stuff, creating links to desktop, asking whether you want the play the audio-CD you just inserted in amarok etc.).
    However, when you create an entry in /etc/fstab, e.g. for a cd-rom drive or an USB-stick, it won’t be automounted any longer. At least that’s what I observed after creating entries in /etc/fstab for my cd-rom drives to get cedega correctly working.

  4. Ozzy Says:

    That helped a lot. I am using SUSE SLES 10 servers with just command line option on all over our servers and I was looking for a solution to mount USB drives easly.

    Thank you! 🙂

    ###Sharing Knowledge helps humanity###

  5. Attila Says:

    I`ve just installed SUSE 10.0 but it does not automount and does not create link on the desktop.

  6. paul Says:

    Great advice!!!
    It worked just like it should, thanks a lot man for saving me from frustration!

  7. Digital Inexpensive Gift » USB Memory Stick - thorsten van elten Says:

    […] suse linux rants discusses suse linux, opensuse issues about linux, tips and tricks about suse and SUSE Linux Rants. Tips, tricks, how-tos, opinions, and news regarding SUSE Linux. more […]

  8. gavin Says:

    I have just been experimenting with this on suse 10.1 on a laptop using a usb memory stick. Whether or not it is automounted depends on your window manager/desktop. With gnome and kde an icon appears on your desktop and a dialogue prompts what operation to do with the new device – even with no entry for it in fstab. However, this is an old laptop and I run icewm due to lack of ram and cpu. Icewm doesn’t automount and certainly has no desktop icons. In that case, I have to manually mount, which is made easier by the right fstab entry.
    Gavin

  9. gherardo Says:

    Thanks for the advice. I was baffled seeing on suse 10 sles desktop the icon for the usb stick , but not being permitted to open it or to mount it.

  10. Calling me mini? :: Sceptical Ptarmigan Says:

    […] to get a nice unpacker and then went on with openssh-server and openjdk-6-jre. On a USB stick I had the new and cute SpringSource dm server but didn’t know how to mount a USB stick. Google comes rescue: […]

  11. Mike Cresswell Says:

    Thanks Scott. Very Helpful.

  12. Larry Steele Says:

    I’m still using SuSE 9.1, and I do not see anything in /proc/partitions? Just the harddrive partitions. Is 9.1 too old?

OpenSUSE Linux Rants
Official OpenSUSE Linux Site

internal links:

categories:

SUSE Resources

search blog:

archives:

May 2021
S M T W T F S
« Feb    
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

60 queries. 0.978 seconds