Partition size adjustment Manual

Source: Internet
Author: User
Partition size adjustment manual-general Linux technology-Linux technology and application information. For more information, see the following. [I = s] This post was last edited by Liu Chong at, September 8 ,.

Summary

This document uses an example to describe the complete process of adjusting the partition size. (16:59:41)

Environment

A 60 GB hard disk is installed on the server, which is divided into/,/home,/chroot, And/swap. The detailed partition information is shown below:

Command (m for help): p

Disk/dev/hda: 61.4 GB, 61492838400 bytes

255 heads, 63 sectors/track, 7476 cylinders

Units = cylinders of 16065*512 = 8225280 bytes

Device Boot Start End Blocks Id System

/Dev/hda1*1 915 7349706 83 Linux

/Dev/hda2 916 1414 4008217 + 83 Linux

/Dev/hda3 1415 7476 48693015 5 Extended

/Dev/hda5 1415 1477 506016 82 Linux swap

/Dev/hda6 1478 7476 48186936 83 Linux

Now, we want to split up about 4 GB space from the/home partition to install FreeBSD.

Process

First, we need to adjust the size of the file system (note that the file system is not the partition size), then check the adjusted file system, and then further adjust the partition size.

This article uses my own system as an example. You can adjust the system based on your actual operation.

Those who are used to the traditional hard drive tool may think that the file system and the hard disk partition are unified, in fact, they are not a complete whole (that is why BSD can create multiple file system partitions in a hard disk partition ). Imagine a bookcase with a mobile shelf. You can adjust the location of books in the bookcase through a mobile bookshelf. Using books as a file system, you can fill the cupboard with books, or adjust the space of the bookcase through mobile bookshelves. Of course, you can also adjust the storage location of books in the bookcase through the bookshelf. As shown in:

| <-- Hda1 ------ >|< -- hda2 ------> |

+ --------------- +

| XXXXXXXXXXXXXXX | XXXXXXXXXX |

| XXXXXXXXXXXXXXX | XXXXXXXXXX |

+ --------------- +

The file system in hard disk partition/dev/hda1 occupies the entire partition, while the file system in/dev/hda2 only occupies about 2/3 of the partitions.

The basic principle is as follows. Now Let's adjust the file system size in/dev/hda6:

[Root @ ringmail root] # umount/home

[Root @ ringmail root] # resize_reiserfs-s 43000 M/dev/hda6

<------------- Resize_reiserfs, 2002 ------------->

Reiserfsprogs 3.6.4

You are running BETA version of reiserfs shrinker.

This version is only for testing or very careful use.

Backup of you data is recommended.

Do you want to continue? [Y/N]: y

Processing the tree: 0%

... 20%... 40%... 60%... 80%... 100% left 0, 301020/sec

Nodes processed (moved ):

Int 56 (0 ),

Leave 8124 (0 ),

Unfm 6313240 (0 ),

Total 6321420 (0 ).

Check for used blocks in truncated region

ReiserFS report:

Blocsize 4096

Block count 11008000 (12046734)

Free blocks 4678034 (5716736)

Bitmap block count 336 (368)

Syncing... done

Because the original size of/home is 47057, and we want to divide 4 GB space in/home, the target size of the integer/home is 43000. Therefore, when resize_reiserfs is used, the-s size is 43000 M.

In this way, we have completed the file system size adjustment. Let's calculate the size of the target partition according to the Units value in your fdisk, because hard disk partitions are all divided by the cylinder, the basic calculation method is: 43000*1024*1024/8225280 = 5481.7304699657640834111422346716, then we take the nearest value 5482 + 1478 = 6960 as the column number of the end of the partition. Here, 1478 is the cylinder number at the beginning of the/home partition, which can be seen in the fdisk in the front.

After adjusting the file system size, run the following command to perform a comprehensive check on the file system:

[Root @ ringmail root] # reiserfsck -- check -- fix-fixable/dev/hda6

Now we have completed the file system size adjustment, but the size of the hard disk partition is still not adjusted, it is as big as before (we can imagine that we have taken a few books from the cupboard, the size of the bookshelf is not adjusted, and it still occupies the original space ).

Now we need to start the most dangerous operation in the entire operation: If there is no need, it is best not to proceed:-D, but don't worry too much, just follow the steps below.

Start fdisk and follow these steps:

[Root @ ringmail root] # fdisk/dev/hda

The number of cylinders for this disk is set to 7476.

There is nothing wrong with that, but this is larger than 1024,

And coshould in certain setups cause problems:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

(E.g., dos fdisk, OS/2 FDISK)

Command (m for help): p

Disk/dev/hda: 61.4 GB, 61492838400 bytes

255 heads, 63 sectors/track, 7476 cylinders

Units = cylinders of 16065*512 = 8225280 bytes

