使用UUID和LABEL挂载磁盘

本文介绍了Linux磁盘挂载时遇到的设备名改变问题,以及如何通过UUID和LABEL来稳定地识别和挂载磁盘分区。讨论了在ext分区下查找UUID和LABEL的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 介质改变后设备名也改变导致挂载失败

2. 无法知道设备名


linux磁盘挂载需要区别出磁盘分区,可以通过设备名,UUID, LABLE来识别。

如何找出UUID和 LABLE

对于ext分区:

dumpe2fs
ls -l /dev/disk/by-uuid/*
sudo blkid

for swap 分区

$ 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/sda1: UUID="6c589089-c601-4820-b5d2-0c0e0ddcb8ad" TYPE="ext3" 
/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.










评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值