Resetting partition tables in Linux after hard disk partitioning

Source: Internet
Author: User
Article Title: resetting Linux partition tables after hard disk partitioning. Linux is a technology channel of the IT lab in China. Some basic categories, such as desktop applications, Linux system management, kernel research, embedded systems, and open source, may change the uuid after hard disk partitioning, resulting in an error in linux hard disk mounting.
 
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 proc defaults 0 0# /dev/hda1UUID=6286feb3-3037-4893-b0f1-8c9edba3c447 / ext3 defaults,errors=remount-ro 0 1# /dev/hda5UUID=45bdb727-57db-46c2-8b33-e2dc813c0e18 /media/mydoc ext3 defaults 0 2# /dev/hda7UUID=1bfc17a2-b39c-451b-8ce8-2b3bc13bf6e8 none swap sw 0 0/dev/hdd /media/cdrom0 udf,iso9660 user,noauto 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 root 100 2007-04-06 20:09 .drwxr-xr-x 5 root root 100 2007-04-06 20:09 ..lrwxrwxrwx 1 root root 10 2007-04-06 20:09 1bfc17a2-b39c-451b-8ce8-2b3bc13bf6e8 -> ../../sda6lrwxrwxrwx 1 root root 10 2007-04-06 20:09 6286feb3-3037-4893-b0f1-8c9edba3c447 -> ../../sda1lrwxrwxrwx 1 root root 10 2007-04-06 20:09 8c6640b5-9c65-44d7-8f09-771b8c589922 -> ../../sda5
       


 
This is the UUID of my hard disk partition. As you can see, after sda5 is adjusted, the UUID changes and the corresponding part of fstab is deleted. The hard disk format parameters 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 defaults,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=D2B82509B824EDA3 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.