Linux 获得硬盘UUID

网络整理 - 07-30

下面是PHP代码

$dh = opendir('/dev/disk/by-uuid/'); 

 while($file = readdir($dh)){ 

         if(is_link('/dev/disk/by-uuid/'.$file)){ 

               if( realpath('/dev/disk/by-uuid/'.$file) == '/dev/sda1'){ 

                        echo 'Found uuid='.$file.PHP_EOL; 

              } 

       } 

 }