如何固定2个硬盘的设备文件名

声卡/显卡/打印机/USB设备等硬件问题(网卡问题请发上面的网卡板块)
回复
frankxue
帖子: 4
注册时间: 2008-06-25 14:28
送出感谢: 0
接收感谢: 0

如何固定2个硬盘的设备文件名

#1

帖子 frankxue » 2008-07-01 21:45

我的电脑上有2个Hitachi的SATA硬盘,安装ubuntu 8.04,每次启动/dev/sda 和 /dev/sdb对应不同的硬盘(经常变),
我想这是2.6.x 的kernel使用了udev的原因,应该是可以通过写udev的rules来使得设备文件名固定下来(/dev/sda对应物理上第1块SATA盘,/dev/sdb对应第2块硬盘),但我没有写过udev的rules,请问哪位有这方面的经验?

附详细信息:
# udevinfo -a -p $(udevinfo -q path -n /dev/sda)
looking at device '/block/sda':
KERNEL=="sda"
SUBSYSTEM=="block"
DRIVER==""
ATTR{dev}=="8:0"
ATTR{range}=="16"
ATTR{removable}=="0"
ATTR{size}=="234441648"
ATTR{stat}==" 23792 21139 1412657 258864 13020 47176 482512 1108816 0 131040 1370616"
ATTR{capability}=="12"

looking at parent device '/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0':
KERNELS=="0:0:0:0"
SUBSYSTEMS=="scsi"
DRIVERS=="sd"
ATTRS{device_blocked}=="0"
ATTRS{type}=="0"
ATTRS{scsi_level}=="6"
ATTRS{vendor}=="ATA "
ATTRS{model}=="Hitachi HTS54251"
ATTRS{rev}=="BB2O"
ATTRS{state}=="running"
ATTRS{timeout}=="30"
ATTRS{iocounterbits}=="32"
ATTRS{iorequest_cnt}=="0x8fdc"
ATTRS{iodone_cnt}=="0x8fdc"
ATTRS{ioerr_cnt}=="0x0"
ATTRS{modalias}=="scsi:t-0x00"
ATTRS{evt_media_change}=="0"
ATTRS{queue_depth}=="31"
ATTRS{queue_type}=="simple"

looking at parent device '/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0':
KERNELS=="target0:0:0"
SUBSYSTEMS==""
DRIVERS==""

looking at parent device '/devices/pci0000:00/0000:00:1f.2/host0':
KERNELS=="host0"
SUBSYSTEMS==""
DRIVERS==""

looking at parent device '/devices/pci0000:00/0000:00:1f.2':
KERNELS=="0000:00:1f.2"
SUBSYSTEMS=="pci"
DRIVERS=="ahci"
ATTRS{vendor}=="0x8086"
ATTRS{device}=="0x2829"
ATTRS{subsystem_vendor}=="0x17aa"
ATTRS{subsystem_device}=="0x20a7"
ATTRS{class}=="0x010601"
ATTRS{irq}=="218"
ATTRS{local_cpus}=="ff"
ATTRS{modalias}=="pci:v00008086d00002829sv000017AAsd000020A7bc01sc06i01"
ATTRS{enable}=="1"
ATTRS{broken_parity_status}=="0"
ATTRS{msi_bus}==""

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


# udevinfo -a -p $(udevinfo -q path -n /dev/sdb)
looking at device '/block/sdb':
KERNEL=="sdb"
SUBSYSTEM=="block"
DRIVER==""
ATTR{dev}=="8:16"
ATTR{range}=="16"
ATTR{removable}=="0"
ATTR{size}=="234441648"
ATTR{stat}==" 727 14929 18557 5760 29 315 2752 64 0 3868 5824"
ATTR{capability}=="12"

