Disk device files in Linux (sda, sdb, sdc ....) Change Problems

Source: Internet
Author: User
Article Title: Linux disk device files (sda, sdb, sdc ....) Change issues. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

In Linux, this problem often occurs. In some cases, the disk device files, such as/dev/sda, sdb, and sdc, are messy, for example, if sda is changed to sdb or sdc to sdb, this will inevitably lead to confusion in disk device management, and the most common problems such as Linux file system startup. Many people are looking for disk and array manufacturers when encountering such problems. They suspect that this is their problem. In fact, this underlying disk (single disk or RAID array) the ing with disk device files in Linux is not determined by the disk and array manufacturers, but by the Linux kernel itself.

Currently, the ing between Linux kernel and such disk devices depends on three sequence: loading the disk driver, monitoring the host PCI slot, and monitoring the disk itself, first, of course, a, and so on. Therefore, in special circumstances such as hot swapping of some devices and restarting, the device files mapped to the actual disk in Linux may be changed due to such queuing reasons, however, this underlying "secretly" change sometimes causes administrators to make some low-level mistakes.

This is the limitation of Linux Kernel, so there is no way to overcome it. However, there are two "Roundabout tactics" to reduce possible problems, one is the unique identification method of the UUID device, and the other is the Label identification method for the device volume.

1. UUID (globally unique identifier), the unique identification, is mapped to disk devices using Page 83 Information of the SCSI Inquiry command. For example, we can query the uuid id code of some disk devices in Linux.

Bash # ls-la/dev/disk/by-id
Total 0
Drwxr-xr-x 2 root 280 Mar 11.
Drwxr-xr-x 5 root 100 Mar 11 ..
Lrwxrwxrwx 1 root 9 Mar 11 edd-int13_dev80->.../sda
Lrwxrwxrwx 1 root 10 Mar 11 edd-int13_dev80-part1->.../sda1
Lrwxrwxrwx 1 root 10 Mar 11 edd-int13_dev80-part3->.../sda3
Lrwxrwxrwx 1 root 10 Mar 11 edd-int13_dev80-part4->.../sda4
Lrwxrwxrwx 1 root 10 Mar 11 edd-int13_dev80-part5->.../sda5
Lrwxrwxrwx 1 root 10 Mar 11 edd-int13_dev80-part6->.../sda6
Lrwxrwxrwx 1 root 9 Mar 11 :28 scsi-3600050e03d7c67007bf400009f890000-
> ../Sda
Lrwxrwxrwx 1 root 10 Mar 11 scsi-3600050e03d7c67007bf400009f890000-p
Art1-> ../sda1
Lrwxrwxrwx 1 root 10 Mar 11 scsi-3600050e03d7c67007bf400009f890000-p
Art3-> ../sda3
Lrwxrwxrwx 1 root 10 Mar 11 scsi-3600050e03d7c67007bf400009f890000-p
Art4-> ../sda4
Lrwxrwxrwx 1 root 10 Mar 11 scsi-3600050e03d7c67007bf400009f890000-p
Art5-> ../sda5
Lrwxrwxrwx 1 root 10 Mar 11 scsi-3600050e03d7c67007bf400009f890000-p
Art6-> ../sda6

After finding the unique UUID code of the disk device, you can add it to/etc/grub. in conf and/etc/fstab, even if the initial system disk sda is changed to sdb, the startup and loading of Linux and file systems are based on UUID, so the upper layer will not be affected, for example,

Make the following changes in the/etc/grub. conf system startup Portal:

Kernel/boot/vmlinuz-2.6.27.7 root =/dev/disk/by-id/scsi-3600050e03d7c67007bf400009f890000-part1

Make the following changes in the/etc/fstab file system startup Portal:

/Dev/disk/by-id/scsi-3600050e03d7c67007bf400009f890000-part1/ext3 1 1
/Dev/disk/by-id/scsi-234892819987c8f828473829becf38289-part2/home ext3 1 1

2. The second is an old-fashioned solution, that is, to set the Label for the disk volume. In the same way, when the system starts, it only looks at the Label, it does not affect the startup of the system or file system because it does not look at the underlying sda/sdb and other device numbers. For example,

Use the e2label command to set labels for sda1 and sdb1:

/Sbin/e2label/dev/sda1 myroot
/Sbin/e2label/dev/sdb1 myhome

Then, make the following changes in the/etc/grub. conf system startup Portal:

Kernel/boot/vmlinuz-2.6.29 ro root = LABEL = myroot

Make the following changes in the/etc/fstab file system startup Portal:

LABEL = myroot/ext3 defaults 1 1
LABEL = myhome/home ext3 defaults 1 1

Of course, the above two methods are used to avoid affecting the startup of the system and the file system. In actual system management, pay close attention to the changes of the underlying device, otherwise, if a disk partition is accidentally deleted, it would be too much.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.