Jump to content

Linux noob and usb memory stick


oconnellc

Recommended Posts

Sorry this isn't strictly storage related, but...  I bought a usb memory stick so that I could plug it into my unraid server and use it as a place to copy applications that I want to run on my unraid server.  For example, slimserver and mediatomb are a couple to start.  I know that slimserver running is keeping one of my drives from spinning down and I'd rather minimize the access on my unraid memory stick.

 

So, my question is, how do I do that?  I got the stick, formatted it as fat32 and then stuck it into my unraid box and then realized I have no idea how to 'get to it', if that makes sense.  Feel free to hit me with a stick as long as you can point me at what I should be reading to figure this out.  I'm used to just plugging something like this into my windows server and it just shows up.

 

Thanks in advance for your help,

Chris

Link to comment

If it is formatted with a fat32 file-system it can be accessed easily.

 

You just need to logically mount it so you can get to it.

 

After you plug it in type

ls -l /dev/disk/by-id

to find it. 

 

If you gave it a unique LABEL when you formatted it you can alternately type

ls -l /dev/disk/by-label

 

The very last part of the lines printed contain the "device" name.  You will usually see two lines for your flash drive (one without a numeric suffix, which is the whole drive, and the other with a numeric suffix which is the individual partition with the file-system.)

 

We need to type a few commands to mount the partition with the file-system on a "mount point"(an empty directory) so we can get to it.

 

As an example. I just plugged a flash drive like you described  onto my server.

I type ls -l /dev/disk/by-id and see these two lines below in blue (in addition to the lines for all my other disks)

 

root@Tower:# ls -l /dev/disk/by-id

lrwxrwxrwx 1 root root  9 Feb 28 16:38 ata-HDS725050KLAT80_KRVA03ZAG3V5LD -> ../../hdb

lrwxrwxrwx 1 root root 10 Feb 28 16:38 ata-HDS725050KLAT80_KRVA03ZAG3V5LD-part1 -> ../../hdb1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 ata-HDS725050KLAT80_KRVA03ZAG4V99D -> ../../hdd

lrwxrwxrwx 1 root root 10 Feb 28 16:38 ata-HDS725050KLAT80_KRVA03ZAG4V99D-part1 -> ../../hdd1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 ata-MAXTOR_STM3500630A_5QG00FTK -> ../../hdl

lrwxrwxrwx 1 root root 10 Feb 28 16:38 ata-MAXTOR_STM3500630A_5QG00FTK-part1 -> ../../hdl1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 ata-Maxtor_6Y250P0_Y63KH45E -> ../../sdd

lrwxrwxrwx 1 root root 10 Feb 28 16:38 ata-Maxtor_6Y250P0_Y63KH45E-part1 -> ../../sdd1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 ata-QUANTUM_FIREBALLlct15_08_611020017228 -> ../../hdj

lrwxrwxrwx 1 root root 10 Feb 28 16:38 ata-QUANTUM_FIREBALLlct15_08_611020017228-part1 -> ../../hdj1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 ata-ST31000340AS_9QJ0JPJS -> ../../sdf

lrwxrwxrwx 1 root root 10 Feb 28 16:38 ata-ST31000340AS_9QJ0JPJS-part1 -> ../../sdf1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 ata-ST31500341AS_9VS069T8 -> ../../sda

lrwxrwxrwx 1 root root 10 Feb 28 16:38 ata-ST31500341AS_9VS069T8-part1 -> ../../sda1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 ata-ST31500341AS_9VS0G9D8 -> ../../sdb

lrwxrwxrwx 1 root root 10 Feb 28 16:38 ata-ST31500341AS_9VS0G9D8-part1 -> ../../sdb1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 ata-ST3400620A_5QH00PF4 -> ../../hde

lrwxrwxrwx 1 root root 10 Feb 28 16:38 ata-ST3400620A_5QH00PF4-part1 -> ../../hde1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 ata-ST3400620A_5QH00QPN -> ../../hdc

lrwxrwxrwx 1 root root 10 Feb 28 16:38 ata-ST3400620A_5QH00QPN-part1 -> ../../hdc1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 ata-ST3400633A_3PM0BE0T -> ../../hdg

lrwxrwxrwx 1 root root 10 Feb 28 16:38 ata-ST3400633A_3PM0BE0T-part1 -> ../../hdg1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 ata-ST3400633A_3PM0LZ3D -> ../../hdi

lrwxrwxrwx 1 root root 10 Feb 28 16:38 ata-ST3400633A_3PM0LZ3D-part1 -> ../../hdi1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 ata-ST3750640A_5QD29FXK -> ../../hdk

