1. 介质改变后设备名也改变导致挂载失败
2. 无法知道设备名
linux磁盘挂载需要区别出磁盘分区,可以通过设备名,UUID, LABLE来识别。
如何找出UUID和 LABLE
对于ext分区:
dumpe2fs ls -l /dev/disk/by-uuid/*
sudo blkid
for swap 分区
/dev/sda1: UUID="6c589089-c601-4820-b5d2-0c0e0ddcb8ad" TYPE="ext3"$ sudo mkswap /dev/sda3 mkswap: /dev/sda3: warning: don't erase bootbits sectors (dos partition table detected). Use -f to force. Setting up swapspace version 1, size = 2000088 KiB no label, UUID=04af4966-9e2b-4d6a-b0eb-a11038bee2fb $ sudo blkid
/dev/sda2: LABEL="Android-x86" UUID="1b7e6b09-a9ee-4cc5-9a26-b143fe33b437" SEC_TYPE="ext2" TYPE="ext3"
/dev/sda3: TYPE="swap" UUID="04af4966-9e2b-4d6a-b0eb-a11038bee2fb"
/dev/sda4: UUID="a7d96647-bfdf-4f3f-ae99-61485ff09c9c" TYPE="ext3"
通过uuid来更新/etc/fstab文件:
UUID=1b7e6b09-a9ee-4cc5-9a26-b143fe33b437 none swap sw 0 0 UUID=a7d96647-bfdf-4f3f-ae99-61485ff09c9c /mnt/sda4 ext3 defaults 0 0
:
A. 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. Thus, anyone can create a UUID and use it to identify something with reasonable confidence that the identifier will never be unintentionally used by anyone for anything else. Information labeled with UUIDs can therefore be later combined into a single database without needing to resolve name conflicts.