LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Resizing NTFS Partition with errors (https://www.linuxquestions.org/questions/linux-software-2/resizing-ntfs-partition-with-errors-546462/)

pashabear 04-16-2007 08:42 AM

Resizing NTFS Partition with errors
 
Hi, I have the unfortunate situation of a hard disk with bad sectors, these showed up when I tried to resize my NTFS (WinXP) partition. I believe they're from a Partition Magic resizing gone bad (even though I've since completely wiped out that partition and reinstalled Windows). Anyway, GParted didn't want to resize because of these bad sectors, and recommended I run the chkdsk command under Windows and reboot. This I did, but still got the errors. Upon looking closer, I saw that the ntfsresize command needed to be run with the -b option. I did this manually, and successfully resized to 10240 MB (10 GB). BUT, now GParted shows the disk still at 20 GB, and says 15 GB are full! What to do??? When I ran the ntfsresize command it mentioned something about using fdisk to reduce the size of the partition, but I didn't understand.
As you can guess, I'm pretty much a newbie to command line stuff, I'm not afraid of it but if directing me to use such please give complete directions.
Thanks
pb

nirmaltom 04-16-2007 01:43 PM

hi,

To understand parition and file systems, read
http://en.wikipedia.org/wiki/Disk_partitioning
http://en.wikipedia.org/wiki/File_systems

From man pages,
Quote:

If you wish to enlarge a filesystem, you must first make sure you can expand the size of the underlying partition first.Now expand the file system.

If you wish to shrink ,first shrink the size of filesystem. Then you may use fdisk to shrink the size of the partition. When shrinking the size of the partition, make sure you do not make it smaller than the new size of the filesystem!

When u create a partition using fdisk , does it hold a file system by default?No
They are empty or raw partitions.Then u will format it with a file system like ext2 or vfat.Similarly when u resize u have to resize both of them.

So u shrinked the file system and u have to shrink the partition now.
I think u will understand it now.

Take backup first to avoid data loss.

regards,
Nirmal Tom.

pashabear 04-16-2007 08:49 PM

Well, I understand that I need to shrink the partition, but I don't know how to do this. I've looked at the fdisk man page, but still can't understand. Please help!

syg00 04-16-2007 09:37 PM

The concept is simple - the partition table entry merely describes the partition; basically start and size. You delete the partition entry (doesn't affect the data), then define a new (smaller in your case) partition starting at the same location.
Needs to be no smaller than the filesystem you resized.

Try the FAQ at linux-ntfs.org - seems to be offline at present, but has a bit more detail about how to do this safely.

nirmaltom 04-17-2007 05:58 AM

hi,
u can use both fdisk and parted for the purpose.parted is easy.

like syg00 said,

Quote:

define a new (smaller in your case) partition starting at the same location
its too important.
when use fdisk note the start cylinder of the partition u wish to resize, then delete it and recreate the partition with the same cylinder as start and the end cylinder is ur desired size.

parted on the other hand is too easy.

give the command ,
parted /dev/sda

where sda is ur hard disk name

then give command print, it will print partition structure in easy format
mine is,

(parted) print

Disk /dev/sda: 80.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
1 8225kB 10.5GB 10.5GB primary boot
2 10.5GB 80.0GB 69.5GB extended lba
5 10.5GB 31.5GB 21.0GB logical fat32
6 31.5GB 36.7GB 5239MB logical ntfs
7 36.7GB 36.8GB 107MB logical ext3
8 36.8GB 63.0GB 26.2GB logical lvm
9 63.0GB 63.1GB 82.2MB logical fat16
10 63.1GB 80.0GB 16.9GB logical


No cylinder infn, for our easy doing.Then use resize command to resize the partition u like.

from parted help,
Quote:

resize NUMBER START END resize partition NUMBER and its file
system

NUMBER is the partition number used by Linux. On MS-DOS disk labels,
the primary partitions number from 1 to 4, logical partitions from 5
onwards.
START and END are disk locations, such as 4GB or 10%. Negative values
count from the end of the disk. For example, -1s specifies exactly the
last sector.
The partition must have one of the following FS-TYPEs: ext3, ext2,
fat32, fat16, hfsx, hfs+, hfs, linux-swap

suppose if i like resize mu 10th partition(10 63.1GB 80.0GB 16.9GB logical),
i have to do,

resize 10 63.1GB 70GB

hope u understand

regards,
Nirmal Tom.

pashabear 04-17-2007 10:26 AM

Your suggestion (using parted) sounded good, but it turns out it won't work:
Code:

No Implementation: Support for opening ntfs file systems is not implemented yet.
So, I guess it's back to fdisk...
pb

pashabear 04-17-2007 10:25 PM

Well, I managed to get the partition resized using fdisk, here are the commands I used (from another page I found):

Code:

# fdisk /dev/hda
Command (m for help): p

Command (m for help): d
Partition number (1-4): 1

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (8-3648, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (8-3648, default 3648): +10240M

Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): 7
Changed system type of partition 1 to 7 (HPFS/NTFS)

Command (m for help): a
Partition number (1-4): 1

Command (m for help): p

Device Boot Start End Blocks Id System
/dev/hda1 * 1 1246 10008463+ 7 HPFS/NTFS

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Command (m for help):q

Just thought this might be useful for someone else, searching though the forums...
pb

nirmaltom 04-19-2007 03:07 PM

hi,
i am not aware of that parted limitation.Glad to see u post back to help others.Good luck on your linux adventures.
regards,
Nirmal tom


All times are GMT -5. The time now is 05:44 AM.