lrwxrwxrwx 1 root root 10 Feb 28 16:38 ata-ST3750640A_5QD29FXK-part1 -> ../../hdk1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 ata-ST3750640A_5QD2AX3G -> ../../hda

lrwxrwxrwx 1 root root 10 Feb 28 16:38 ata-ST3750640A_5QD2AX3G-part1 -> ../../hda1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 ata-WDC_WD10EACS-00D6B1_WD-WCAU44206983 -> ../../sde

lrwxrwxrwx 1 root root 10 Feb 28 16:38 ata-WDC_WD10EACS-00D6B1_WD-WCAU44206983-part1 -> ../../sde1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 ata-WDC_WD5000AAKB-00YSA0_WD-WCAS88067391 -> ../../hdf

lrwxrwxrwx 1 root root 10 Feb 28 16:38 ata-WDC_WD5000AAKB-00YSA0_WD-WCAS88067391-part1 -> ../../hdf1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 scsi-SATA_Maxtor_6Y250P0_Y63KH45E -> ../../sdd

lrwxrwxrwx 1 root root 10 Feb 28 16:38 scsi-SATA_Maxtor_6Y250P0_Y63KH45E-part1 -> ../../sdd1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 scsi-SATA_ST31000340AS_9QJ0JPJS -> ../../sdf

lrwxrwxrwx 1 root root 10 Feb 28 16:38 scsi-SATA_ST31000340AS_9QJ0JPJS-part1 -> ../../sdf1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 scsi-SATA_ST31500341AS_9VS069T8 -> ../../sda

lrwxrwxrwx 1 root root 10 Feb 28 16:38 scsi-SATA_ST31500341AS_9VS069T8-part1 -> ../../sda1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 scsi-SATA_ST31500341AS_9VS0G9D8 -> ../../sdb

lrwxrwxrwx 1 root root 10 Feb 28 16:38 scsi-SATA_ST31500341AS_9VS0G9D8-part1 -> ../../sdb1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 scsi-SATA_WDC_WD10EACS-00_WD-WCAU44206983 -> ../../sde

lrwxrwxrwx 1 root root 10 Feb 28 16:38 scsi-SATA_WDC_WD10EACS-00_WD-WCAU44206983-part1 -> ../../sde1

lrwxrwxrwx 1 root root  9 Mar  2 05:56 usb-SanDisk_Corporation_Flash_Drive_2004110051192c10778f-0:0 -> ../../sdg

lrwxrwxrwx 1 root root 10 Mar  2 05:56 usb-SanDisk_Corporation_Flash_Drive_2004110051192c10778f-0:0-part1 -> ../../sdg1

lrwxrwxrwx 1 root root  9 Feb 28 16:38 usb-SanDisk_Corporation_MobileMate_200445269218B56190D7-0:0 -> ../../sdc

lrwxrwxrwx 1 root root 10 Feb 28 16:38 usb-SanDisk_Corporation_MobileMate_200445269218B56190D7-0:0-part1 -> ../../sdc1

 

Use the device make/serial number to identify it.  It should identify itself as a usb drive.

The device for the first partition on my additional flash drive is therefore /dev/sdg1

 

Now, we need an empty directory where we can mount the drive to access it. To create one we type:

mkdir /boot/myfiles

We can name the directory anything we like... in this case, I named it "myfiles"

 

Now to mount the file-system on the mount point type:

mount /dev/sdg1 /boot/myfiles

 

Then, you can get to the files by listing the directory

ls -l /boot/myfiles

 

