Recent Bloggers

Saurang Suthar
Posts: 5
Stars: 0
Date: 7/4/17
Jyoti Verma
Posts: 3
Stars: 0
Date: 6/28/17
Pankti Patel
Posts: 1
Stars: 0
Date: 5/26/17
Chandrika Baraiya
Posts: 5
Stars: 0
Date: 5/26/17
Atith Patel
Posts: 5
Stars: 0
Date: 5/22/17
Nisarg Pujara
Posts: 6
Stars: 0
Date: 5/10/17
Pranavsinh Parmar
Posts: 4
Stars: 0
Date: 5/3/17
Ankit Prajapati
Posts: 5
Stars: 0
Date: 5/3/17
Pratik Solanki
Posts: 5
Stars: 0
Date: 4/7/17
Chirag Patel
Posts: 4
Stars: 0
Date: 3/30/17
« Back

Expand NTFS Volume from EC2 Linux Instance

Recently, we faced an issue of EBS volume expansion while we were migrating from Windows instance to Linux Instance. We were trying to attach the volume to Linux Instance which is restored from snapshot holding NTFS file system with lots of data. There was also a need to increase volume size before attaching it to Linux instance.

 

Expansion of partition in the EBS volume generally required in two scenarios:

  1. While volume is restored from snapshot which holds filesystem and data.

  2. While expanding storage space of an existing volume.

 

There are two steps to achieve partition expansion in file systems. First, we need to recreate the partition table entry of the volume’s file system and then expand partition in remaining size.

 

Let's start with re-creating a partition table entry.

 

There are lots of tools available for manipulating partition table in Linux like parted, GPT fdisk, FIPS, KDE Partition Manager etc. We are going to use “parted” tool for partition recreation. Most of Linux distribution comes with parted tool bundled with them. For more information, refer this link parted.

 

Below are the steps to recreate the partition table of the volume file system:

 

Note: Before proceeding further, it is advisable to take a snapshot of your volume. There is a possibility that you might corrupt or lose your data in the following procedures. If you have latest snapshot, you can start over in case of data corruption.

 

  1. Identify volume, which needs to be resized. Use lsblk to list all block devices.

ubuntu@:~$ lsblk

Find a volume that needs to be resized.

 

  1. Unmount volume if it is mounted. Use UMOUNT command with value of mountpoint from above step.  

ubuntu@:~$ sudo umount mountpoint

 

  1. Run parted utility on the volume that needs to be resized, not on the partition of that volume. Remember to add the /dev/ prefix to the name that lsblk outputs.

ubuntu@:~$ sudo parted block_device

 

  1. Change unit to sectors. For More Information, see parted units.

(parted) unit s

 

  1. List the detail of the partition entries of the volume.

Use print command to list all details of the partition table. For certain type of partition table you might get message to repair partition table. Answer “Ignore” to fixing existing partition table as we are going to create it later.

(parted) print

 

Note down details from output as it will be needed in next steps, the total size of the disk, the partition table type, the number of the partition, the start point of the partition, and flags. For gpt partition table, partition name and for msdos partition table, partition type and start point is needed to create new partition.

 

  1. Delete partition entry that you want to extend.

(parted) rm partition_num

 

  1. Create a new partition which is extended up to your expected size. Here we are going to extend it to the end of the volume.

(parted) mkpart partition_type partition_starting_point 100%

        

  1. Verify partition table entry. Use print command to list partition details and verify updated detail with previous detail which noted in the step 5.     

(parted) print
 

  1. Check if flag is there or not. In some cases the flag may be lost. If a flag was dropped from the partition when it was expanded, add the flag with the following command, substituting your partition number and the flag name

(parted) set partition_num flag_name on

Once again run print command and verify changes.

 

  1. Exit from parted.

(parted) quit

 

Now, We have recreated partition table entry in the previous steps. It’s time to resize partition as per our need. As we have ntfs filesystem resize2fs or xfs_growfs will not work here.

 

We are going to use ntfsresize to extend NTFS file system. ntfsresize is a free unix utility that non-destructively resize the NTFS file system used with any windows OS on a hard-disk partition. No de-fragmentation is required prior to resizing. ntfsresize is included in the ntfsprogs package. For more Information, see ntfsresize.

 

Below are the steps to resize partition.

 

  1. Resize partition, use ntfsresize command.

ntfsresize -s size partition_name

Here size is expected size in MB for the new partition.

eg. ntfsresize -s 11000M /dev/xvdf1

 

  1. List block devices using lsblk and verify whether volume size is expanded.

lsblk

 

Now you are done with volume expansion. Mount your volume and enjoy the expanded size of the volume.

 

For more implementation details or support you may contact us at enquiry@surekhatech.com.

Comments
Trackback URL:

No comments yet. Be the first.

Contact Us

Loading

Get in touch

Headquarter :
302, Landmark,
Nr. Titanium City Center,
Prahlad Nagar Road,
Ahmedabad, India - 380015.