linux查看设备的uuid,设备的UUID详解 – 笑遍世界的测试技术 – 51Testing软件测试 51Testing软件测试 -软件测试人的精神家园…

第一次看到UUID这个东西,是在Ubuntu系统中看到/boot/grub/grub.cfg中对kernel的配置:

linux/boot/vmlinuz-2.6.31-14-generic root=UUID=c74288db-c35e-4d7e-a1e8-82d6e8eff5cf

后来在分区表/etc/fstab中也有出现UUID。

所以简单学习了一下。对UUID做如下总结。

获取设备的UUID的方法(Linux系统中):

1)# blkid /dev/sda1

/dev/sda1: LABEL=”/axs3″

UUID=”298d198d-aa60-48af-a9f4-638f8f274afa” SEC_TYPE=”ext2″

TYPE=”ext3″

2) # tune2fs -l /dev/sda1 |grep ‘UUID’

298d198d-aa60-48af-a9f4-638f8f274afa

3)# ls -l /dev/disk/by-uuid/ |grep sda1 |awk ‘{print $8}’

298d198d-aa60-48af-a9f4-638f8f274afa

4)#scsi_id -p 0x80/0x83 -s /block/sda1应该只对SCSI设备有效。5)# dumpe2fs /dev/sda1 |grep ‘UUID’

dumpe2fs 1.39 (29-May-2006)

Filesystem UUID:       298d198d-aa60-48af-a9f4-638f8f274afa

这个命令不建议使用,要是分区比较大,耗时还是比较长的6)# vol_id /dev/sda1 |grep ‘UUID’

ID_FS_UUID=298d198d-aa60-48af-a9f4-638f8f274afa

ID_FS_UUID_ENC=298d198d-aa60-48af-a9f4-638f8f274afa

UUID是什么/p>

UUID(Universally Unique Identifier)全局唯一标识符,是指在一台机器上生成的数字,它保证对在同一时空中的所有机器都是唯一的。按照开放软件基金会(OSF)制定的标准计算,用到了以太 卡地址、纳秒级时间、芯片ID码和许多可能的数字。由以下几部分的组合:当前日期和时间(UUID的第一个部分与时间有关,如果你在生成一个UUID之后,过几秒又生成一个UUID,则第一个部分不同,其余相同),时钟序列,全局唯一的IEEE机器识别 (如果有 卡,从 卡获得,没有 卡以其他方式获得),UUID的唯一缺陷在于生成的结果串会比较长。

A universally unique identifier (UUID) is

an identifier standard used in software construction, standardized by the Open

Software Foundation (OSF) as part of the Distributed Computing Environment

(DCE). The intent of UUIDs is to enable distributed systems to uniquely

identify information without significant central coordination. In this context

the word unique should be taken to mean “practically unique” rather

than “guaranteed unique”. Since the identifiers have a finite size it

is possible for two differing items to share the same identifier. The

identifier size and generation process need to be selected so as to make this

sufficiently improbable in practice. Anyone can create a UUID and use it to

identify something with reasonable confidence that the same identifier will

never be unintentionally created by anyone to identify something else.

Information labeled with UUIDs can therefore be later combined into a single

database without needing to resolve name conflicts.

A UUID is 128 bits long, and can guarantee

uniqueness across space and time.UUIDs

were originally used in the Apollo Network Computing System and later in the

Open Software Foundation’s (OSF) Distributed Computing Environment (DCE), and

then in Microsoft Windows platforms.

上面说的到在grub中写到的UUID的的好处是什么呢/p>

这样做和使用/dev/sda5这种直接引用分区的方法的一个优点就是,当硬盘中增加了新的分区,或者分区的顺序改变后,仍然能够保证系统加载分区到正确的加载点。

这对于swap分区尤为重要,如果硬盘分区顺序改变,而fstab对swap分区编 做响应的调整,是不是会把其他分区给作为swap哪果是很可怕的,这个分区上的数据恐怕就要不保了。通过在/dev/disk/uuid,这里的uuid列表实际上是一些soft link文件,系统可以保证针对每一个分区生成一个唯一的编码,增加了系统的稳定性。

参考资料:

文章知识点与官方知识档案匹配,可进一步学习相关知识CS入门技能树Linux入门初识Linux24695 人正在系统学习中 相关资源:【内存遍历工具】Cheat.Engine.V5.4.简体中文版-专业指导文档类…

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2021年4月4日
下一篇 2021年4月4日

相关推荐