Reprint: http://www.linuxidc.com/Linux/2010-06/26689.htm
In the process of using Linux, with the installation of software and the expansion of data, it is sometimes found that the partitioning of the Linux partition needs to be adjusted. If you use the partition command Fdisk to resize the partition, it often means that the partition data is lost. LVM technology can avoid partition data loss, but there are many restrictions in use. This article describes a method for partitioning Linux partitions using GParted, which is more suitable for hard disk partition adjustments in personal computers and also avoids data loss.
GParted is a free, open source Linux partition software with a graphical user interface.
In Ubuntu, you can use the following command to install:
sudo apt-get install gparted
Note that in Ubuntu, GParted does not support NTFS partitioning by default, and you must also install ntfsprogs with the following instructions:
sudo apt-get install Ntfsprogs
You can then start gparted with the following command:
sudo gparted
This article focuses on expanding or merging partitions using the GParted tool under Ubuntu. A situation that is not sufficient for a particular partition. It's no big problem to shrink a partition.
Partitioning is the first step in installing an operating system, but before the operating system, it is difficult to know which partitions require much space, and even if you get some reminders and reference numbers from others, there are often discrepancies for your specific situation. Some partitions are larger than needed, and there is not much problem, as long as your hard drive is sufficient. But if some partitions run out, not enough, trouble!
This time, you have to adjust the size of the partition. There are many ways. Some directly remove the system, repartition, and then reinstall the operating system, simply, trouble by tiring, and require a large number of backup or no important things to back up, some of the large partition to carve out a piece of free space, the small space is also deleted, the free partition and together, and then re-establish the partition, In Linux also to modify the Fstab file, not only to beware of data loss also need to know clearly how fstab, so you have a certain level of Linux, of course, there are logical volume method. In short, whatever method you take, make the necessary backups to ensure foolproof.
I already have a free space on my disk and need to merge this free partition into that smaller partition. To the online check, mainly two methods, is the logical volume, as well as the deletion of partition reconstruction partition and then modify the method of Fstab, I think since there is a special tool, how can it be so troublesome?! If so, the value of the tool gparted exists is questionable.
I think a lot of people are doing this because they don't have a good understanding of gparted usage.
The first thing to note is that the operation of a partition in GParted can only affect the two neighboring partitions, and only the neighboring two partitions can affect the partition.
That is, if a partition is drawn out of a small block and becomes an idle area, then the idle area will be generated and will definitely be adjacent to the partition. Naturally, if a partition is to be enlarged, it is necessary to ensure that the upper and lower two areas of the partition have a space, unallocated. Only in this way can the partition be scaled! In GParted, a partition needs to be enlarged, and the size of the pre-and post-free area required is at least 0.
The idle area and small partition on my disk are not adjacent. So we need to move the space area near the small partition. See Figure 1 in the following detail. If you move the partition, as far as I know, only the "passing" zoning can be adjusted. (Note that resizing is not the size of these passing partitions, but the size of the idle areas before and after them, as shown in Figure 2). For example, to move the "unallocated" to/dev/sda9 above, you need to go through/dev/sda6,/DEV/SDA7,/dev/sda8 these three to pass the partition. You need to adjust the size of the front and rear idle areas of these partitions separately.
For/dev/sda6, when selected, click the button "Resize/move", the dialog box in Figure 2 appears, there are three edit boxes, respectively: Free space preceding, New Size, free space Following. What we're going to do is adjust the first and third values. In Figure 1 and Figure 2, you can see that the "unallocated" size is 11.37GB (11641MB), it is on top of the/dev/sda6, and there is no other idle area behind/dev/sda6, so in the Resize/move dialog box, the free Space preceding is 11641MB, while free space following is 0MB.
In order to move the idle area down, move to the/dev/sda6 (closer to/DEV/SDA9), as long as the/dev/sda6 free space preceding set to 0, and free space following set to the size of the idle area. Of course, if you're not going to move your entire idle, this value can be set to the smaller value you need. If you need to move the whole, there is a trick is to only set the free space preceding 0, the system will automatically set the free space following to the desired value (the size of the entire idle area), of course, to see the results in real time, Just reposition the mouse (click Elsewhere, for example in the free Space following input box). Set the situation as shown in Figure 3. Then click on the "Resize/move" button in the dialog box to see the effect of Figure 4. Click "Apply", the partition position adjustment began processing, the implementation of Figure 4 settings. (Of course, you can set all the operation and the final effect, and then apply)
In this way, one step at a time to/dev/sda7,/dev/sda8 do the same treatment, you can move the idle area to the/dev/sda9 of the tight top. Again to the/dev/sda9 "Resize/move", you will find that the size of the partition before and after the idle area is not all 0, the front of the idle area is already 11641MB, so that the/dev/sda9 can be expanded.
One problem to note is that if the swap partition is involved in the adjustment, it needs to be disabled first. However, after the adjustment, it was found that the swap did not mount after reboot, causing the system to be slow and required to activate swap. Take a closer look. The UUID of the swap partition has changed and needs to be changed in Fstab. I think this is the imperfection of gparted.
View the uuid:ls-l of a partition/dev/disk/by-uuid
Condition of list partition: DF-LH
Figure 1. My disk partition situation, need to be "unallocated" in the 1G into the partition/dev/sda9.
Figure 2. In GParted, each partition has three properties that can be adjusted.
Figure 3. Move the idle area below. ( you can simply drag the left and right arrows in the dialog box to resize the partition )
Figure 4. Sets the adjustment effect for the location of the partition.
Ubuntu Merging partitions with GParted