After the hard disk is partitioned, reset the hard disk table in linux.

Source: Internet
Author: User
After the hard disk is partitioned, reset the hard disk table in linux-general Linux technology-Linux technology and application information. For more information, see the following. The uuid changes after the hard disk is partitioned, causing an error in mounting the hard disk in linux.

----- What is uuid?

UUID, full name: Universally Unique Identifier

It is a 128-bit, 16-byte value and must be unique in time and space. It combines the hardware address, time, and random number to ensure its uniqueness. Generally, the generation algorithm is generated using the IP address of the computer Nic and a 60-bit timestamp. The time interval is 100ns. For example, for a 6862 PL computer, the MAC address of the NIC integrated with the motherboard is 00-04-AC-2E-B7-DC, And the last six bytes of the UUID will be 0004AC2EB7DC.

The uuid changes after the hard disk partition is adjusted.

----- Check the uuid ls-l/dev/disk/by-uuid corresponding to each partition
----- Modify the uuid Allocation Table sudo vi/etc/fstab in linux

Ubuntu now uses the UUID value to represent hard disk partitions by default. in/etc/fstab, we can easily see:

#/Etc/fstab: static file system information.
#
#
Proc/proc defaults 0 0
#/Dev/hda1
UUID = 6286feb3-3037-4893-b0f1-8c9edba3c447/ext3 defaults, errors = remount-ro 0 1
#/Dev/hda5
UUID = 45bdb727-57db-46c2-8b33-e2dc813c0e18/media/mydoc ext3 defaults 0 2
#/Dev/hda7
UUID = 1bfc17a2-b39c-451b-8ce8-2b3bc13bf6e8 none swap sw 0 0
/Dev/hdd/media/cdrom0 udf, iso9660 user, noauto 0 0 0
/Dev // media/floppy0 auto rw, user, noauto 0 0

This representation is also available in the GRUB startup Item.
Kernel/boot/vmlinuz-2.6.20-14-generic root = UUID = 6286feb3-3037-4893-b0f1-8c9edba3c447 ro
Quiet splash locale = zh_CN

Compared with the previous use of hda *, the advantage of using UUID is that as long as the partition size is not adjusted, its UUID value is fixed, that is, even if all other partitions are deleted, does not affect the mounting of this partition.

So what if the partition changes? Sometimes you need to adjust the partition size so that its UUID value changes. In this case, you need to change the UUID value of the partition to the current value in/etc/fstab; otherwise, the partition cannot be automatically mounted.

To query the UUID value of a partition, run the following command:
Ls-al/dev/disk/by-uuid

The result is as follows:

Total usage 0

Drwxr-xr-x 2 root 100.
Drwxr-xr-x 5 root 100 ..
Lrwxrwxrwx 1 root 10 2007-04-06 20:09 1bfc17a2-b39c-451b-8ce8-2b3bc13bf6e8->.../sda6
Lrwxrwxrwx 1 root 10 2007-04-06 20:09 6286feb3-3037-4893-b0f1-8c9edba3c447->.../sda1
Lrwxrwxrwx 1 root 10 2007-04-06 20:09 8c6640b5-9c65-44d7-8f09-771b8c589922->.../sda5

This is the UUID of my hard disk partition. It can be seen that after sda5 is adjusted, the UUID changes and the corresponding part of fstab is deleted. OK

----- Parameters of Various Hard Disk formats are as follows:

# Ext3
# Entry for/dev/sda3:
UUID = b5105255-3d75-46bf-8836-ca69f3ae6ee6/ext3 defaults, errors = remount-ro 0 1

# Ntfs
# Entry for/dev/sda1:
UUID = 2290D8F490D8D001/media/sda1 ntfs-3g ults, locale = zh_CN.UTF-8 0 1

# Fat 32
# Entry for/dev/sda6:
UUID = 471E-29DD/media/sda6 vfat defaults, utf8, umask = 007, gid = 46 0 1

# Swap
# Entry for/dev/sda8:
# UUID = d2b82509b450eda3 none swap sw 0 0
Related Article

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.