Last week I need a new partition on my external drive. The HDD has 80Gb split in 2 partitions, one of 20Gb and one of around 56Gb. The first partition was nearly full and the second had 30Gb of free space (but with many fragmented files). The obvious solution is to move the 26Gb from the second partition to another drive, delete it and create 2 smaller ones. But if you don’t have the 26Gb of temporary space there is another solution: shrink the second partition and create a new one in the free remaining space. This can be achieved with Partition Magic but the tool is not free. (You can download a trial version and see if it is working but using free tools is better – and I was eager to see if it is possible). The process I’ll describe below is simple and can be applied to any external HDD drive with ntfs partitions (and probably other types, by using the correct tools).
Important: Before starting please be aware of the risks you are taking. I strongly advise you to fully backup at least the partition that will be resized. The best is to do a full disk backup before trying any change. You’ve been warned, please don’t complain later!
Step 1. Tools
We will use several tools during the process.
The most important is the file system re-sizer named ntfsresize. It and can be obtain from linux-ntfs or from a linux live-cd. To run it you can use an already existing linux environment or the live-cd (my choice).
Before resizing the file system we’ll need to move all the existing information on the beginning of the partition. This is done by using JkDefrag. This tool has an option to consolidate the free space and to move all the files to the beginning of the disk.
After resizing the file system you’ll need to resize the existing partition and to create the new partitions. This task is accomplished with fdisk. The creation of the new file systems can be done either in windows or in linux.
Step 2. Linux environment
If you don’t have a running linux environment you can use a vmware virtual machine with a live-cd. In this case SystemRescueCD version 0.3.5 which comes with several useful tools. (you will find there GParted which is a clone of Partition Magic for Linux but I didn’t used it for this task).
As virtual machine vmware provides 2 choices. The simpler is to use the VMware Player (but you’ll need to build the virtual machine with a third party tool). The most flexible is to install the VMware Server and run the VM from there. Because I needed a quick solution I’ve used the player approach (as I have it already install). The virtual machine is created with VMX Builder. You can create the machine with the standard options (even without HDD disk) but don’t forget to add an USB controller (by default it is not selected) and to map the CDROM device to the live-cd image (an iso file or the real cdrom).
Step 3. Defragmentation
In order to be able to create a new partition we’ll need to make as much free space as possible on the last section of the existing partition. For this we’ll need to consolidate the free space by using the JkDefrag. This step is done from Windows. Just save the application somewhere on the disk and run from the command prompt:
JkDefrag.exe -a 5 -q letter
The -a 5 option specifies to force all the files to the disk beginning. The letter is your disk letter for the partition you are resizing. After a while (it can take hours for a big disk with many files!) it will finish and exist. At this moment it is critical to not change anything on the freshly defragmented partition. For this you must unplug the USB drive and start the virtual environment (don’t start it with the hdd connected because it will “belong” to the host OS not the the virtual one – the hdd must be connected to the usb port only after the virtual machine is online and has focus).
Step 3. Resizing
The resizing is done from the linux environment. I was using a virtual machine running with a live-cd but you can try a real linux if you have it. The instructions are the same. I’ve took them from here, you should read them if you need more details. (all the operations are done as root).
The first step is to plug-in the HDD drive in the USB port. The linux will detect the device and load the required modules for you. To check everything worked you can issue
fdisk -l
which will list the available drives. The USB HDD should be /dev/sda (or something similar sdb, sdc, sdd). If the device is not present something went wrong and you’ll have to solve this issue first (Hint: you can use dmesg to check for modules loading errors).
fdisk -l /dev/sda
will get you a list of the partitions from the drive. You should identify the NTFS partition you need to resize (it has number from 1 to 4 if it is a primary partition or 5-… if it is into an extended partition – in my case it was sda2).
Next you will find how much space you can obtain by resizing
ntfsresize -i /dev/sda2
NTFS volume version: 3.1
Current volume size: 56340212768 bytes (56340 MB)
Scanning volume ...
100.00 percent completed
You could resize at 23900082544 bytes or 23900 MB (freeing 32440 MB).
In this case we can get around 32GB of free space. It is best not to resize up to the maximum available space and let 1-2 GB of spare space on the existing partition. In this case I’ve decided to get 30000MB for the new partition. The ntfresize has a test mode where it executes all the resizing operations but do not write anything on disk. If there is an error (or even warning?) it is best not to do the resizing as you might lose all your data.
ntfsresize -n -s30000M /dev/sda2
If there is no error you can issue the real command
ntfsresize -s30000M /dev/sda2
...
NTFS had been successfully resized on device '/dev/hdc1'.
You can go on to resize the device e.g. with 'fdisk'.
IMPORTANT: When recreating the partition, make sure you
1) create it with the same starting disk cylinder
2) create it with the same partition type (usually 7, HPFS/NTFS)
3) do not make it smaller than the new NTFS filesystem size
4) set the bootable flag for the partition if it existed before
Otherwise you may lose your data or can't boot your computer from the disk!
and wait a few seconds to finish the operation. If the resize is successful you should see the next steps you must perform to finish the process.
Did I mention you should power the external HDD and the computer from a UPS? You are risking all your data if a power failure occurs during the process…
Step 4. Repartitioning
After the resizing process is finish you have a disk with a smaller file system but with a large partition. The information about the partition size is kept in the partition table and you will change it with the fdisk tool. This is a risky step as if you make a mistake then the existing partition will be lost (you can use other disk recovery tools but this is not fail-safe). You can make a backup of the partition table with the dd:
dd if=/dev/hdc of=/root/sec.bin -s 512
and restore later. This is just a safety measure, don’t skip the other instructions.
fdisk /dev/sda
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (2549-10198, default 1): 2549
Last cylinder or +size or +sizeM or +sizeK (2549-10198, default 10198): +23900M
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 7
Changed system type of partition 1 to 7 (HPFS/NTFS)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
The performed steps are:
– delete the old partiton (d command on partiton 2)
– create a new partition (n command) – pay attention to starting cylinder, must be the same as the old partition with the new size (23900M, the same as the ntfsresize -i return!)
– set the type as NTFS
– write the partition table.
If there was an error you can restore the old partition table and forget about resizing 🙂
Now you can create the new partition. You can do it from linux.
fdisk /dev/sda
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (5596-10198, default 1): 5596
Last cylinder or +size or +sizeM or +sizeK (5596-10198, default 10198):
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 7
Changed system type of partition 1 to 7 (HPFS/NTFS)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
The last step is the creation of a new file system (NTFS) which can be done from windows or linux.
mkntfs /dev/sda3
With this you are ready and can test the new drive (after you power off the virtual machine).
Step 5. Testing
For testing the new partition just run a chkdsk from Windows (to be sure the file system is not corrupted) and copy some files.
Finally, there’s another very important peculiarity of what does Cialis that brings it so high above its alternatives. It is the only med that is available in two versions – one intended for use on as-needed basis and one intended for daily use. As you might know, Viagra and Levitra only come in the latter of these two forms and should be consumed shortly before expected sexual activity to ensure best effect. Daily Cialis, in its turn, contains low doses of Tadalafil, which allows to build its concentration up in your system gradually over time and maintain it on acceptable levels, which, consequently, makes it possible for you to enjoy sex at any moment without having to time it.