Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following situation:


I want to resize the ntfs partition. Specifically I want to add it 15 GB. What is the best sequence of steps to do?

The output from sudo fdisk -l /dev/sda and sudo fdisk -l /dev/sdb

enter image description here

share|improve this question
It is unclear what you are trying to do. – psusi Jan 17 '13 at 15:19
I want to add 15 GB to the ntfs partition. – Overflow012 Jan 17 '13 at 15:20
From where? You have to have 15gb free to do that. – psusi Jan 17 '13 at 15:20
From any partition. sda7 or sda5. – Overflow012 Jan 17 '13 at 15:22
And what about the part "from logical to primary"? Which of your partitions are primary and which are logical? Please post the output of a sudo fdisk -l /dev/sdX (where X is the letter of your drive - sda, sdb, etc.). – Avio Jan 17 '13 at 15:24

Make sure your backups of documents and other important files are current. You might make a mistake, or data loss could occur during dynamic partition resizing. Once that's done, boot from an Ubuntu live CD/DVD/USB, select Try Ubuntu, and run the GParted Partition Editor.

Taking space from /dev/sda7 is the easiest, as it requires a lower number of resize/move operations than taking it from /dev/sda5. This, in turn, is because your /dev/sda7 partition is closer to the beginning (left) boundary of /dev/sda2 (the extended partition container), and that boundary has to be moved.

  1. Right-click on /dev/sda7 (your Ubuntu partition, /) and click Resize/Move. Shrink it from the left--that is, increase the Free space preceding.

    Decrease it by however much you want your Windows partition to increase. Please note that you won't necessarily be able to increase your Windows partition by exactly that amount (depending on alignment issues), but it will be pretty close.

    Now there is space between /dev/sda6 and /dev/sda7.

  2. Right-click on /dev/sda6 (your linux-swap partition) and click Resize/Move. Slide it as far to the right as possible, so it is once again flush against /dev/sda7 (or as close as it can be).

    Now there is unallocated space at the very beginning of the extended partition.

  3. Right-click on /dev/sda2 (the extended partition). It's much easier to select this form the list than from the horizontal bar representing your disk. Click Resize/Move. Shrink it from the left--that is, increase the Free space preceding.

    Now there is unallocated space outside the extended partition, immediately to the right of the Windows partition.

  4. This is the moment you've been waiting for. Expand the Windows partition (/dev/sda1) to fill that space: Right-click on it, click Reize/Move, and expand it on the right--that is, decrease the Free space following.

  5. Click the check mark to apply your changes, and hope everything works out OK. When that's done, quit GParted.

You won't necessarily have to reinstall Ubuntu's GRUB2 boot loader to the Master Boot Record, but you might as well, as long as you're already booted into the live environment. (Otherwise, you might have to boot back to the live CD/DVD/USB to do it, after discovering that GRUB is not working well enough to boot Ubuntu...or to boot anything.)

