FAQ SearchLogin
Tuxera Home
View unanswered posts | View active topics It is currently Thu May 13, 2021 21:48



Post new topic Reply to topic  [ 4 posts ] 
Resize NTFS Partition 
Author Message

Joined: Wed Apr 25, 2012 22:37
Posts: 3
Post Resize NTFS Partition
Hello all,

I am in need of some help resizing an existing NTFS partition. I need it to be done from the CLI because it needs to be run from a python script.

I have the following:

The partition in question is /dev/sda2. This is the last partition on the drive. I would like this partition, as well as the NTFS filesystem that resides on it, to simply fill the rest of the drive.

I've googled and searched for several hours and have only found solutions suck as using fdisk to destroy and recreate the partition or using GParted. I am under the impression that using fdisk would corrupt the filesystem.

Any help is greatly appreciated!

Cheers,

Jolladay


Fri May 04, 2012 23:27
Profile
NTFS-3G Lead Developer

Joined: Tue Sep 04, 2007 17:22
Posts: 1286
Post Re: Resize NTFS Partition
Hi,

Quote:
The partition in question is /dev/sda2. This is the last partition on the drive. I would like this partition, as well as the NTFS filesystem that resides on it, to simply fill the rest of the drive.

Use ntfsresize (recent version) with option -x, this will expand an existing ntfs file system to the beginning of the partition, provided the end of the partition is unchanged. AFAIK this option is not managed by gparted.

Do the following (in that order) :
- backup your important files
- make sure the backup boot sector is correct by "ntfsfix /dev/sda2"
- build the target partition : relocate the beginning of the partition by an exact multiple of the cluster size, and make sure the end of the partition is unchanged. Make sure the new partition layout is acknowledged by the OS, you may have to reboot.
- adjust the file system to the partition by "ntfsresize -x /dev/sda2" Should something go wrong in that step, just restart the command, do not try to fix the file system.

Useful hints :
- get the initial file system parameters by "ntfsinfo -m /dev/sda2"
- get the initial partition layout by "sfdisk -d /dev/sda"

Quote:
I am under the impression that using fdisk would corrupt the filesystem.

when expanding a partition below the beginning, the file system is kept intact, but its boot sector cannot be located the usual way. This is why the backup boot sector has to be correct for resizing.

Regards

Jean-Pierre


Sat May 05, 2012 08:55
Profile

Joined: Wed Apr 25, 2012 22:37
Posts: 3
Post Re: Resize NTFS Partition
Hello,

Thank you for the response. I don't believe I explained my situation clearly. The drive appears like this:

|--SDA1--||---SDA2-------||--Unpartitioned Space--|

I would like to extend SDA2 to fill the remaining space. The beginning of SDA2 should remain in the same place.

Can I simply follow the steps you described but, instead of changing the start of the partition, just change the end?

Thank you,

Jolladay


Mon May 07, 2012 18:07
Profile
NTFS-3G Lead Developer

Joined: Tue Sep 04, 2007 17:22
Posts: 1286
Post Re: Resize NTFS Partition
Hi,

Quote:
I would like to extend SDA2 to fill the remaining space. The beginning of SDA2 should remain in the same place.

Can I simply follow the steps you described but, instead of changing the start of the partition, just change the end?

Not exactly, I understood sda2 were at the end of disk, and you wanted to expand to the space before it, but your actual situation is the opposite.

You will have to compute the partition size (partsize) from the end of disk and the beginning of sda2, and the new file system size (fssize), which must be a multiple of the cluster size and at most one sector less than the partition size.

You will have to use ntfsresize with option "-s fssize" instead of "-x".

Do the following (in that order) :
- backup your important files
- compute the new partition size and the new file system size
- build the target partition : relocate the end of the partition, and make sure the beginning of the partition is unchanged. Make sure the new partition layout is acknowledged by the OS, you may have to reboot.
- check whether the computed fssize is acceptable by "ntfsresize -n -s fssize /dev/sda2"
- adjust the file system to the fssize by "ntfsresize -s fssize /dev/sda2"
- recreate the backup boot sector by starting chkdsk (on Windows) or ntfsfix (recent version only).

This situation is managed by gparted, which will take care of all the constraints.

Regards

Jean-Pierre


Mon May 07, 2012 21:45
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Original forum style by Vjacheslav Trushkin.