By creating the mount-point under /boot (which is already visible as a shared directory on the LAN as \\tower\flash, we can get to the new flash drive by navigating to \\tower\flash\myfiles on your PC.

 

Later, when you are finished using the additional flash drive you can un-mount it by typing

umount /boot/myfiles

or

umount /dev/sdg1

Notice I typed umount, not unmount.  (It is not a typo, the first "n" is missing in the command)

 

Also notice I did not need to tell the server what type of file-system was on the flash drive. In some versions of linux, it will not mount without that option, and you will need to tell it the file-system type using the "-t" option to the mount command.

 

For a "fat" or fat32 that would be

mount -t vfat /dev/sdg1 /boot/myfiles

 

Joe L.

Link to comment

Ok, I think I ran into a snag.  I followed the instructions and figured out what it would take to mount the memory stick.  I then added a line to my 'go' script to have this get automatically mounted on restart.  Then I restart my tower.  Well, on restart, the memory stick ended up showing up in a different area.  Instead of being sde, it was now sdf.  Weirdly enough, my memory stick with unraid installed on it ended up being on sde and that memory stick ended up being mounted to itself.

 

Anyway, I appreciate your help in the first place.  So, now, anyone have any idea how I can figure out what the device name will be, or force it to always have the same device name?

 

Thanks,

Chris

Link to comment

Ok, I think I ran into a snag.  I followed the instructions and figured out what it would take to mount the memory stick.  I then added a line to my 'go' script to have this get automatically mounted on restart.  Then I restart my tower.  Well, on restart, the memory stick ended up showing up in a different area.  Instead of being sde, it was now sdf.  Weirdly enough, my memory stick with unraid installed on it ended up being on sde and that memory stick ended up being mounted to itself.

 

Anyway, I appreciate your help in the first place.  So, now, anyone have any idea how I can figure out what the device name will be, or force it to always have the same device name?

 

Thanks,

Chris

Instead of using /dev/sd? in the mount command you can use the much longer name you see in /dev/disk/by-id instead

 

So, (as an example) you can use

mount /dev/disk/by-id/usb-SanDisk_Corporation_Flash_Drive_2004110051192c10778f-0:0-part1 /boot/myfiles

 

You must use the line that has the "-part1" at the end, since you still want the first partition.

Obviously, you would use the name you see for your flash drive, not the one I used.

 

Joe L.

 

Link to comment

I had no idea this would be so difficult...  Anyway, I now have the memory stick getting mounted.  I put slimserver on the stick and now want to run slimserver.  I know that you shouldn't run slimserver as 'root', so I can create the slimserver user.  However, I think I need to change the ownership of all the slimserver files so that they are all owned by slimserver.  So, I try to run the 'chown' command, and I'm getting weird errors.

 

root@Tower:/boot/apps# chown -R slimserver slimserver/

 

This gives me an error for every file that says:

chown: changing ownership of `slimserver/sql/mysql/schema_1_up.sql': Operation not permitted

 

The command to mount the memory stick to the "/boot/apps" directory is being executed in the 'go' script, so I assume that that is being done by root.  I assume that that has something to do with the fact that chown is not working, but for the life of me I can't figure out what.  Any ideas?

 

Thanks,

Chris

Link to comment

Oh, snap.  So, I just discovered that the slimserver directory that I am trying to chown has read and execute permissions, but not write, for anyone not root.  So, for grins I tried a chmod to give everyone rwx on everthing in that folder.  I don't get any error message, but the permissions do not change.

 

Is there something weird that I don't know about a memory stick?  I formatted it as fat32 using my windows machine.  Was that incorrect?

 

Thanks in advance for any help.

 

Chris

Link to comment

Oh, snap.  So, I just discovered that the slimserver directory that I am trying to chown has read and execute permissions, but not write, for anyone not root.  So, for grins I tried a chmod to give everyone rwx on everthing in that folder.  I don't get any error message, but the permissions do not change.

 

Is there something weird that I don't know about a memory stick?  I formatted it as fat32 ...

 

Fat32 is not really a linux file system.  Its file attributes don't mean exactly the same thing as linux attributes, so some artificial mapping has to occur.  If you need full linux functionality then you may want to format your usb flash key with some other file system.

 

Link to comment

Ok, next stupid question...  How do I do that?  I've been looking for some utility that will allow me to put something other than fat or fat32 on a memory stick and I'm not having much luck.

 

My assumption is that I need to bring the stick back to my windows machine to reformat.  Sorry to ask such simple questions, but I don't really know what my options are.  Can I format it while it is plugged into the unraid box?  Should I try to have it formatted as reiser?  Something else?

 

I appreciate any help.

 

Thanks,

Chris

Link to comment

Ok, I found this.  Step by step instructions for formatting and creating a filesystem on something like a USB memory stick: http://www.ehow.com/how_1000631_hard-drive-linux.html

 

I formatted my memory stick as ext2.  There might have been a better option, but for what I am trying to do, I don't know what it would have been.  The next step is to assign a label to the drive.  What I read was that assigning a label was a good idea because it then allowed you to mount a drive using the label, which is a bit more robust than using the sdc or sde or whatever id that was just assigned to it on restart.  It seems that adding new drives can cause those things to change.  Anyway, for instructions on adding a label, check this out: http://wikis.sun.com/display/BigAdmin/Using+Disk+Labels+on+Linux+File+Systems

 

The short of it for the labels is this:

: elabel2 /dev/sde1 APPS
: elabel2 /dev/sde1

 

That will add the label 'APPS' to the first partition for the sde device.  I only had a single partition created on my sde device.  That is typical, but you can create multiple, so just look out for it.

 

Thanks to everyone who gave me enough help to get this far.

 

Chris

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...