Use the LinuxFdisk command to adjust the partition structure of the Disk

Source: Internet
Author: User
Article Title: Use the LinuxFdisk command to adjust the partition structure of the disk. Linux is a technology channel of the IT lab in China. Including desktop applications, Linux system management, kernel research, embedded systems, open source, and other basic categories. Fdisk here is not Fdisk in DOS, but Fdisk in Linux.
 
I have already divided many partitions on my hard disk, and each partition is installed with Linux of different release versions. Today I want to draw partitions from the remaining space to install Fedora Core, but it fails. I checked the structure of the partition table:
 
  
     
      Disk /dev/hda: 80.0 GB, 80025280000 bytes255 heads, 63 sectors/track, 9729 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System/dev/hda1 * 1 1275 10241406 7 HPFS/NTFS/dev/hda2 1276 6374 40957717+ 7 HPFS/NTFS/dev/hda3 6375 7139 6144862+ 83 Linux/dev/hda4 7140 8663 12241530 f Win95 Ext'd (LBA)/dev/hda5 7140 7204 522081 82 Linux swap/dev/hda6 7205 7690 3903763+ 83 Linux/dev/hda7 7691 8177 3911796 83 Linux/dev/hda8 8178 8663 3903763+ 83 Linux
     


 
From the partition structure of the hard disk, the hda5-8 has occupied all the space of the extended partition hda4, and the remaining space on the hard disk is located after hda4. So to use the last available space on the hard disk, you must add a partition on the hda partition table, and hda partition table has been all occupied (hda1-4 ), therefore, you cannot add more partitions.
 
The solution is to increase the size of hda4 so that it can occupy the remaining space on the entire hard disk, and then divide the new partition into hda4.
 
After reading the help of fdisk, it seems that there is no command to directly modify the partition size, so you can't delete the partition and recreate it. To prevent this, run # dd if =/dev/hda of =/root/mbr bs = 1 count = 512 to back up the MBR, then, put the backed up/root/mbr file in a safe place. Write down the start address and end address of each partition for future partition recovery. Use the d command to delete hda4 so that all the hda5-8 located on hda4 is deleted. Then run the n command to create a new partition, and select e to create an extended partition. the start and end addresses of the partition use the default value to fill the remaining space. Then, use the t command to change the hda4 format to W95 Ext 'd (LBA), numbered f. then based on the previously written partition start and end address information, in order to establish a hda5-8. finally, run the p command to view the partition table structure as follows:
 
  

     
      Disk /dev/hda: 80.0 GB, 80025280000 bytes255 heads, 63 sectors/track, 9729 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System/dev/hda1 * 1 1275 10241406 7 HPFS/NTFS/dev/hda2 1276 6374 40957717+ 7 HPFS/NTFS/dev/hda3 6375 7139 6144862+ 83 Linux/dev/hda4 7140 9729 20804175 f Win95 Ext'd (LBA)/dev/hda5 7140 7204 522081 82 Linux swap/dev/hda6 7205 7690 3903763+ 83 Linux/dev/hda7 7691 8177 3911796 83 Linux/dev/hda8 8178 8663 3903763+ 83 Linux
     

 
We can see that the structure of all the partitions except hda4 has not changed. In this way, 8664-9729 after hda9 can be used to partition new partitions.
 
Then, run the w command to save the file. To be safe, use the fsck. ext3 command to check the hda6-8 and ensure there is no error.
 

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.