Open a Terminal window (Ctrl+Alt+T) and run these commands to reinstall GRUB2 to the MBR (it's this technique, but with the correct values for your system filled in):

sudo mount /dev/sda7 /mnt    # For other folks: Replace sda7 with your / device.
sudo grub-install --root-directory=/mnt /dev/sda
sudo umount /mnt

It's theoretically possible that your Windows system will also need to be repaired, but very unlikely, because:

  • GRUB2 takes care of bootstrapping to the Windows boot loader (which is in the boot sector of its partition, not in the MBR). That's still present and fully intact.

    That's the real reason the Windows system will almost certainly be fine. Read on, if secondary factors interest you...

  • The Windows partition still begins in the same place on the disk.

  • The Windows partition was just expanded to the right, so all its files are in the same place on the disk.

  • Some Windows 7 systems have separate partitions for the boot loader (similar to, but not quite the same as, a /boot partition on some Ubuntu and other Unix-like systems). Yours does not. So there's nothing external to sda1 that matters, when it comes to whether or not the Windows system works. GRUB2 passes control to the boot loader in sda1, and from there on everything is in the same place it was before.

In the event that your Windows system did stop booting and you had to repair it, you could do it from the recovery console on a Windows install DVD/USB, including a trial DVD/USB.

But you probably don't need to resize your partitions at all.

Now that I've presented detailed instructions for resizing your partitions, I'd like to suggest an alternative.

I'm guessing you want to expand your Windows primary partition because you need to fit more into folders that are supposed to be located on that partition and not some other partition.

However, you have another NTFS partition (a logical partition, in the extended partition, to the right of Ubuntu's partitions) with plenty of free space.

So you can make NTFS junctions in your small-ish Windows partition, with their target folders in the big-ish logical NTFS partiton.

For example, a folder from inside Program Files (or even Program Files itself!) could be moved off to the bigger NTFS partition, and a junction created in its place, pointing to it on the big partition.

Or take a look at "How to create and manipulate NTFS junction points," which explains how to use the linkd and delrp commands to create and destroy junctions. Or you may prefer the junction command, which you can get here. (Windows 7 also supports another kind of symbolic link, see this article and mklink.)

NTFS directory junctions are a lot like symbolic links in ext4 and other Unix-style filesystems. But be careful! Directory junctions are parsed like directories, even in situations where *nix symlinks would be parsed like files. For example:

  • Deleting a junction, the way you'd delete a file or folder, deletes what it points to. (Or at least deletes the contents of what it points to.)
  • If a directory C:\foo contains a directory qux, which contains a junction bar pointing to D:\baz, and you recursively delete foo or qux (for example, by Shift+Deleteing the folder in Windows Explorer), D:\baz and everything contained within it gets deleted.
  • Moving C:\foo\qux to C:\ (so it will be C:\qux) moves D:\baz and everything in it from D: to C:!

NTFS junctions don't cause problems in Ubuntu. NTFS-3G, Ubuntu's NTFS filesystem driver, is compatible with them (though they're treated like Unix-style symbolic links, which means they behave a bit differently than on Windows).

For details or advice on creating and managing junctions (or other forms of symbolic links, as were added in Windows 7) within Windows, you should ask somewhere Windows is supported, such as Super User. (And, at least in my opinion, you should use Windows to make them if you decide to use them, even if it's theoretically possible to do so in Ubuntu.) But I wanted to present what may be a good alternative to resizing your partitions.

share|improve this answer


before proceeding, be prepared to have an unbootable system. Get a Knoppix, a Win7 recovery disk and someone that knows how to recover from a broken Grub2/Win7 bootloader.

Ok, here is what should be the simplest solution. Resize /dev/sda5 to be close to 165Gb. You'll end up with a free 30Gb partition at the end of the disk. There you can copy your primary NTFS partition (/dev/sda1) and resize it to fill the empty space.

When gparted has finished, hide the first partition (/dev/sda1) and update the grub2 configuration immediately (sudo update-grub).

Win7 shouldn't have problems in booting from a logical partition at the end of the disk if grub2 does it work properly. However Win7 is unpredictable by definition, so be prepared.

Good luck!

share|improve this answer
Sorry, but what do you mean by "There you can copy your primary NTFS partition"? I should reinstall Win and all copy all my files on the new partition?. Also, how can I hide the first partition?Excuse me, but I have not very clear this issue. – Overflow012 Jan 17 '13 at 15:59
No, you just have to tell gparted to copy your whole /dev/sda1 partition where you just created 30Gb of empty space (at the end of the disk, resizing /dev/sda5). You don't have to reinstall anything, gparted will copy your Win7 installation sector-by-sector. Win7 shouldn't even notice that it has been moved. – Avio Jan 17 '13 at 16:02
Partitions can be hidden. It's just a flag that tells the OSes and applications not to consider the partition. Just right click on your /dev/sda1 partition and in the context menu you should see a menu called flag management or something like that. There you can find the hidden flag. – Avio Jan 17 '13 at 16:05
There's no reason to suggest Knoppix on an Ubuntu site... just use the Ubuntu cd, also the hidden flag has no effect in Linux. Both partitions will be seen and this will confuse grub. Also windows can not boot from a logical partition. – psusi Jan 17 '13 at 16:42
The hidden flag is for Win7 in fact. And can you explain why two Win7 installation should confuse grub? I suggested Knoppix because I prefer it over the Ubuntu Live CD. Anyone can use whatever tool one deems appropriate. You should be on Ask Different if you believe otherwise. – Avio Jan 17 '13 at 16:48

Your Answer


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.