looking at parent device '/devices/pci0000:00/0000:00:1f.1/host3/target3:0:0/3:0:0:0':
KERNELS=="3:0:0:0"
SUBSYSTEMS=="scsi"
DRIVERS=="sd"
ATTRS{device_blocked}=="0"
ATTRS{type}=="0"
ATTRS{scsi_level}=="6"
ATTRS{vendor}=="ATA "
ATTRS{model}=="HITACHI HTS54161"
ATTRS{rev}=="SB3I"
ATTRS{state}=="running"
ATTRS{timeout}=="30"
ATTRS{iocounterbits}=="32"
ATTRS{iorequest_cnt}=="0x304"
ATTRS{iodone_cnt}=="0x304"
ATTRS{ioerr_cnt}=="0x0"
ATTRS{modalias}=="scsi:t-0x00"
ATTRS{evt_media_change}=="0"
ATTRS{queue_depth}=="1"
ATTRS{queue_type}=="none"

looking at parent device '/devices/pci0000:00/0000:00:1f.1/host3/target3:0:0':
KERNELS=="target3:0:0"
SUBSYSTEMS==""
DRIVERS==""

looking at parent device '/devices/pci0000:00/0000:00:1f.1/host3':
KERNELS=="host3"
SUBSYSTEMS==""
DRIVERS==""

looking at parent device '/devices/pci0000:00/0000:00:1f.1':
KERNELS=="0000:00:1f.1"
SUBSYSTEMS=="pci"
DRIVERS=="ata_piix"
ATTRS{vendor}=="0x8086"
ATTRS{device}=="0x2850"
ATTRS{subsystem_vendor}=="0x17aa"
ATTRS{subsystem_device}=="0x20a6"
ATTRS{class}=="0x01018a"
ATTRS{irq}=="20"
ATTRS{local_cpus}=="ff"
ATTRS{modalias}=="pci:v00008086d00002850sv000017AAsd000020A6bc01sc01i8a"
ATTRS{enable}=="1"
ATTRS{broken_parity_status}=="0"
ATTRS{msi_bus}==""

looking at parent device '/devices/pci0000:00':
KERNELS=="pci0000:00"
SUBSYSTEMS==""
DRIVERS==""
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙
送出感谢: 4 次
接收感谢: 256 次

#2

帖子 eexpress » 2008-07-01 22:12

/dev/sda 和 /dev/sdb 还经常变啊。奇怪
● 鸣学
头像
windwiny
帖子: 2254
注册时间: 2007-03-13 17:26
送出感谢: 0
接收感谢: 1 次

#3

帖子 windwiny » 2008-07-02 8:55

代码: 全选

cat >>  /etc/udev/rules.d/60-my-storage.rules <<EOF
#SUBSYSTEM=="block",ATTRS{serial}=="0406181936511",NAME="dev_MY_udisk"
EOF
frankxue
帖子: 4
注册时间: 2008-06-25 14:28
送出感谢: 0
接收感谢: 0

#4

帖子 frankxue » 2008-07-04 18:09

ok,我自己解决了这个问题,通过UUID来mount

1.找出UUID:
#blkid
/dev/sda1: UUID="def36252-3c73-48f5-a773-a7a247105e31" TYPE="ext3"
/dev/sda5: UUID="38F055B2F055775A" TYPE="ntfs"
/dev/sda6: UUID="065C7AFD5C7AE739" TYPE="ntfs"
/dev/sdb1: UUID="207F-9BB8" TYPE="vfat"
/dev/sdb5: UUID="F4D82E47D82E0906" TYPE="ntfs"
/dev/sdb6: UUID="C67C35B27C359DDD" TYPE="ntfs"
/dev/sda2: UUID="db888983-1e19-4892-bca3-e6b8a42e7058" SEC_TYPE="ext2" TYPE="ext3"
/dev/sda7: TYPE="swap" UUID="e69e5f87-1764-433d-bdf3-c097e3b9045c"

2.修改/etc/fstab
#vi /etc/fstab
UUID=F4D82E47D82E0906 /media/diskd ntfs-3g user,iocharset=utf-8 0 0
UUID=C67C35B27C359DDD /media/diske ntfs-3g user,iocharset=utf-8 0 0

UUID=38F055B2F055775A /media/diskf ntfs-3g user,iocharset=utf-8 0 0
UUID=065C7AFD5C7AE739 /media/diskg ntfs-3g user,iocharset=utf-8 0 0
回复

回到 “常用硬件支持”