LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-15-2007, 08:02 PM   #1
markw8500
Member
 
Registered: Jul 2005
Posts: 104

Rep: Reputation: 15
how to reset usb device to "sda1"...


I have a external usb hard drive that I use to back up to and sometimes what happens is that it will start a sda1, then if I unplug it then plug it back in it will go to sdb1, then sdc1, etc... I am wondering if there is a command that I can put in my script that will reset the device names back to sda1 so then I can always mount it to sda1....

Mark
 
Old 11-15-2007, 08:12 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,140

Rep: Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123
Look up udev rules - has been discussed several times.
Sounds like your distro has some code in place that might be doing this.
 
Old 11-16-2007, 06:07 AM   #3
markw8500
Member
 
Registered: Jul 2005
Posts: 104

Original Poster
Rep: Reputation: 15
Can you give me a little more than that...
 
Old 11-16-2007, 09:54 AM   #4
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by markw8500 View Post
Can you give me a little more than that...
Here is what I use for my local rules file for my usb devices.

Code:
cat /etc/udev/rules.d/010-local.rules

KERNEL=="sd*", SUBSYSTEMS=="usb", ATTRS{product}=="DMC-FZ7", SYMLINK+="camera"
KERNEL=="sd*", BUS=="usb" , ATTRS{serial}=="1000000019AA", NAME="%k", SYMLINK+="bytecc_1" , MODE="0777" , OWNER="stephen"
KERNEL=="sd*", BUS=="usb" , ATTRS{serial}=="100000001BF0", NAME="%k", SYMLINK+="bytecc_2" , MODE="0777" , OWNER="stephen"
KERNEL=="sd*", BUS=="usb" , ATTRS{serial}=="400000000887", NAME="%k", SYMLINK+="bytecc_3" , MODE="0777" , OWNER="stephen"
KERNEL=="sd*" , BUS=="usb", ATTRS{serial}=="013550967FFF", NAME="%k", SYMLINK+="lacie_1" , MODE="0777" , OWNER="stephen"
KERNEL=="sd*" , BUS=="usb", ATTRS{serial}=="152D203380B6", NAME="%k", SYMLINK+="lacie_2" , MODE="0777" , OWNER="stephen"
Now you get these settings (ATTRS{serial}=="1000000019AA" for instance) by looking at the output of the command udevinfo -a -p /sys/block/sda now once you have the serial number for your drive copy and paste one of the lines I have to your own rules file changing the OWNER to your username and the serial to your serial number.

Now you need to put an entry in your /etc/fstab similar to below.

Code:
cat /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/sda1       /               reiserfs notail,noatime          0       1
/dev/sda3       /home           reiserfs defaults,noatime        0       2
/dev/sda5       /music          reiserfs defaults,noatime       0       2
/dev/sda6       /video          reiserfs defaults,noatime       0       2
/dev/sda7       none            swap    sw              0       0
/dev/sr0        /media/cdrom0   udf,iso9660 ro,user,noauto  0       0
#/dev/hdd        /media/cdrom1   udf,iso9660 ro,user,noauto  0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto  0       0
sysfs           /sys            sysfs   defaults        0       0

## Lumix Camera
/dev/camera /media/camera auto rw,user,noauto     0 0

## External Seagate 200gb disk
/dev/bytecc_1   /media/bytecc_1 reiserfs defaults,user,noauto,noatime 0 0
## External WD 500gb disk
/dev/bytecc_2   /media/bytecc_2 reiserfs defaults,user,noauto,noatime 0 0
## External WD 500gb disk
/dev/bytecc_3   /media/bytecc_3 reiserfs defaults,user,noauto,noatime 0 0
## External Lacie 500gb
/dev/lacie_1   /media/lacie_1 reiserfs defaults,user,noauto,noatime 0 0
## External Lacie 500gb
/dev/lacie_2   /media/lacie_2 reiserfs defaults,user,noauto,noatime 0 0
And of course you have to make a mount point in my case I created them in the /media directory your distro may have a different spot it puts them in. Once you have created the rule, put the line in the /etc/fstab and made the mount point when you plug in the drive the /dev/???? (whatever you named the SYMLINK+="????" in the rules file) will appear and you can access the drive as this same device every time. I just put icon shortcuts on my desktop for a filesystem device in KDE and click on them when I want to access, if I had wanted I could simply have let hald auto-mount and popup a file system browser window with Konqueror.
 
Old 11-21-2007, 02:29 PM   #5
ScottReed
Member
 
Registered: Dec 2005
Location: Montana
Distribution: Debian "squeeze"
Posts: 157

Rep: Reputation: 30
Question HAL vs UDEV

I've found some interesting reads about HAL vs UDEV, but what would you all recommend?

