Linux磁盘分区UUID的获取及其UUID的作用

注:UUID-Universally Unique IDentifiers全局唯一标识符

一、Linux磁盘分区UUID的获取方法

1、[san@localhost ~]$ ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 2010-01-18 02:18 0733f5c1-cb85-4f98-9d4f-122cfcee9806 -> http://www.cnblogs.com/sdc1


lrwxrwxrwx 1 root root 10 2010-01-18 01:13 3754-1BDB -> http://www.cnblogs.com/sda5
lrwxrwxrwx 1 root root 10 2010-01-18 01:13 41a18221-6b1f-4ca2-9bc3-dc353c87d932 -> http://www.cnblogs.com/sda9
lrwxrwxrwx 1 root root 10 2010-01-18 01:13 57183ff9-d4a5-4623-a47f-f8f17339be03 -> http://www.cnblogs.com/sda7
lrwxrwxrwx 1 root root 10 2010-01-18 01:13 6bdf487f-cad7-4197-b0d9-4ddc6df1de2d -> http://www.cnblogs.com/sda8
lrwxrwxrwx 1 root root 10 2010-01-18 01:13 ae6dcc02-3f7f-47cc-8a6e-e29218b4d345 -> http://www.cnblogs.com/sda6
lrwxrwxrwx 1 root root 10 2010-01-18 01:13 CC47-2A04 -> http://www.cnblogs.com/sda1


lrwxrwxrwx 1 root root 10 2010-01-18 02:18 d2154d3e-3006-4a05-a134-f721145f1670 -> http://www.cnblogs.com/sdc2
lrwxrwxrwx 1 root root 10 2010-01-18 02:18 df974270-dbba-4f87-8121-427636dab396 -> http://www.cnblogs.com/sdc3


lrwxrwxrwx 1 root root 10 2010-01-18 01:52 f535fef8-f392-4c84-8e7a-85915d9179fb -> http://www.cnblogs.com/sdb1


VS:

lrwxrwxrwx 1 root root 10 2010-01-18 02:25 0733f5c1-cb85-4f98-9d4f-122cfcee9806 -> http://www.cnblogs.com/sdb1
lrwxrwxrwx 1 root root 10 2010-01-18 01:13 3754-1BDB -> http://www.cnblogs.com/sda5
lrwxrwxrwx 1 root root 10 2010-01-18 01:13 41a18221-6b1f-4ca2-9bc3-dc353c87d932 -> http://www.cnblogs.com/sda9
lrwxrwxrwx 1 root root 10 2010-01-18 01:13 57183ff9-d4a5-4623-a47f-f8f17339be03 -> http://www.cnblogs.com/sda7
lrwxrwxrwx 1 root root 10 2010-01-18 01:13 6bdf487f-cad7-4197-b0d9-4ddc6df1de2d -> http://www.cnblogs.com/sda8
lrwxrwxrwx 1 root root 10 2010-01-18 01:13 ae6dcc02-3f7f-47cc-8a6e-e29218b4d345 -> http://www.cnblogs.com/sda6
lrwxrwxrwx 1 root root 10 2010-01-18 01:13 CC47-2A04 -> http://www.cnblogs.com/sda1
lrwxrwxrwx 1 root root 10 2010-01-18 02:25 d2154d3e-3006-4a05-a134-f721145f1670 -> http://www.cnblogs.com/sdb2
lrwxrwxrwx 1 root root 10 2010-01-18 02:25 df974270-dbba-4f87-8121-427636dab396 -> http://www.cnblogs.com/sdb3


2、通过blkid命令


[san@localhost ~]$ blkid /dev/sdb1
/dev/sdb1: LABEL="SAN " UUID="f535fef8-f392-4c84-8e7a-85915d9179fb " TYPE="ext3 "

[san@localhost ~]$ blkid /dev/sda6

/dev/sda6: LABEL="/" UUID="ae6dcc02-3f7f-47cc-8a6e-e29218b4d345 " TYPE="ext3" SEC_TYPE="ext2 "

二、Linux UUID的作用及意义

 原因1:它是真正的唯一标志符

UUID为系统中的存储设备提供唯一的标识字符串,不管这个设备是什么类型的。如果你在系统中添加了新的存储设备如硬盘,很可能会造成一些麻烦,比如说启动的时候因为找不到设备而失败,而使用UUID则不会有这样的问题。

原因2:设备名并非总是不变的

自动分配的设备名称并非总是一致的,它们依赖于启动时内核加载模块的顺序。如果你在插入了USB盘时启动了系统,而下次启动时又把它拔掉了,就有可能导致设备名分配不一致。

使用UUID对于挂载移动设备也非常有好处──例如我有一个24合一的读卡器,它支持各种各样的卡,而使用UUID总可以使同一块卡挂载在同一个地方。

原因3:ubuntu中的许多关键功能现在开始依赖于UUID

例如grub──系统引导程序,现在可以识别UUID,打开你的/boot/grub/menu.lst,你可以看到类似如下的语句:
title Ubuntu hardy (development branch), kernel 2.6.24-16-generic
root (hd2,0)
kernel /boot/vmlinuz-2.6.24-16-generic root=UUID=c73a37c8-ef7f-40e4-b9de-8b2f81038441 ro quiet splash
initrd /boot/initrd.img-2.6.24-16-generic
quiet

本段出处:DIY部落(http://www.diybl.com/course/6_system/linux/Linuxjs/2008930/147029.html)

posted @ 2011-01-30 01:35  xiahaitao  阅读(33393)  评论(1编辑  收藏  举报