特殊:Badtitle/NS100:UsingUUID:修订间差异
小无编辑摘要 |
小无编辑摘要 |
||
(未显示同一用户的1个中间版本) | |||
第15行: | 第15行: | ||
sudo vol_id -u /dev/sda2 | sudo vol_id -u /dev/sda2 | ||
</nowiki></pre> | </nowiki></pre> | ||
Note: The utility vol_id doesn't exist in Karmic. | |||
(for an ext3 filesystem) produces an output similar to: | (for an ext3 filesystem) produces an output similar to: | ||
<pre><nowiki> | <pre><nowiki> | ||
第28行: | 第29行: | ||
/dev/sda5: TYPE="swap" UUID="8c4e69f8-5074-42c0-8134-0b2429c4c02c" | /dev/sda5: TYPE="swap" UUID="8c4e69f8-5074-42c0-8134-0b2429c4c02c" | ||
/dev/sdb1: SEC_TYPE="msdos" UUID="4848-E35A" TYPE="vfat" </nowiki></pre> | /dev/sdb1: SEC_TYPE="msdos" UUID="4848-E35A" TYPE="vfat" </nowiki></pre> | ||
Alternatively you can list them from | Alternatively you can list them from their listing in your root filesystem: | ||
<pre><nowiki> | <pre><nowiki> | ||
ls -l /dev/disk/by-uuid/ | ls -l /dev/disk/by-uuid/ | ||
第40行: | 第41行: | ||
lrwxrwxrwx 1 root root 10 2008-06-04 03:10 8c4e69f8-5074-42c0-8134-0b2429c4c02c -> ../../sda5</nowiki></pre> | lrwxrwxrwx 1 root root 10 2008-06-04 03:10 8c4e69f8-5074-42c0-8134-0b2429c4c02c -> ../../sda5</nowiki></pre> | ||
== Converting to UUIDs == | == Converting to UUIDs == | ||
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=info.png https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconNote.png If you are using Ubuntu 6.06 [[UbuntuHelp:DapperDrake| Dapper Drake]] LTS, you can use these commands to "upgrade" to UUIDs. '''All other supported versions of Ubuntu automatically use UUIDs, so this is not necessary.''' You may be interested in having a | https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=info.png https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconNote.png If you are using Ubuntu 6.06 [[UbuntuHelp:DapperDrake| Dapper Drake]] LTS, you can use these commands to "upgrade" to UUIDs. '''All other supported versions of Ubuntu automatically use UUIDs, so this is not necessary.''' You may be interested in having a look, anyway. | ||
=== Fstab === | === Fstab === | ||
For <code><nowiki>/etc/fstab</nowiki></code>: | For <code><nowiki>/etc/fstab</nowiki></code>: | ||
第113行: | 第114行: | ||
* [[UbuntuHelp:RenameUSBDrive|RenameUSBDrive]] - help with adding LABELs to partitions | * [[UbuntuHelp:RenameUSBDrive|RenameUSBDrive]] - help with adding LABELs to partitions | ||
* [[UbuntuHelp:LinuxFilesystemsExplained|LinuxFilesystemsExplained]] | * [[UbuntuHelp:LinuxFilesystemsExplained|LinuxFilesystemsExplained]] | ||
* [http://ubuntu.wordpress.com/2006/03/01/editing-fat32-partition-labels-using-mtools/ Editing FAT32 Partition Labels using mtools]. | * [http://ubuntu.wordpress.com/2006/03/01/editing-fat32-partition-labels-using-mtools/ Editing FAT32 Partition Labels using mtools]. | ||
[[category:UbuntuHelp]] | [[category:UbuntuHelp]] |
2010年5月20日 (四) 00:44的最新版本
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/UsingUUID }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/af | • {{#if: UbuntuHelp:UsingUUID|Afrikaans| [[::UsingUUID/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/ar | • {{#if: UbuntuHelp:UsingUUID|العربية| [[::UsingUUID/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/az | • {{#if: UbuntuHelp:UsingUUID|azərbaycanca| [[::UsingUUID/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/bcc | • {{#if: UbuntuHelp:UsingUUID|جهلسری بلوچی| [[::UsingUUID/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/bg | • {{#if: UbuntuHelp:UsingUUID|български| [[::UsingUUID/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/br | • {{#if: UbuntuHelp:UsingUUID|brezhoneg| [[::UsingUUID/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/ca | • {{#if: UbuntuHelp:UsingUUID|català| [[::UsingUUID/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/cs | • {{#if: UbuntuHelp:UsingUUID|čeština| [[::UsingUUID/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/de | • {{#if: UbuntuHelp:UsingUUID|Deutsch| [[::UsingUUID/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/el | • {{#if: UbuntuHelp:UsingUUID|Ελληνικά| [[::UsingUUID/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/es | • {{#if: UbuntuHelp:UsingUUID|español| [[::UsingUUID/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/fa | • {{#if: UbuntuHelp:UsingUUID|فارسی| [[::UsingUUID/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/fi | • {{#if: UbuntuHelp:UsingUUID|suomi| [[::UsingUUID/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/fr | • {{#if: UbuntuHelp:UsingUUID|français| [[::UsingUUID/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/gu | • {{#if: UbuntuHelp:UsingUUID|ગુજરાતી| [[::UsingUUID/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/he | • {{#if: UbuntuHelp:UsingUUID|עברית| [[::UsingUUID/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/hu | • {{#if: UbuntuHelp:UsingUUID|magyar| [[::UsingUUID/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/id | • {{#if: UbuntuHelp:UsingUUID|Bahasa Indonesia| [[::UsingUUID/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/it | • {{#if: UbuntuHelp:UsingUUID|italiano| [[::UsingUUID/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/ja | • {{#if: UbuntuHelp:UsingUUID|日本語| [[::UsingUUID/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/ko | • {{#if: UbuntuHelp:UsingUUID|한국어| [[::UsingUUID/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/ksh | • {{#if: UbuntuHelp:UsingUUID|Ripoarisch| [[::UsingUUID/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/mr | • {{#if: UbuntuHelp:UsingUUID|मराठी| [[::UsingUUID/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/ms | • {{#if: UbuntuHelp:UsingUUID|Bahasa Melayu| [[::UsingUUID/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/nl | • {{#if: UbuntuHelp:UsingUUID|Nederlands| [[::UsingUUID/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/no | • {{#if: UbuntuHelp:UsingUUID|norsk| [[::UsingUUID/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/oc | • {{#if: UbuntuHelp:UsingUUID|occitan| [[::UsingUUID/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/pl | • {{#if: UbuntuHelp:UsingUUID|polski| [[::UsingUUID/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/pt | • {{#if: UbuntuHelp:UsingUUID|português| [[::UsingUUID/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/ro | • {{#if: UbuntuHelp:UsingUUID|română| [[::UsingUUID/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/ru | • {{#if: UbuntuHelp:UsingUUID|русский| [[::UsingUUID/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/si | • {{#if: UbuntuHelp:UsingUUID|සිංහල| [[::UsingUUID/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/sq | • {{#if: UbuntuHelp:UsingUUID|shqip| [[::UsingUUID/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/sr | • {{#if: UbuntuHelp:UsingUUID|српски / srpski| [[::UsingUUID/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/sv | • {{#if: UbuntuHelp:UsingUUID|svenska| [[::UsingUUID/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/th | • {{#if: UbuntuHelp:UsingUUID|ไทย| [[::UsingUUID/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/tr | • {{#if: UbuntuHelp:UsingUUID|Türkçe| [[::UsingUUID/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/vi | • {{#if: UbuntuHelp:UsingUUID|Tiếng Việt| [[::UsingUUID/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/yue | • {{#if: UbuntuHelp:UsingUUID|粵語| [[::UsingUUID/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/zh | • {{#if: UbuntuHelp:UsingUUID|中文| [[::UsingUUID/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/zh-hans | • {{#if: UbuntuHelp:UsingUUID|中文(简体)| [[::UsingUUID/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UsingUUID | UbuntuHelp:UsingUUID | {{#if: | :}}UsingUUID}}/zh-hant | • {{#if: UbuntuHelp:UsingUUID|中文(繁體)| [[::UsingUUID/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:UsingUUID|:UsingUUID|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :UsingUUID/zh | | {{#ifexist: UsingUUID/zh | | {{#ifeq: {{#titleparts:UsingUUID|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:UsingUUID|1|-1|}} | zh | | }}
Linux now prefers to use UUID (Universally Unique Identifier), LABEL, or symlinks to identify media storage devices on a system. Directly using /dev/hd*#
or /dev/sd*#
is no longer preferred since these device assignments can change between system boots:
- all filesystems should be specified by
UUID=<id>
orLABEL=<name>
for each partition. - all physical devices should be specified by a symlink, like
/dev/cdrom
for a cd drive and/dev/disk/by-id/...
for each physical hard drive.
The files for which UUID is most critical:
/boot/grub/menu.lst
/etc/fstab
/etc/initramfs-tools/conf.d/resume
This page uses the terminal a lot, so if you are new to this, see UsingTheTerminal.
Finding UUIDs
UUIDs can be determined using the vol_id
or blkid
commands. The first command is used on individual partitions, the second command lists for all attached devices (mounted or not).
Here are examples (your output will be different, but similarly formatted). The command:
sudo vol_id -u /dev/sda2
Note: The utility vol_id doesn't exist in Karmic. (for an ext3 filesystem) produces an output similar to:
30fcb748-ad1e-4228-af2f-951e8e7b56df
and the command:
sudo blkid
produces an output similar to:
/dev/sda1: TYPE="ntfs" UUID="72C0DE8EC0DE57C5" LABEL="windows" /dev/sda2: UUID="30fcb748-ad1e-4228-af2f-951e8e7b56df" SEC_TYPE="ext2" TYPE="ext3" /dev/sda5: TYPE="swap" UUID="8c4e69f8-5074-42c0-8134-0b2429c4c02c" /dev/sdb1: SEC_TYPE="msdos" UUID="4848-E35A" TYPE="vfat"
Alternatively you can list them from their listing in your root filesystem:
ls -l /dev/disk/by-uuid/
produces an output similar to:
total 0 lrwxrwxrwx 1 root root 10 2008-06-04 03:10 30fcb748-ad1e-4228-af2f- 951e8e7b56df -> ../../sda2 lrwxrwxrwx 1 root root 10 2008-06-07 16:51 4848-E35A -> ../../sdb1 lrwxrwxrwx 1 root root 10 2008-06-04 03:10 72C0DE8EC0DE57C5 -> ../../sda1 lrwxrwxrwx 1 root root 10 2008-06-04 03:10 8c4e69f8-5074-42c0-8134-0b2429c4c02c -> ../../sda5
Converting to UUIDs
If you are using Ubuntu 6.06 Dapper Drake LTS, you can use these commands to "upgrade" to UUIDs. All other supported versions of Ubuntu automatically use UUIDs, so this is not necessary. You may be interested in having a look, anyway.
Fstab
For /etc/fstab
:
sudo rm /etc/fstab.pre-uuid sudo /var/lib/dpkg/info/volumeid.postinst configure
Grub
For /boot/grub/menu.lst
:
sudo update-grub
Resuming from Hibernation
For /etc/initramfs-tools/conf.d/resume
, there is no automatic procedure. You must manually verify that RESUME=UUID=<some_UUID>
where <some_UUID>
matches the UUID for the swap
line in your /etc/fstab
file.
First check the contents of the files:
cat /etc/initramfs-tools/conf.d/resume cat /etc/fstab | grep swap
If the UUIDs do not match or do not exist in the resume
file, open it for editing one of the following:
gksudo gedit /etc/initramfs-tools/conf.d/resume sudo nano -Bw /etc/initramfs-tools/conf.d/resume
Now add the correct UUID to the resume
file in the format
RESUME=UUID=<swap_UUID>
Save and close. After any adjustment, run:
sudo update-initramfs -u
Using LABEL
Labels can be very useful for external media, like flash drives and USB hard drives since these are generally automounted by hal
(Hardware Abstraction Layer). If a device has a label, it will be mounted at the /media/<label>
location and appear with the label on the desktop.
For help with labeling devices, see RenameUSBDrive.
Symlinks
Symlinks (symbolic links) are used to make it easier to identify a device. For example /dev/cdrom
can link to /dev/scd0
. These are normally created by udev which is the device manager program used in the Linux 2.6 kernel series. We will not cover creating your own symlinks here (may be added later).
Other examples of symlinks include /dev/floppy
to /dev/fd0
or /dev/dvd
to /dev/scd1
.
You can view the linked device on a symlink with the ls
command, like so:
ls -l /dev/cdrom
produces an output similar to:
lrwxrwxrwx 1 root root 4 2008-06-22 17:31 /dev/cdrom -> scd0
This tell us that /dev/cdrom
is a symlink to the device /dev/scd0
.
To view the physical device identifiers (like for a hard drive, not to be confused with a disk's partitions), the command:
ls -l /dev/disk/by-id/
produces an output similar to:
total 0 lrwxrwxrwx 1 root root 9 2008-06-22 10:30 ata-Hitachi_HTS541080G9AT00_MPB4PAX6H6B68G -> ../../sda lrwxrwxrwx 1 root root 10 2008-06-22 10:30 ata-Hitachi_HTS541080G9AT00_MPB4PAX6H6B68G-part1 -> ../../sda1 lrwxrwxrwx 1 root root 10 2008-06-22 10:30 ata-Hitachi_HTS541080G9AT00_MPB4PAX6H6B68G-part2 -> ../../sda2 lrwxrwxrwx 1 root root 10 2008-06-22 10:30 ata-Hitachi_HTS541080G9AT00_MPB4PAX6H6B68G-part3 -> ../../sda3 lrwxrwxrwx 1 root root 10 2008-06-22 10:30 ata-Hitachi_HTS541080G9AT00_MPB4PAX6H6B68G-part5 -> ../../sda5 lrwxrwxrwx 1 root root 9 2008-06-22 17:31 ata-LEXAR_ATA_FLASH_13523623189499090034 -> ../../sdb lrwxrwxrwx 1 root root 10 2008-06-22 17:31 ata-LEXAR_ATA_FLASH_13523623189499090034-part1 -> ../../sdb1 lrwxrwxrwx 1 root root 9 2008-06-22 10:30 scsi-1ATA_Hitachi_HTS541080G9AT00_MPB4PAX6H6B68G -> ../../sda lrwxrwxrwx 1 root root 10 2008-06-22 10:30 scsi-1ATA_Hitachi_HTS541080G9AT00_MPB4PAX6H6B68G-part1 -> ../../sda1 lrwxrwxrwx 1 root root 10 2008-06-22 10:30 scsi-1ATA_Hitachi_HTS541080G9AT00_MPB4PAX6H6B68G-part2 -> ../../sda2 lrwxrwxrwx 1 root root 10 2008-06-22 10:30 scsi-1ATA_Hitachi_HTS541080G9AT00_MPB4PAX6H6B68G-part3 -> ../../sda3 lrwxrwxrwx 1 root root 10 2008-06-22 10:30 scsi-1ATA_Hitachi_HTS541080G9AT00_MPB4PAX6H6B68G-part5 -> ../../sda5 lrwxrwxrwx 1 root root 9 2008-06-22 17:31 scsi-1ATA_LEXAR_ATA_FLASH_13523623189499090034 -> ../../sdb lrwxrwxrwx 1 root root 10 2008-06-22 17:31 scsi-1ATA_LEXAR_ATA_FLASH_13523623189499090034-part1 -> ../../sdb1
Note that each partition (called part#) identifies with their parent device - this is because they exist on that physical piece of hardware. You will also notice that the drives and partitions appear twice, the first time as ata and the second time as scsi. I am unclear as to why this is, but I believe it is related to IDE hard drives being identified to the system as SCSI drives (because of ide-scsi emulation?).
Other Resources
Here are some other useful and related pages.
- Fstab
- RenameUSBDrive - help with adding LABELs to partitions
- LinuxFilesystemsExplained
- Editing FAT32 Partition Labels using mtools.