First off, before I went to Slack 12, I was on Slack 10 and was using UDEV exclusively. My external thumb drives and lacie were all handled via udev and I had appropriate /etc/fstab entries.

Now with Slack 12.0 my devices automatically get assigned a name (ie: disk) and get mounted to /media/name (ie: /media/disk) automatically via HALD.

This really is unfortunate because it appears that my /etc/udev/rules.d/10-udev.rules is being ignored and I am no longer getting devices created in /dev via udev.

For example, I had my Slack 10 udev.rules configured to assign like this:

Kingston thumbdrive = /dev/datatraveller
Crucial Gizmo thumb = /dev/gizmo
Lacie FireWire Ext HD = /dev/lacie

I am using the same udev rules in Slack 12 and they are being ignored completely.

Should I just get rid of hald service?

Scott
 
Old 11-21-2007, 03:29 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,140

Rep: Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123
I haven't used Slack since 10.something, but have you had a look at the sticky by rworkman in the slack forum ???. Seems to cover things ...
 
Old 11-21-2007, 03:54 PM   #7
ScottReed
Member
 
Registered: Dec 2005
Location: Montana
Distribution: Debian "squeeze"
Posts: 157

Rep: Reputation: 30
sweet, will check it out!
 
Old 11-26-2007, 10:06 AM   #8
ScottReed
Member
 
Registered: Dec 2005
Location: Montana
Distribution: Debian "squeeze"
Posts: 157

Rep: Reputation: 30
Question

The writeup by rworkman was helpful, but not what I was looking for overall. I stepped away from this issue end of last week and came back to it this morning. I still cannot get my 10-local.rules UDEV rule to correctly create dev nodes for me.

For simplicity sake, I just want to get my Lacie FW 160gb ext drive set to /dev/lacie so I can create an fstab entry for a specific mount point.

udevinfo on the device in question:

Code:
udevinfo -a - p /sys/block/sdc

looking at device '/block/sdc':
    KERNEL=="sdc"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{stat}=="    2498       71    20054    17266     1084    28373   235656   786886        0    17650   804152"
    ATTR{size}=="320173056"
    ATTR{removable}=="0"
    ATTR{range}=="16"
    ATTR{dev}=="8:32"

  looking at parent device '/devices/pci0000:00/0000:00:0e.0/fw-host0/00d04b3c090824d4/00d04b3c090824d4-0/host7/target7:0:0/7:0:0:0':
    KERNELS=="7:0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"
    ATTRS{ioerr_cnt}=="0x0"
    ATTRS{iodone_cnt}=="0xe0a"
    ATTRS{iorequest_cnt}=="0xe0a"
    ATTRS{iocounterbits}=="32"
    ATTRS{timeout}=="30"
    ATTRS{state}=="running"
    ATTRS{rev}=="YAR4"
    ATTRS{model}=="Y160P0          "
    ATTRS{vendor}=="Maxtor 6"
    ATTRS{scsi_level}=="5"
    ATTRS{type}=="14"
    ATTRS{queue_type}=="none"
    ATTRS{queue_depth}=="1"
    ATTRS{device_blocked}=="0"
    ATTRS{ieee1394_id}=="00d04b3c090824d4:0:0"

  looking at parent device '/devices/pci0000:00/0000:00:0e.0/fw-host0/00d04b3c090824d4/00d04b3c090824d4-0/host7/target7:0:0':
    KERNELS=="target7:0:0"
    SUBSYSTEMS==""
    DRIVERS==""

  looking at parent device '/devices/pci0000:00/0000:00:0e.0/fw-host0/00d04b3c090824d4/00d04b3c090824d4-0/host7':
    KERNELS=="host7"
    SUBSYSTEMS==""
    DRIVERS==""

  looking at parent device '/devices/pci0000:00/0000:00:0e.0/fw-host0/00d04b3c090824d4/00d04b3c090824d4-0':
    KERNELS=="00d04b3c090824d4-0"
    SUBSYSTEMS=="ieee1394"
    DRIVERS=="sbp2"
    ATTRS{model_name_kv}=="LaCie Hard Drive Firewire   "
    ATTRS{model_id}=="0x000001"
    ATTRS{version}=="0x010483"
    ATTRS{specifier_id}=="0x00609e"
    ATTRS{ignore_driver}=="0"
    ATTRS{length}=="0"
    ATTRS{address}=="0x0000fffff0000830"

  looking at parent device '/devices/pci0000:00/0000:00:0e.0/fw-host0/00d04b3c090824d4':
    KERNELS=="00d04b3c090824d4"
    SUBSYSTEMS=="ieee1394"
    DRIVERS==""
    ATTRS{vendor_name_kv}=="LaCie   "
    ATTRS{bus_options}=="IRMC_0_ CMC_0_ ISC_0_ BMC_0_ PMC_0_ GEN_0_ LSPD_2_ MAX_REC_64_ MAX_ROM_0_ CYC_CLK_ACC_255_"
    ATTRS{nodeid}=="0xffc0"
    ATTRS{vendor_id}=="0x00d04b"
    ATTRS{capabilities}=="0x0083c0"
    ATTRS{guid_vendor_id}=="0x00d04b"
    ATTRS{guid}=="0x00d04b3c090824d4"

  looking at parent device '/devices/pci0000:00/0000:00:0e.0/fw-host0':
    KERNELS=="fw-host0"
    SUBSYSTEMS=="ieee1394"
    DRIVERS=="nodemgr"
    ATTRS{is_busmgr}=="0"
    ATTRS{is_irm}=="1"
    ATTRS{is_cycmst}=="1"
    ATTRS{is_root}=="1"
    ATTRS{in_bus_reset}=="0"
    ATTRS{nodes_active}=="2"
    ATTRS{selfid_count}=="2"
    ATTRS{node_count}=="2"

  looking at parent device '/devices/pci0000:00/0000:00:0e.0':
    KERNELS=="0000:00:0e.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="ohci1394"
    ATTRS{msi_bus}==""
    ATTRS{broken_parity_status}=="0"
    ATTRS{enable}=="1"
    ATTRS{modalias}=="pci:v00001106d00003044sv00001462sd0000702Dbc0Csc00i10"
    ATTRS{local_cpus}=="1"
    ATTRS{irq}=="5"
    ATTRS{class}=="0x0c0010"
    ATTRS{subsystem_device}=="0x702d"
    ATTRS{subsystem_vendor}=="0x1462"
    ATTRS{device}=="0x3044"
    ATTRS{vendor}=="0x1106"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
