LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-16-2007, 08:42 AM   #1
pashabear
LQ Newbie
 
Registered: Jan 2006
Location: Moscow, Russia
Distribution: Mint, Puppy, PCLinuxOS, Mepis, Freespire
Posts: 10

Rep: Reputation: 0
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
 
Old 04-16-2007, 01:43 PM   #2
nirmaltom
Member
 
Registered: Jun 2005
Location: India
Distribution: Redhat,Fedora,DSL,Ubuntu
Posts: 238

Rep: Reputation: 30
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.

Last edited by nirmaltom; 04-16-2007 at 01:47 PM.
 
Old 04-16-2007, 08:49 PM   #3
pashabear
LQ Newbie
 
Registered: Jan 2006
Location: Moscow, Russia
Distribution: Mint, Puppy, PCLinuxOS, Mepis, Freespire
Posts: 10

Original Poster
Rep: Reputation: 0
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!
 
Old 04-16-2007, 09:37 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
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.
 
Old 04-17-2007, 05:58 AM   #5
nirmaltom
Member
 
Registered: Jun 2005
Location: India
Distribution: Redhat,Fedora,DSL,Ubuntu
Posts: 238

Rep: Reputation: 30
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.
 
Old 04-17-2007, 10:26 AM   #6
pashabear
LQ Newbie
 
Registered: Jan 2006
Location: Moscow, Russia
Distribution: Mint, Puppy, PCLinuxOS, Mepis, Freespire
Posts: 10

Original Poster
Rep: Reputation: 0
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
 
Old 04-17-2007, 10:25 PM   #7
pashabear
LQ Newbie
 
Registered: Jan 2006
Location: Moscow, Russia
Distribution: Mint, Puppy, PCLinuxOS, Mepis, Freespire
Posts: 10

Original Poster
Rep: Reputation: 0
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
 
Old 04-19-2007, 03:07 PM   #8
nirmaltom
Member
 
Registered: Jun 2005
Location: India
Distribution: Redhat,Fedora,DSL,Ubuntu
Posts: 238

Rep: Reputation: 30
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Solution: Resizing a NTFS partition. PureRumble Linux - Software 12 04-03-2007 01:45 PM
I Need Help Resizing NTFS partition fatenabu Linux - Distributions 1 12-04-2005 01:47 AM
URGENT! Resizing NTFS partition size problems. rconan Linux - Software 3 09-03-2005 12:03 PM
Safely resizing NTFS partition jnsg Linux - General 9 01-12-2005 11:35 PM
NTFS Partition Resizing darkangel Linux - General 13 08-04-2002 12:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration