How to Prepare Intel RAID Disk for Multi-boot

I often help my users set up their machines for multi-boot. For older computers without RAID, it’s quite easy. There is a nice GUI application QtParted to do it. The problem is QtParted doesn’t work on RAID disks. We have quite a few new Dell Dimensions with DataSafe (RAID 1) configuration. For these machines with RAID disks, you need to use command line tools to prepare them for multi-boot.

Before you do any of the following steps, make sure you have a good backup of your machine. It’s quite easy to render your machine unusable if you mess up.

First, you need to download the latest KNOPPIX, if you don’t have it. At time of this post, the version is 5.01. Early versions don’t recognize the RAID, so don’t use them. Boot the machine up using the KNOPPIX CD. Bring up a root shell. The RAID disk device files are in /dev/mapper directory. You’ll see several entries like isw_ccjdijdagj_ARRAY, isw_ccjdijdagj_ARRAY1 and isw_ccjdijdagj_ARRAY2 … The one without a number in the end is the RAID disk (isw_ccjdijdagj_ARRAY). The others with numbers are the partitions (isw_ccjdijdagj_ARRAY1, isw_ccjdijdagj_ARRAY2). Note that the exact name of the RAID is different for each machine. You’ll need to modify the command to suit your machine.

Now, we use fdisk to show the partition table of our RAID.


[email protected][knoppix]# fdisk -l /dev/mapper/isw_ccjdijdagj_ARRAY

Disk /dev/mapper/isw_ccjdijdagj_ARRAY: 159.9 GB, 159999590400 bytes255 heads, 63 sectors/track, 19452 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes



Device Boot      Start         End      Blocks   Id  System



/dev/mapper/isw_ccjdijdagj_ARRAY1               1           7       56196   de  Dell Utility



/dev/mapper/isw_ccjdijdagj_ARRAY2   *           8       19004   152593402+   7  HPFS/NTFS

There are two partitions for this RAID. The first partition is the Dell Utility and the second one is the NTFS partition for Windows. We want to shrink the second partition so that we have enough free space for other systems.

We can use ntfsresize with -i option to show information for the partition.


[email protected][knoppix]# ntfsresize -i /dev/mapper/isw_ccjdijdagj_ARRAY2

ntfsresize v1.13.1-WIP (libntfs 9:0:0)



Device name        : /dev/mapper/isw_ccjdijdagj_ARRAY2



NTFS volume version: 3.1



Cluster size       : 4096 bytes



Current volume size: 156255642112 bytes (156256 MB)



Current device size: 156255644160 bytes (156256 MB)



Checking filesystem consistency ...



100.00 percent completed



Accounting clusters ...



Space in use       : 62687 MB (40.1%)



Collecting resizing constraints ...



You might resize at 62686748672 bytes or 62687 MB (freeing 93569 MB).



Please make a test run using both the -n and -s options before real resizing!

This partition is about 156 GB. We want to resize it to about 130 GB, so that we have about 26 GB free space. As the suggestion given out by the previous command, we use -n and -s options to test it.


[email protected][knoppix]# ntfsresize -n -s130000M /dev/mapper/isw_ccjdijdagj_ARRAY2



ntfsresize v1.13.1-WIP (libntfs 9:0:0)



Device name        : /dev/mapper/isw_ccjdijdagj_ARRAY2



NTFS volume version: 3.1



Cluster size       : 4096 bytes



Current volume size: 156255642112 bytes (156256 MB)



Current device size: 156255644160 bytes (156256 MB)



New volume size    : 129999995392 bytes (130000 MB)



Checking filesystem consistency ...



100.00 percent completed



Accounting clusters ...



Space in use       : 62687 MB (40.1%)



Collecting resizing constraints ...



Needed relocations : 682 (3 MB)



Schedule chkdsk for NTFS consistency check at Windows boot time ...



Resetting $LogFile ... (this might take a while)



Relocating needed data ...



100.00 percent completed



Updating $BadClust file ...



Updating $Bitmap file ...



Updating Boot record ...



The read-only test run ended successfully.

All look good. Now we are going to resize the NTFS for real this time.




[email protected][knoppix]# ntfsresize -s130000M /dev/mapper/isw_ccjdijdagj_ARRAY2



ntfsresize v1.13.1-WIP (libntfs 9:0:0)



Device name        : /dev/mapper/isw_ccjdijdagj_ARRAY2



NTFS volume version: 3.1



Cluster size       : 4096 bytes



Current volume size: 156255642112 bytes (156256 MB)



Current device size: 156255644160 bytes (156256 MB)



New volume size    : 129999995392 bytes (130000 MB)



Checking filesystem consistency ...



100.00 percent completed



Accounting clusters ...



Space in use       : 62687 MB (40.1%)



Collecting resizing constraints ...



Needed relocations : 682 (3 MB)



WARNING: Every sanity check passed and only the dangerous operations left.



Make sure that important data has been backed up! Power outage or computer



crash may result major data loss!



Are you sure you want to proceed (y/[n])? y



Schedule chkdsk for NTFS consistency check at Windows boot time ...



Resetting $LogFile ... (this might take a while)



Relocating needed data ...



100.00 percent completed



Updating $BadClust file ...



Updating $Bitmap file ...



Updating Boot record ...



Syncing device ...



Successfully resized NTFS on device '/dev/mapper/isw_ccjdijdagj_ARRAY2'.



You can go on to shrink the device for example with Linux fdisk.



IMPORTANT: When recreating the partition, make sure that you



1)  create it at the same disk sector (use sector as the unit!)



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 won't be able to access NTFS or can't boot from the disk!



If you make a mistake and don't have a partition table backup then you



can recover the partition table by TestDisk or Parted's rescue mode.

We have successfully resized the NTFS file system, but we are not done yet. We need to “resize” the partition to match the file system size. The tool we are going to use is our good old fdisk. Wait, you might ask there is no resize command for fdisk. How are we going to “resize” the partition? Well, you’ll need to delete the partition and create a new partition that is of the size of file system we just shrunk.

Ok, enough of that. Now, let’s delete the second partition.




[email protected][knoppix]# fdisk /dev/mapper/isw_ccjdijdagj_ARRAY



The number of cylinders for this disk is set to 19452.



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)



Command (m for help): p



Disk /dev/mapper/isw_ccjdijdagj_ARRAY: 159.9 GB, 159999590400 bytes



255 heads, 63 sectors/track, 19452 cylinders



Units = cylinders of 16065 * 512 = 8225280 bytes



Device Boot      Start         End      Blocks   Id  System



/dev/mapper/isw_ccjdijdagj_ARRAY1               1           7       56196   de  Dell Utility



/dev/mapper/isw_ccjdijdagj_ARRAY2   *           8       19004   152593402+   7  HPFS/NTFS



Command (m for help): d



Partition number (1-4): 2

After the partition is deleted. We need to create a new partition.




Command (m for help): n



Command action



e   extended



p   primary partition (1-4)



p 



Partition number (1-4): 2



First cylinder (8-19452, default 8): 8



Last cylinder or +size or +sizeM or +sizeK (8-19452, default 19452): +130000M



Command (m for help): p



Disk /dev/mapper/isw_ccjdijdagj_ARRAY: 159.9 GB, 159999590400 bytes



255 heads, 63 sectors/track, 19452 cylinders



Units = cylinders of 16065 * 512 = 8225280 bytes



Device Boot      Start         End      Blocks   Id  System



/dev/mapper/isw_ccjdijdagj_ARRAY1               1           7       56196   de  Dell Utility



/dev/mapper/isw_ccjdijdagj_ARRAY2               8       15813   126961695   83  Linux

When the new partition gets created initially, the type is Linux and it’s not activated. We need to change the type back to NTFS and we also need to activate it, otherwise the system won’t boot.




Command (m for help): t



Partition number (1-4): 2



Hex code (type L to list codes): 7



Changed system type of partition 2 to 7 (HPFS/NTFS)



Command (m for help): a



Partition number (1-4): 2

Up until now, all the changes to the partition table are temporary. You might want to issue a “p” command to print the partition table and make sure it’s what you want. If not, just press “q” to quit fdisk without changes. If everything is alright, press “w” to save changes and exit.




Command (m for help): w



The partition table has been altered!



Calling ioctl() to re-read partition table.



WARNING: Re-reading the partition table failed with error 22: Invalid argument.



The kernel still uses the old table.



The new table will be used at the next reboot.



Syncing disks.

The next time you boot to Windows, the operating system would check the file system. Don’t panic, it’s normal. Afterward, you might need to reboot one more time because the OS think you just installed a new hard drive.

Now your RAID has enough free space for other OS. You’ll need to use a recent distribution of Linux. I used FC6. The installer of FC5 or earlier don’t support Intel RAID.