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.

OpenSUSE Linux Rants
Official OpenSUSE Linux Site

internal links:

categories:

SUSE Resources

search blog:

archives:

June 2006
S M T W T F S
« May   Jul »
 123
45678910
11121314151617
18192021222324
252627282930  

59 queries. 0.829 seconds