Current udev rule:

Code:
# Lacie
BUS="scsi", ATTRS{model}=="Y160P0", ATTRS{vendor}=="Maxtor 6", KERNEL="sd?1", NAME="%k", SYMLINK="lacie", MODE="0666"
What am I doing wrong? With the exception of changing from SYSFS to ATTRS in the rule, this is the same rule that was working flawlessly in Slack 10

Thanks,
Scott
 
Old 11-26-2007, 10:40 AM   #9
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by ScottReed View Post
The writeup by rworkman was helpful, but not what I was looking for overall. I stepped away from this issue end of last week and came back to it this morning. I still cannot get my 10-local.rules UDEV rule to correctly create dev nodes for me.


Try something like this.

Code:
# Lacie
KERNEL="sd*", BUS="scsi", ATTRS{model}=="Y160P0", ATTRS{vendor}=="Maxtor 6", NAME="%k", SYMLINK+="lacie", MODE="0666"
Or when I used the firewire for my Bytecc drive I used this.

Code:
KERNEL=="sd*", BUS=="ieee1394" , ATTRS{guid}=="0x0050770e000019ab", NAME="%k", SYMLINK+="bytecc_1" , MODE="0777" , OWNER="stephen"
So using your settings something like this with the MODE set how you seem to want it.

Code:
KERNEL=="sd*", BUS=="ieee1394" , ATTRS{guid}=="0x00d04b3c090824d4", NAME="%k", SYMLINK+="lacie" , MODE="0666"
And if you find that the drive does not seem to want to be recognized then install gscanbus using it as root making sure that the raw1394 module is loaded then you will need to use the rescan bus option a time or two until your drive shows up in the graphic viewer for it to work, firewire is a PITA USB works without the headaches for my drives.
 
Old 11-26-2007, 11:48 AM   #10
ScottReed
Member
 
Registered: Dec 2005
Location: Montana
Distribution: Debian "squeeze"
Posts: 157

Rep: Reputation: 30
Smile

Quote:
Code:
KERNEL=="sd*", BUS=="ieee1394" , ATTRS{guid}=="0x00d04b3c090824d4", NAME="%k", SYMLINK+="lacie" , MODE="0666"
That worked! Guess the BUS as scsi was wrong

Added the following to my /etc/fstab and all is mounting fine now:

Code:
/dev/lacie	/mnt/lacie		ext3	defaults,user,noauto,noatime 	0 	0
Scott
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
2.6.19: VFS: Cannot Open root device "sda1" or unknown-block(0,0) havok1977 Linux - Kernel 19 02-24-2021 12:35 AM
"/dev/sda1 is not a valid block device" used to be millionknives Linux - Hardware 6 12-13-2005 06:39 PM
"Unable to open USB device "usb://hp/LaserJet%201000": No such device" lordshipmayhem Mandriva 2 08-08-2004 04:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration