<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>惜分飞 &#187; linux udev</title>
	<atom:link href="https://www.xifenfei.com/tag/linux-udev/feed" rel="self" type="application/rss+xml" />
	<link>https://www.xifenfei.com</link>
	<description>提供7*24专业数据库(Oracle,SQL Server,MySQL,PostgreSQL等)恢复和技术支持@Tel:17813235971</description>
	<lastBuildDate>Sun, 25 Oct 2026 13:02:42 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>linux 7(redhat,oracle linux,centos)中使用udev</title>
		<link>https://www.xifenfei.com/2016/08/linux-7-udev.html</link>
		<comments>https://www.xifenfei.com/2016/08/linux-7-udev.html#comments</comments>
		<pubDate>Sun, 07 Aug 2016 15:07:35 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[linux 7]]></category>
		<category><![CDATA[linux 7 udev]]></category>
		<category><![CDATA[linux udev]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=6587</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2016/08/linux-7-udev.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div id="xifenfeicopyright">
<p>联系：<a href="https://www.xifenfei.com/about_xifenfei" target="_blank">手机/微信(+86 17813235971)   QQ(107644445)</a><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&#038;uin=107644445&#038;site=qq&#038;menu=yes"><img src="https://www.xifenfei.com/wp-content/themes/img/site_qq.jpg" alt="QQ咨询惜分飞" title="QQ咨询惜分飞"/></a></p>
<p>标题：<a href="https://www.xifenfei.com/2016/08/linux-7-udev.html" target="_blank">linux 7(redhat,oracle linux,centos)中使用udev</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>慢慢的linux 7的使用人越来越多了,但是linux 7相对于5和6的版本,变动确实比较大,本文主要描写在linux 7中如何实现udev,实现设备持久化,权限和所属组的修改<br />
<strong>linux版本</strong></p>
<pre class="brush: bash; title: ; notranslate">
Oracle Linux Server release 7.1
[root@www.xifenfei.com ~]# uname -a
Linux www.xifenfei.com 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 04:05:24 PST 2015 x86_64 x86_64 x86_64 GNU/Linux
</pre>
<p><strong>VMware Workstation中显示uuid需要在vmx文件中增加</strong></p>
<pre class="brush: bash; title: ; notranslate">
disk.enableUUID = &quot;TRUE&quot;
</pre>
<p><strong>查看磁盘分区</strong></p>
<pre class="brush: bash; title: ; notranslate">
[root@www.xifenfei.com ~]# fdisk -l

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xf60fe217

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     2099199     1048576   83  Linux

Disk /dev/sda: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000bce7c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048     4204543     2101248   8e  Linux LVM
/dev/sda2   *     4204544    79702015    37748736   83  Linux

Disk /dev/sdc: 32.2 GB, 32212254720 bytes, 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/ol-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
</pre>
<p><strong>查看磁盘uuid</strong></p>
<pre class="brush: bash; title: ; notranslate">
[root@www.xifenfei.com ~]# /usr/lib/udev/scsi_id -g -u /dev/sdb1
36000c29e91831cedbe69afe6cc08daf7
[root@www.xifenfei.com ~]# /usr/lib/udev/scsi_id -g -u /dev/sdc
36000c292495e9d9de6f21640cc7b53b9
</pre>
<p><strong>udev绑定</strong></p>
<pre class="brush: bash; title: ; notranslate">
[root@www.xifenfei.com ~]# more /etc/udev/rules.d/99-my-asmdevices.rules 
KERNEL==&quot;sd*[!0-9]&quot;, ENV{DEVTYPE}==&quot;disk&quot;, SUBSYSTEM==&quot;block&quot;, PROGRAM==&quot;/usr/lib/udev/scsi_id -g -u -d $devnode&quot;,
 RESULT==&quot;36000c292495e9d9de6f21640cc7b53b9&quot;, RUN+=&quot;/bin/sh -c 'mknod /dev/xifenfei-sdc b $major $minor; 
chown oracle:dba /dev/xifenfei-sdc; chmod 0660 /dev/xifenfei-sdc'&quot;

KERNEL==&quot;sd?1&quot;, SUBSYSTEM==&quot;block&quot;, PROGRAM==&quot;/lib/udev/scsi_id -g -u -d /dev/$parent&quot;, 
RESULT==&quot;36000c29e91831cedbe69afe6cc08daf7&quot;, SYMLINK+=&quot;xifenfei-sdb1&quot;, OWNER=&quot;oracle&quot;, GROUP=&quot;dba&quot;, MODE=&quot;0660&quot;
</pre>
<p><strong>绑定结果</strong></p>
<pre class="brush: bash; title: ; notranslate">
[root@www.xifenfei.com ~]# ls -l /dev/xifenfei-*
lrwxrwxrwx. 1 root   root     4 Aug  7 22:49 /dev/xifenfei-sdb1 -&gt; sdb1
brw-rw----. 1 oracle dba  8, 32 Aug  7 22:36 /dev/xifenfei-sdc
[root@www.xifenfei.com ~]# ls -l /dev/sdb1
brw-rw----. 1 oracle dba 8, 17 Aug  7 22:49 /dev/sdb1
</pre>
<p><strong>udev只修改磁盘权限</strong></p>
<pre class="brush: bash; title: ; notranslate">
[root@www.xifenfei.com ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (2-4, default 2): 
First sector (2099200-41943039, default 2099200): 
Using default value 2099200
Last sector, +sectors or +size{K,M,G} (2099200-41943039, default 41943039): +1G
Partition 2 of type Linux and of size 1 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@www.xifenfei.com ~]# more /etc/udev/rules.d/99-my-asmdevices.rules 
KERNEL==&quot;sd?2&quot;, SUBSYSTEM==&quot;block&quot;, PROGRAM==&quot;/lib/udev/scsi_id -g -u -d /dev/$parent&quot;,
 RESULT==&quot;36000c29e91831cedbe69afe6cc08daf7&quot;,  OWNER=&quot;oracle&quot;, GROUP=&quot;dba&quot;, MODE=&quot;0660&quot;
[root@www.xifenfei.com ~]# /sbin/udevadm trigger --type=devices --action=change
[root@www.xifenfei.com ~]# ls -l /dev/sdb2
brw-rw----. 1 oracle dba 8, 18 Aug  7 23:14 /dev/sdb2
</pre>
<p>这里可以发现在linux 7中使用了两种方法绑定udev,一种是真实生成udev设备,另外一种是通过软连接实现.感谢lunar(<a href="http://www.lunar2013.com" title="Lunar的oracle实验室" target="_blank">Lunar的oracle实验室</a>)在linux 7学习中的帮助</p>
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2014/01/multipath%e5%ae%9e%e7%8e%b0%e8%ae%be%e5%a4%87%e7%94%a8%e6%88%b7%e7%bb%84%e8%ae%be%e7%bd%ae.html" rel="bookmark" class="crp_title">multipath实现设备用户组设置</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/06/iscsiadm%e4%b8%bb%e8%a6%81%e6%93%8d%e4%bd%9c%e5%91%bd%e4%bb%a4.html" rel="bookmark" class="crp_title">iscsiadm主要操作命令</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2013/03/%e5%88%b6%e4%bd%9cu%e7%9b%98%e5%88%b7exadata.html" rel="bookmark" class="crp_title">制作U盘刷EXADATA</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2016/06/asm-disk-format-ext4-recovery.html" rel="bookmark" class="crp_title">oracle asm disk格式化恢复&#8212;格式化为ext4文件系统</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/10/arm-vg-err-mysql-recovery.html" rel="bookmark" class="crp_title">arm环境vg损坏mysql数据库恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/03/gzexe%e5%8a%a0%e5%af%86shell%e8%84%9a%e6%9c%ac.html" rel="bookmark" class="crp_title">gzexe加密shell脚本</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2017/07/disable_transparent_hugepages.html" rel="bookmark" class="crp_title">Disable Transparent HugePages</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2021/05/ext4-lvm-resize.html" rel="bookmark" class="crp_title">ext4 lvm在线扩容</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2010/09/shell%e7%bc%96%e7%a8%8b%e2%80%94%e2%80%94%e5%9f%ba%e6%9c%ac%e8%af%ad%e6%b3%95.html" rel="bookmark" class="crp_title">shell编程——基本语法</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/04/%e4%bd%bf%e7%94%a8dd%e5%a4%8d%e5%88%b6asm%e4%b8%ad%e6%96%87%e4%bb%b6.html" rel="bookmark" class="crp_title">使用dd复制asm中文件</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2010/10/oracle%e6%9f%a5%e7%9c%8bobject%e5%af%b9%e8%b1%a1%e4%bd%bf%e7%94%a8%e7%a9%ba%e9%97%b4.html" rel="bookmark" class="crp_title">oracle查看object对象使用空间</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2017/05/asm-disk-partition-lost-recovery.html" rel="bookmark" class="crp_title">asm磁盘分区丢失恢复</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2016/08/linux-7-udev.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
