Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

The following is a screenshot of my current partitions, shown by gparted:

current partitions

Note that the partitions on the right of /dev/sda3, without labels on them in the figure,

  • are /dev/sda6 (for /home), /dev/sda7 (for /), unallocated, and /dev/sda5 (for swap), from left to right,

  • taken together, constitute the contents of the extended partition /dev/sda4.

I would like to resize the partitions, such that some unused space from /dev/sda7 (for /) and the small unallocated space can be moved to /dev/sda3 (for /windows-d) and make it larger.

If this is possible, how can I do it?

share|improve this question
    
    
This certainly is possible though it's going to be more difficult due to needing to shift the boundaries of sda4, your extended partition container. Unless gparted has progressed in recent times, it can't resize those so you'll have to do some fairly dangerous editing of the partition table. –  neon_overload May 31 '12 at 22:48
1  
@neon_overload GParted can (safely) resize extended partitions (as well as primary partitions and logical partitions). –  Eliah Kagan May 31 '12 at 22:51
add comment

2 Answers 2

This is similar to this question, except that there, space outside of an extended partition was moved into an extended partition, and then used by a logical partition (in the extended). In this question, space inside an extended partition needs to be moved out of the extended partition, and used by a primary partition. While the situations are different, I've based this answer on my answer to that question.

First, make sure that:

  • All your documents and other important (i.e., hard to replace) files from all your partitions are backed up. Moving and resizing partitions dynamically carries with it a small risk of data loss (for example, if there is a power failure, if one of your filesystems is broken in a way GParted does not know how to detect, or if there is a bug in GParted), plus you could make a mistake and accidentally wipe something out.

  • You are running from a live CD/DVD or USB flash drive, rather than running GParted out of the installed Ubuntu system. It is unsafe (and would almost certainly not succeed) to dynamically move and resize partitions on the same physical disk as the OS you use to do it.

Provided that this is taken care of, you have to perform 4 (or 5) operations. It will definitely take a while for GParted to perform them.

  1. Shrink /dev/sda7 (/) down to whatever size you like. Remember to leave some space, because you need to have some free space on / for Ubuntu to update and install software, store non-user-specific files (including global configuration files), keep system logs, and so that applications can store data in /var and /tmp.

    • I recommend shrinking this on the left (i.e., increasing Free space preceding). However, if you are insistent on attempting to reclaim the 3 MiB of space between the end of /dev/sda7 (/) and /dev/sda5 (your swap partition), then you might as well instead shrink it on the right (increasing Free space following), then move the partition to the right. Please note that performing these two separate operations will make things take longer, and is almost certainly not worth it if your goal is to maximize available space. On the other hand, if the issue is that you're personally bugged by an ugly partition table, go ahead. ;-)

    This step creates unallocated space in the extended partition, between /dev/sda6 (/home) and /dev/sda7 (/).

  2. Move /dev/sda6 (/home) as far to the right as it will go, inside the extended partition. This moves the unallocated space to the very beginning (i.e., left side) of the extended partition.

  3. Shrink /dev/sda4 (the extended partition) on the left (increasing the Free space preceding). When I tried this to make sure it would work properly, I found that it did, but that I had to manually specify a different Free space preceding number. Once I supplied any number manually, I was then able to shrink my extended partition easily by dragging its left edge to the right (as you'd expect to be able to do from the get-go). I'm not sure if you will experience this issue, but if you do, you can use that workaround.

    This step moves the unallocated space out of the the extended partition.

  4. Expand /dev/sda3 (/windows-d) on the right as much as possible (decreasing Free space following), so that its right edge is flush with (or as close as possible to) the left edge of /dev/sda4 (the extended partition you've just shrunk down).

    This step moves eliminates the unallocated space, converting it into free space inside your /dev/sda3 Windows partition.

You must apply your changes to get GParted to perform the operations. To do this, click the green check-mark. After the operations complete, make sure your partition layout looks the way you want it, and quit GParted.

Since you have no separate /boot partition, the boot files for your Ubuntu system are located in the / partition (/dev/sda7). Since you have changed where this partition starts (i.e., the location of its left edge), and where the extended partition that contains it starts, it's likely that your Ubuntu system will not be able to boot. Fortunately, fixing this is easy, and consists of reinstalling GRUB2 (your boot loader) to your Master Boot Record.

If you want to try shutting down / restarting the live CD/DVD/USB system and booting into your Ubuntu system at this point, you can, but it's likely enough that you'll have to reinstall GRUB2 to the MBR that I recommend just doing it before rebooting. You can use any of the methods presented here.

Since you'll probably have to do this, I'll detail one method in this answer (with specifics of your system filled in). In the live CD/DVD/USB system, open a Terminal window (Ctrl+Alt+T) and run these commands:

sudo mount /dev/sda7 /mnt
sudo grub-install --boot-directory=/mnt/boot /dev/sda
sudo umount /mnt

Then reboot into the Ubuntu system installed on the hard disk, to make sure everything is working. It's also a good idea to boot into the Windows, and make sure it recognizes the NTFS partition. If Windows wants to perform a chkdsk scan and fix problems, you should let it.

share|improve this answer
add comment

You should be able to do it in steps. If it were me, I don't know if I'd tell it to do all the steps in one big operation, but that's only because I'd worry that it might take so long that I'd want to interrupt it for some reason.

You'll need to shrink the partitions in the Extended partition, moving them as far to the right as possible. Then, you want to shrink the Extended partition itself, leaving room on the left. Then, you should be able to make the primary partition sda3 bigger.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.