Device Boot Start End Blocks Id System

/Dev/hda1*1 915 7349706 83 Linux

/Dev/hda2 916 1414 4008217 + 83 Linux

/Dev/hda3 1415 7476 48693015 5 Extended

/Dev/hda5 1415 1477 506016 82 Linux swap

/Dev/hda6 1478 7476 48186936 83 Linux

Command (m for help): d

Partition number (1-6): 6

Command (m for help): n

Command action

L logical (5 or over)

P primary partition (1-4)

L

First cylinder (1478-7476, default 1478): 1478

Last cylinder or + size or + sizeM or + sizeK (1478-7476, default 7476): 6960

Command (m for help): p

Disk/dev/hda: 61.4 GB, 61492838400 bytes

255 heads, 63 sectors/track, 7476 cylinders

Units = cylinders of 16065*512 = 8225280 bytes

Device Boot Start End Blocks Id System

/Dev/hda1*1 915 7349706 83 Linux

/Dev/hda2 916 1414 4008217 + 83 Linux

/Dev/hda3 1415 7476 48693015 5 Extended

/Dev/hda5 1415 1477 506016 82 Linux swap

/Dev/hda6 1478 6960 44042166 83 Linux

Command (m for help): w

The partition table has been altered!

Calling ioctl () to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource

Busy.

The kernel still uses the old table.

The new table will be used at the next reboot.

Syncing disks.

It should be noted that, because the kernel still uses the old partition table, I need to restart to refresh the partition information just created. So after the partition re-partitioning operation, I have restarted the system. After the system is restarted, continue the subsequent operation.

Through the above steps, we have completed the hard disk partition size adjustment operation, and then back to the problem of re-adjusting the file system size. Since hard disk partitions are planned according to the cylinder, it is difficult to adjust the file system size in one step in the resize_reiserfs step to be exactly the same as the hard disk partition size. Therefore, hard disk partitioning is generally a little bigger than the file system, and then you can use the following command to synchronize (of course, if you do not care about the space in the hard disk partition, you can ignore the following steps ):

[Root @ ringmail root] # umount/home/

[Root @ ringmail root] # resize_reiserfs/dev/hda6

<------------- Resize_reiserfs, 2002 ------------->

Reiserfsprogs 3.6.4

ReiserFS report:

Blocsize 4096

Block count 11010541 (11008000)

Free blocks 4680574 (4678034)

Bitmap block count 337 (336)

Syncing... done

After the operation is completed, the size adjustment of the original partition is completed. Next, you need to create a new partition:

[Root @ ringmail root] # fdisk/dev/hda

The number of cylinders for this disk is set to 7476.

There is nothing wrong with that, but this is larger than 1024,

And coshould in certain setups cause problems:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

(E.g., dos fdisk, OS/2 FDISK)

Command (m for help): p

Disk/dev/hda: 61.4 GB, 61492838400 bytes

255 heads, 63 sectors/track, 7476 cylinders

Units = cylinders of 16065*512 = 8225280 bytes

Device Boot Start End Blocks Id System

/Dev/hda1*1 915 7349706 83 Linux

/Dev/hda2 916 1414 4008217 + 83 Linux

/Dev/hda3 1415 7476 48693015 5 Extended

/Dev/hda5 1415 1477 506016 82 Linux swap

/Dev/hda6 1478 6960 44042166 83 Linux

Command (m for help): n

Command action

L logical (5 or over)

P primary partition (1-4)

L

First cylinder (6961-7476, default 6961 ):

Using default value 6961

Last cylinder or + size or + sizeM or + sizeK (6961-7476, default 7476 ):

Using default value 7476

Command (m for help): t

Partition number (1-7): 7

Hex code (type L to list codes): a5

Changed system type of partition 7 to a5 (FreeBSD)

Command (m for help): p

Disk/dev/hda: 61.4 GB, 61492838400 bytes

255 heads, 63 sectors/track, 7476 cylinders

Units = cylinders of 16065*512 = 8225280 bytes

Device Boot Start End Blocks Id System

/Dev/hda1*1 915 7349706 83 Linux

/Dev/hda2 916 1414 4008217 + 83 Linux

/Dev/hda3 1415 7476 48693015 5 Extended

/Dev/hda5 1415 1477 506016 82 Linux swap

/Dev/hda6 1478 6960 44042166 83 Linux

/Dev/hda7 6961 7476 4144738 + a5 FreeBSD

Command (m for help): w

The partition table has been altered!

Calling ioctl () to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource

Busy.

The kernel still uses the old table.

The new table will be used at the next reboot.

Syncing disks.

So far, the entire operation to adjust the partition size and create a new partition is complete.

Blockdev -- rereadpt/dev/hda

Kernel can re-read the partitions table.

Hdparm-z

Is also okay, and easier to remember

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.