OSWikiHK: 请协力 GPLv3 的中文翻译工作。
使用 UUID 管理檔案系統
OSWikiHK,自由中文開源知識庫
| 標準文章 | |
|---|---|
| 作者: | Jadedragon |
| 協力: | Roy Chan |
| 校對: | - |
| 級別: | 初階 |
| 分享本文: | |
傳統上 GNU/Linux 在 /etc/fstab 都直接使用裝置檔案名稱 (/dev/hda1 或 /dev/sda5 等) 指定要掛載的儲存裝置。然而裝置檔案名稱有時會因為 BIOS 的設定或插入次序而改變,引起混亂。部份 GNU/Linux distribution 等已改用檔案系統標簽 (filesystem label) 或 UUID (Universal Unique Identifier) 來指定要掛載的儲存裝置。
現時主要有 Ubuntu 預設使用 UUID 指定要掛載的儲存裝置。
目录 |
查看 UUID
要顯示各儲存裝置的 UUID,可以使用命令「blkid -s UUID」:
/dev/hda3: UUID="440612e0-9cea-4751-8e59-07ebffc589c2" /dev/hda1: UUID="027ecc62-d346-411d-ae6c-c3eaa87fb195" /dev/hdc1: UUID="fdbe6b52-755f-4e14-b970-b3be01543acc" /dev/hdc2: UUID="e61f4197-5f00-4f4f-917c-290922a85339" /dev/hdc3: UUID="06679282-4973-476a-98ae-4986f504816f" /dev/hdc5: UUID="51f7e9a4-5154-4e29-a7a6-208417290b85" /dev/hdc6: UUID="4bf4855e-96b9-43c4-89d7-b3d0087560e1" /dev/hdc8: UUID="5a15d9d7-5a17-4d71-a2b6-eb978e6905cd" /dev/hdc9: UUID="dc348785-9acb-4484-b52a-da000ffba601"
改變 UUID
Ext2/Ext3/Ext4
要設定 UUID 可以使用命令「tune2fs -U UUID 裝置檔案」,例如把 /dev/sda1 命名為 /boot:
tune2fs -U 51f7e9a4-5154-4e29-a7a6-208417290b85 /dev/sda1
-U 的參數如果為 random 表示直接產生一個隨意的新 UUID:
tune2fs -U random /dev/sda1
-U 的參數如果為 time 表示直接依當前時間產生一個新的 UUID:
tune2fs -U time /dev/sda1
-U 的參數如果為 clear 表示清除檔案系統的 UUID:
tune2fs -U clear /dev/sda1
SGI XFS
要設定 UUID 可以使用命令「xfs_admin -U label 裝置檔案」,例如把 /dev/sda1 命名為 /boot:
xfs_admin -U 51f7e9a4-5154-4e29-a7a6-208417290b85 /dev/sda1
-U 的參數如果為 generate 表示直接產生一個新的 UUID:
xfs_admin -U generate /dev/sda1
-U 的參數如果為 nil 表示清除檔案系統的 UUID:
xfs_admin -U nil /dev/sda1
ReiserFS
要設定 UUID 可以使用命令「reiserfstune -u label 裝置檔案」,例如把 /dev/sda1 命名為 /boot:
reiserfstune -u 51f7e9a4-5154-4e29-a7a6-208417290b85 /dev/sda1
IBM JFS
要設定 UUID 可以使用命令「jfs_tune -U label 裝置檔案」,例如把 /dev/sda1 命名為 /boot:
jfs_tune -U 51f7e9a4-5154-4e29-a7a6-208417290b85 /dev/sda1
-U 的參數如果為 random 表示直接產生一個隨意的新 UUID:
jfs_tune -U random /dev/sda1
-U 的參數如果為 time 表示直接依當前時間產生一個新的 UUID:
jfs_tune -U time /dev/sda1
-U 的參數如果為 clear 表示清除檔案系統的 UUID:
jfs_tune -U clear /dev/sda1
在 mount 命令中使用 UUID 掛載檔案系統
使用 mount 命令掛載檔案系統,可以使用選項 -U uuid 取代裝置檔案指定要掛載的裝置:
mount -U 51f7e9a4-5154-4e29-a7a6-208417290b85 /mnt
亦可以使用 UUID=uuid 取代 -U 選項:
mount UUID="51f7e9a4-5154-4e29-a7a6-208417290b85" /mnt
在 /etc/fstab 中使用 LABEL 或 UUID
在檔案 /etc/fstab 可以使用 UUID=uuid 取代裝置檔案指定要掛載的裝置: :
UUID="e61f4197-5f00-4f4f-917c-290922a85339" / ext3 defaults 0 1 UUID="51f7e9a4-5154-4e29-a7a6-208417290b85" /boot ext3 defaults 0 2
相關頁面
相關連結
- Gite, Vivek (Sep 27, 2008). “How To Use UUID To Mount Partitions / Volumes Under Ubuntu Linux”. NixCraft.
- Kemp, Juliet (Dec 15, 2008). “Using UUID to Deal With Disks”. ServerWatch.
- Pendell, David (Sep 11, 2008). “What UUIDs can do for you”. Linux.com.
- Mike (Aug 20, 2008).“ How To Manage Your Disk By UUID On Linux”. The Linux and Unix Menagerie.
- Ubuntu Community. “UsingUUID”. Community Ubuntu Documentation.
- e2fsprogs (Mar 2008).“blkid(8)”. Linux. - GNU/Linux 中 e2fsprogs 1.40.8 的 blkid(8) 說明文件
- e2fsprogs (2008).“blkid(8)”. Ubuntu 9.04. - Ubuntu 9.04 中 e2fsprogs 1.41.3 的 blkid(8) 說明文件
- e2fsprogs (Mar 2008).“tune2fs(8)”. Linux. - GNU/Linux 中 e2fsprogs 1.40.8 的 tune2fs(8) 說明文件
- e2fsprogs (2008).“tune2fs(8)”. Ubuntu 9.04. - Ubuntu 9.04 中 e2fsprogs 1.41.3 的 tune2fs(8) 說明文件
- xfs_admin. “xfs_admin(8)”. Ubuntu 9.04. - Ubuntu 9.04 中 xfsprogs 2.9.8 的 xfs_admin(8) 說明文件
- reiserfsprogs (Feb 2004).“reiserfstune(8)”. Linux. - GNU/Linux 中 reiserfsprogs 3.6.19 的 reiserfstune(8) 說明文件
- reiserfsprogs (Feb 2004).“reiserfstune(8)”. Ubuntu 9.04. - Ubuntu 9.04 中 reiserfsprogs 3.6.19 的 reiserfstune(8) 說明文件
- Arndt, Barry (Oct 28, 2002).“jfs_tune(8)”. Linux. - GNU/Linux 中 jfsutils 的 jfs_tune(8) 說明文件
- Arndt, Barry (Oct 28, 2002).“jfs_tune(8)”. Ubuntu 9.04. - Ubuntu 9.04 中 jfsutils 1.1.12 的 jfs_tune(8) 說明文件
- Linux (Dec 16, 2008).“mount(8)”. Linux. - GNU/Linux 中的 mount(8) 說明文件
- Linux (2008).“mount(8)”. Ubuntu 9.04. - Ubuntu 9.04 中的 mount(8) 說明文件
页面分类: Filesystem | Ext2 | Ext3












