Today I helped my friend to setup data partition on her laptop. She used to have one partition for her window$ and just.
Usualy I use Knoppix for this, but recently I discovered a new live CD and this was the perfect opportunity to test it. It is called GParted LiveCD. It is an ~50mb distribution containing basic tools and runs GParted in Fluxbox window manager. Using the GUI is straightforward, but the disc in question had bad sectors so I had to use ntfsresize in command-line. The GUI
The following instructions are copied from http://crashrecovery.org/CrashRecoveryKit/iso/2.4.21/HOWTO.ntfs.html. I’ve copied the instructions since the originating page of these excerpts is not accessible and I’m afraid that this might happen also with the page hosting these excerpts. I’ve just added the notes for dealing with partitioning discs with bad sectors.
excerpts taken from ntfsresize FAQ (Frequently Asked Questions) http://mlf.linux.rulez.org/mlf/ezaz/ntfsresize.html by Szabolcs Szakacsits. ------------------------------------------------------------------------------ * Locate the drive and partition having the NTFS you plan to resize. Red Hat logs boot time messages during installation to /tmp/syslog that can help you to find the disk drive if you missed it. IDE disks are usually hda, hdb, hdc or hdd and SCSI ones are sda, sdb, sdc and so on. We have only one disk, hdc. Let's see what partitions it has, this shows all your drives for which are present and accesable: [tinker:root]:(~)# fdisk -l [tinker:root]:(~)# fdisk -l /dev/hdc Disk /dev/hdc: 255 heads, 63 sectors, 2480 cylinders Units = cylinders of 16065 * 512 bytes Device Boot Start End Blocks Id System /dev/hdc1 * 1 2479 19912536 7 HPFS/NTFS Only one partition, it's /dev/hdc1 and NTFS (OS/2 HPFS and Windows NTFS uses the same partition type, 7). Notice, it's also marked as bootable. * Find out where you could resize: [tinker:root]:(~)# ntfsresize -i /dev/hdc1 ntfsresize v1.6.99 NTFS volume version: 3.1 Current volume size: 20390432768 bytes (20391 MB) Scanning volume ... 100.00 percent completed You could resize at 10196025344 bytes or 10197 MB (freeing 10194 MB).If resizing disc with bad sectors, this command will issue a warning and instructions for proceeding before attempting the ntfsresize with --bad-sectors option. Follow the instructions and first run chkdsk /f /r in window$ command line (DOS) and reboot TWICE! Then boot back to QParted LiveCD, kill the x-server (Ctrl+Alt+Backspace) and run the above and following commandswith --bad-sectors option:[tinker:root]:(~)# ntfsresize -i --bad-sectors /dev/hdc1So we could free over 10 GB disk space using NTFS currently. ntfsresize will warn you if it can't free any space. Also if you get too small value, to be worth/possible installing Linux on, you must defragment your NTFS. However be careful, some defragmenters relocates data to the end of the disk in cases, so you won't be able to free any space with ntfsresize if this happens. * Make an ntfsresize test run, using the -n option. We chose trying to resize at 11 GB. [tinker:root]:(~)# ntfsresize -n --bad-sectors -s11000M /dev/hdc1 ntfsresize v1.6.99 NTFS volume version: 3.1 Current volume size: 20390432768 bytes (20391 MB) New volume size : 10999996416 bytes (11000 MB) Scanning volume ... 100.00 percent completed Updating $BadClust file ... Updating $Bitmap file ... Updating Boot record ... The read-only test run ended successfully. Everything looks good, let's go on. If you would get a different message or an ERROR: then don't proceed or try to force resizing! * Resize NTFS. [tinker:root]:(~)# ntfsresize --bad-sectors -s11000M /dev/hdc1 ntfsresize v1.6.99 NTFS volume version: 3.1 Current volume size: 20390432768 bytes (20391 MB) New volume size : 10999996416 bytes (11000 MB) Scanning volume ... 100.00 percent completed WARNING: Every sanity check passed and only the DANGEROUS operations left. Please make sure all your important data had been backed up in case of an unexpected failure! Are you sure you want to proceed (y/[n])? y Schedule chkdsk NTFS consistency check at Windows boot time ... Resetting $LogFile ... (this might take a while) Updating $BadClust file ... Updating $Bitmap file ... Updating Boot record ... Syncing device ... 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! Fine, NTFS had been shrunk. Let's continue with repartitioning the disk. * Repartition the disk. Warning! Basically this is the only error-prone step and several people made mistakes here forcing them to recover from backup! Below in order, we list the partition table, delete the 1st partition, recreate it with the same starting cylinder and using size 11000 MB as above (note, old fdisk uses binary while recent ones decimal units for kilo- and megabyte prefixes. ntfsresize uses decimal units), set the partition type to NTFS, mark it bootable as it was before. Then we print the partition table again to check everything is OK before writing it to disk. [tinker:root]:(~)# fdisk /dev/hdc Command (m for help): p Disk /dev/hdc: 255 heads, 63 sectors, 2480 cylinders Units = cylinders of 16065 * 512 bytes Device Boot Start End Blocks Id System /dev/hdc1 * 1 2479 19912536 7 HPFS/NTFS 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 (1-2480, default 1): 1 Last cylinder or +size or +sizeM or +sizeK (1-2480, default 2480): +11000M 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 Disk /dev/hdc: 255 heads, 63 sectors, 2480 cylinders Units = cylinders of 16065 * 512 bytes Device Boot Start End Blocks Id System /dev/hdc1 * 1 1403 11269566 7 HPFS/NTFS Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. * Reboot to Windows to check everything is right (e.g. pressing [Ctrl]-[Alt]-[Del]). Now you should have unallocated disk space that all Linux distribution installations must be able to handle. Enjoy! * Expanding your NTFS Volume . one should proceed in the opposite way. First run fdisk like above. throw away your NTFS partition, then create a new partition again which is of course bigger. Make sure if its your windows C: drive that it is tagged as active and has type 7 (HPFS/NTFS). next run ntfsresize like this : [tinker:root]:(~)# ntfsresize /dev/hdc1 so without any options, just add your partition as argument. One has to reboot and boot windows, i think twice, because windows chkdsk will of course check the changed disk settings. Here are the command line options for ntfsresize : [tinker:root]:(~)# ntfsresize -h ntfsresize v1.7.1 Usage: ntfsresize [options] device Resize an NTFS volume non-destructively. -i --info Calculate the smallest shrunken size supported -s num --size num Resize volume to num[k|M|G] bytes -n --no-action Do not write to disk -f --force Force to progress (DANGEROUS) -V --version Display version information -h --help Display this help The options -i and -s are mutually exclusive. If both options are omitted then the NTFS volume will be enlarged to the device size. Please report bugs to linux-ntfs-dev@lists.sourceforge.net Linux NTFS homepage: http://linux-ntfs.sourceforge.net * Speed up the installation of your Windows XP A couple a things can happen when you want to install or re-install Windows XP on your 120 Gbyte disk. 1. after 3 or 4 installs your serial-number on the label of your Windows-XP cdrom cannot be used again. 2. Formatting a 120 Gbyte harddisk can be a timely thing to wait for. So the first thing to do is to erase your disk : [tinker:root]:(~)# dd if=/dev/zero of=/dev/sda bs=40M count=1 1+0 records in 1+0 records out [tinker:root]:(~)# The will wipe enough info from the entire drive, that even Windows XP will forget it was even installed on the same drive before. So the old serial-number on the label of your Windows-XP cdrom can be used again. So it seems by zero-ing the first 40Mb of your disk the hardware history database which windows XP builds up is erazed too. However this is a wild guess, and not backed up by some real evidence. So don't flame me if the above disk cleaning command stops working suitable enoughNext we are going to create a new fresh NTFS partition on /dev/sda which we are going to install Windows XP on : [tinker:root]:(~)# fdisk /dev/sda Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. The number of cylinders for this disk is set to 2231. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-2231, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-2231, default 2231): Using default value 2231 Command (m for help): t Selected partition 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 Disk /dev/sda: 18.3 GB, 18351959040 bytes 255 heads, 63 sectors/track, 2231 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 2231 17920476 7 HPFS/NTFS Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [tinker:root]:(~)# Next we need to format it into a NTFS Filesystem Volume. To create a NTFS filesystem, mkntfs needs a disk sector-size and a Volume cluster-size. The following command adresses those : [tinker:root]:(~)# mkntfs -s 512 -c 4096 -Q /dev/sda1 mkntfs v1.7.1 Creating NTFS volume structures. Setting the volume dirty so check disk runs on next reboot into Windows. mkntfs completed successfully. Have a nice day. [tinker:root]:(~)# For documentation on which sector and cluster size to use see : Microsoft Knowledge Base Article - 314878 : http://support.microsoft.com/default.aspx?scid=kb;[LN];314878 http://www.ntfs.com/partition-table-heads.htm Now start up your machine with the Windows XP installation cdrom and choose to format the existing NTFS partition (Quick). With large partitions and disks this will save some time. ------------------------------------------------------------------------------- excerpts taken from ntfsresize FAQ (Frequently Asked Questions) http://mlf.linux.rulez.org/mlf/ezaz/ntfsresize.html by Szabolcs Szakacsits.