Archive for the 'Hardware' Category

08
Sep
07

Adventures With Linux RAID Part 2

Background

After several days of playing around with FakeRAID on Ubuntu, I decided to scrap the install and start over using software raid instead. Originally I had went with FakeRAID because I wanted to share the RAID partition between Windows and Linux. Software raid partitions however are only available to linux, so that would have excluded Windows. By the third or so day or attempting to setup a dual-boot on FakeRAID however I decided the need to have Windows running on RAID was not that great– thus, it was time to try Soft RAID.

Initial Setup

Since my data was already backed up from before, I did not need to worry about salvaging anything from my drives and simply wiped them clean. So here is what I have:

  • Western Digital 320GB SATA 7200rpm
  • Maxtor 300GB SATA 7200rpm
  • Maxtor 160GB SATA 7200rpm
The goal was to set-up a software (mdadm) RAID-0 partition spread across the first two ~300GB drives. Even though they are not the exact same size, by creating partitions of the same size, hard-drive size should not be an issue. Windows would have to go on the third (160GB) drive since it cannot see Soft RAID partitions. In order to avoid having to re-install GRUB, I installed Windows XP on the 160GB drive beforehand.
First Attempt

Using the Ubuntu 7.04 Alternate Install CD, I follow the steps from a useful tutorial I found on setting up software RAID. At the partition set-up step, I created two 280GB partitions of type “physical volume for RAID“, one on each of the ~300GB hard-drives. I then created a 2GB swap space following the 300GB partition on the first drive, and then left the rest of the free space on each drive empty (I figured later I could use it for another OS, or for a shared NTFS partition). The 160GB drive with Windows was left alone.

Everything during the partition step worked fine– I used the “Configure software RAID” command to setup a RAID array using the two partitions, and set that to be my “/” partition. Problems arise only after all of the system files have been copied to the hard-drive, and the installer is attempting to Install GRUB. The screen flashes red and displays some error message along the lines of “Failed to install grub on MBR, would you like to chose another partition?” No matter what partition I attempt to install to however, GRUB will not install.

Eventually I give up and head back to the forums / Google to see if I can find a solution. A hint came in the form of a guide on Ubuntu Forums. The author suggests that for a RAID-0 setup, GRUB must be installed on a separate boot partition. So I wipe the two drives once more and try again.

Second Attempt

This time I do things slightly different. First, I create two 512Mb partitions at the beginning of each of the ~300GB hard-drives to use for a /boot partition (Actually, I only plan to use one, but decide to create similar partitions on both drives so that the RAID partitions will at the same location). Furthermore, I decide to only use 250GB of each drive for the Raid partition. I’ve decided to install two more operating systems, Fedora 8 and Debian Lenny, which will occupy the remaining space of each drive.

This time the install runs successfully and GRUB is installed on the /boot partition on the first hard-drive. Ubuntu boots fine, as do Fedora, Debian and Windows. My only remaining problem at this point is getting Fedora and Debian to recognize the md0 (software RAID) partition. After some messing around, I’m able to get Fedora go mount the md0 partition however I still have no luck with Debian. I decide that the performance gains (which I haven’t noticed really) are not worth all of the trouble I’ve gone through, and would surely go through in the future as I modify the system and try out other distros.

Conclusions

So in the end I decided to ditch the software RAID and install Ubuntu on a normal ext3 partition. I’m sure It would have been possible to get everything running well, and have Debian and Fedora working with the software raid partition, but you have to understand that by this point in time I’ve already spent the greater part of the the past three or four days Installing and troubleshooting RAID partitions. There was also the fact that Windows would not ever be able to see anything on the RAID partition. Perhaps if the performance gains had been more phenomenal I would have been tempted to stick with mdadm, and work out the kinks. They weren’t though. If you are just going to be running Linux alone, or perhaps with one other system, then Linux Software RAID might be worth the effort to install. Anything more elaborate however though I would just stick with traditional partitioning.

02
Sep
07

Adventures With Linux RAID Part 1

So last week I finally got around to re-formatting my system. I had been running a dual-boot with Ubuntu 7.04 and Windows XP for a while, but had finally reached that point after so much playing around with new software and settings that it was time for a fresh start. This time however I decided to try something new. The motherboard I have, a somewhat dated Asus p4c800-e Deluxe, has a built-in RAID controller (Promise 20378 RAID / FastTrak 378). Since I’ve never tried using raid before, and I had a couple of drives that were similar in size, I decided to give it a shot.

After a little bit of research I discovered there are a few different options for implementing RAID:
  • A separate RAID controller (“Hardware RAID”)
  • Built-in Motherboard controller (“fakeRAID” or “SATA RAID”)
  • Linux Software RAID
You also have to chose the type of RAID setup you want:
  • Raid0
  • Raid1
  • Raid5

etc.,

Two popular choices for home users are RAID 0 and RAID 1. In RAID 0, two hard-drives are treated as one. Data is read and written (“striped”) to both drives simultaneously, thus decreasing the time required to read or write files. In RAID 1 arrays, a second hard-drive is used as a backup. All data is written in it’s entirety to both hard-drives. This way, if either of the drives were to fail, there would still be a backup copy on the other drive. (If you want to learn more about the different types of RAID configurations, this RAID tutorial).

Since the RAID controller I have is built-in to the motherboard, I decided to try and setup a FakeRaid array. Software RAID would have been possible too, but I wanted something that Windows could run on as well. I had no critical data on my machine, and was only looking to get a boost in performance, so I chose to go with RAID level 0.

So here goes…

Round 01:
  1. Setup a Raid0 Array between two 300 GB drives (A single 600 GB array) using the Onboard Controller (Promise Fasttrak 378) software.
  2. Install Windows XP (have to load the drivers from a floppy disk during the install for the array to be detected).
  3. Attempt to shrink the NTFS partition currently filling the entire array in order to make room for Ubuntu.
  4. At first I try Gparted Live! And the regular Ubuntu Live! CD but neither are able to recognize the raid partition. After reading around a little more I find out that you have to manually install RAID support (dmraid) before doing any partitioning. I Load the dmraid packages as per this guide and Ubuntu can now see the raid array! (Yay- Almost there!)
  5. Run ntfsresize to resize the partition.
    ubuntu@ubuntu:/mnt$ sudo ntfsresize -s 100000000000 /dev/mapper/pdc_deibjeiej1
    
    ntfsresize v1.13.1 (libntfs 9:0:0)
    Device name        : /dev/mapper/pdc_deibjeiej1
    NTFS volume version: 3.1
    Cluster size       : 4096 bytes
    Current volume size: 600165745152 bytes (600166 MB)
    Current device size: 600165748224 bytes (600166 MB)
    New volume size    : 99999994368 bytes (100000 MB)
    
    Checking filesystem consistency ...
    100.00 percent completed
    Accounting clusters ...
    Space in use       : 30049 MB (5.0%)
    Collecting resizing constraints ...
    Needed relocations : 1369630 (5611 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/pdc_deibjeiej1'.
    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.
        

  6. Run fdisk to try and re-create the partition table– doh! This is where the real problems begin. Examining the RAID array with fdisk gives some strange results:
    ubuntu@ubuntu:/mnt$ sudo fdisk /dev/mapper/pdc_deibjeiej1
    
    The number of cylinders for this disk is set to 72965.
    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/pdc_deibjeiej1: 600.1 GB, 600165748224 bytes
    255 heads, 63 sectors/track, 72965 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    
    This doesn't look like a partition table
    Probably you selected the wrong device.
    
                          Device Boot      Start         End      Blocks   Id  System
    /dev/mapper/pdc_deibjeiej1p1   ?       13578      119522   850995205   72  Unknown
    Partition 1 does not end on cylinder boundary.
    /dev/mapper/pdc_deibjeiej1p2   ?       45382       79243   271987362   74  Unknown
    Partition 2 does not end on cylinder boundary.
    /dev/mapper/pdc_deibjeiej1p3   ?       10499       10499           0   65  Novell Netware 386
    Partition 3 does not end on cylinder boundary.
    /dev/mapper/pdc_deibjeiej1p4          167628      167631       25817+   0  Empty
    Partition 4 does not end on cylinder boundary.
    
    Partition table entries are not in disk order
    
    
There should only be one huge NTFS partition beginning near “0” and spanning the entire drive so something is wrong here.

Running Gparted is not much help either:

Gparted Error Messages

I search around a little more on the web and find out that using the Ubuntu 7.04 alternate install CD is better at setting up SATA raid arrays. At this point I decide to try other systems as well so I download the newest stable and testing releases for Debian along with a Fedora 8 Test 1 DVD. While both Fedora and latest Debian nightly build recognize the raid partition (You have to manually load the drivers for Debian), neither are able to resize the NTFS partition to install themselves. It’s back to the drawing boards for me.

.
.
.

Round 02:
WARNING: Things are about to get really ugly.
Since I’m unable to use any of the graphical partition editors to do what I need, I decide to go use Linux Fdisk to re-create the partition table. All of the documentation I found online suggested working in sectors rather than bytes so this involved busting out my handy calculator (gnome-calculator), and a pencil and paper to keep track of what the hell I was doing. By this point, I’ve run the Debian and Fedora installers so many times that I’ve become somewhat attached and have decided that I will try them out on the new install. So rather than just create a few partitions (Windows, Ubuntu and swap). I decide to create 6 partitions initially– One for windows, Two for Ubuntu (/ and swap), One large shared NTFS partition, and two more ~50 GB partitions for Fedora and Debian.

After several failed attempts at creating the the desired partition table (I have to be especially careful if I don’t want to corrupt my Windows install), I finally got it right! Even with the Ubuntu alternate install CD, fdisk still gave me a bunch of nonsense initially (Since when did I install Novel Netware?!). Rather than try to determine the reason why fdisk is giving such strange output though I decide to do the right lazy thing and just delete all that garbage. /shrug… It worked in the end so I guess it wasn’t anything important.

To work in sectors, I divided the number of bytes by 512. So the entire drive which was 600165748224 bytes consisted of 1172198727 sectors. To make the job easier, I did the calculations beforehand to see how many sectors were in 100Gb, 50Gb, 2Gb, etc– those are the sizes I need to use for creating the partitions.

So for those brave or curious souls, here is how it went:
ubuntu@ubuntu:~$ sudo /sbin/fdisk /dev/dm-1

The number of cylinders for this disk is set to 72965.
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): m

Command action

   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): u

Changing display/entry units to sectors

Command (m for help): p

Disk /dev/dm-1: 600.1 GB, 600165748224 bytes
255 heads, 63 sectors/track, 72965 cylinders, total 1172198727 sectors
Units = sectors of 1 * 512 = 512 bytes

This doesn't look like a partition table
Probably you selected the wrong device.

     Device Boot      Start         End      Blocks   Id  System

/dev/dm-1p1   ?   218129509  1920119918   850995205   72  Unknown
Partition 1 does not end on cylinder boundary.

/dev/dm-1p2   ?   729050177  1273024900   271987362   74  Unknown
Partition 2 does not end on cylinder boundary.

/dev/dm-1p3   ?   168653938   168653938           0   65  Novell Netware 386
Partition 3 does not end on cylinder boundary.

/dev/dm-1p4      2692939776  2692991410       25817+   0  Empty
Partition 4 does not end on cylinder boundary.

Partition table entries are not in disk order

Command (m for help): d

Partition number (1-4): 1

Command (m for help): d

Partition number (1-4): 2

Command (m for help): d

Partition number (1-4): 3

Command (m for help): d

Selected partition 4

Command (m for help): n

Command action

   e   extended
   p   primary partition (1-4)

p

Partition number (1-4): 1

First sector (63-1172198726, default 63): 
Using default value 63

Last sector or +size or +sizeM or +sizeK (63-1172198726, default 1172198726): +195312500

Command (m for help): p

Disk /dev/dm-1: 600.1 GB, 600165748224 bytes
255 heads, 63 sectors/track, 72965 cylinders, total 1172198727 sectors
Units = sectors of 1 * 512 = 512 bytes

     Device Boot      Start         End      Blocks   Id  System

/dev/dm-1p1              63   195312563    97656250+  83  Linux

Command (m for help): a

Partition number (1-4): 1

Command (m for help): p

Disk /dev/dm-1: 600.1 GB, 600165748224 bytes
255 heads, 63 sectors/track, 72965 cylinders, total 1172198727 sectors
Units = sectors of 1 * 512 = 512 bytes

     Device Boot      Start         End      Blocks   Id  System

/dev/dm-1p1   *          63   195312563    97656250+  83  Linux

Command (m for help): n

Command action

   e   extended
   p   primary partition (1-4)

p

Partition number (1-4): 2

First sector (195312564-1172198726, default 195312564): 
Using default value 195312564

Last sector or +size or +sizeM or +sizeK (195312564-1172198726, default 1172198726): +683593750

Command (m for help): p

Disk /dev/dm-1: 600.1 GB, 600165748224 bytes
255 heads, 63 sectors/track, 72965 cylinders, total 1172198727 sectors
Units = sectors of 1 * 512 = 512 bytes

     Device Boot      Start         End      Blocks   Id  System

/dev/dm-1p1   *          63   195312563    97656250+  83  Linux
/dev/dm-1p2       195312564   878906314   341796875+  83  Linux

Command (m for help): t

Partition number (1-4): 1

Hex code (type L to list codes): L

 0  Empty           1e  Hidden W95 FAT1 80  Old Minix       be  Solaris boot   
 1  FAT12           24  NEC DOS         81  Minix / old Lin bf  Solaris        
 2  XENIX root      39  Plan 9          82  Linux swap / So c1  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  83  Linux           c4  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 5  Extended        41  PPC PReP Boot   85  Linux extended  c7  Syrinx         
 6  FAT16           42  SFS             86  NTFS volume set da  Non-FS data    
 7  HPFS/NTFS       4d  QNX4.x          87  NTFS volume set db  CP/M / CTOS / .
 8  AIX             4e  QNX4.x 2nd part 88  Linux plaintext de  Dell Utility   
 9  AIX bootable    4f  QNX4.x 3rd part 8e  Linux LVM       df  BootIt         
 a  OS/2 Boot Manag 50  OnTrack DM      93  Amoeba          e1  DOS access     
 b  W95 FAT32       51  OnTrack DM6 Aux 94  Amoeba BBT      e3  DOS R/O        
 c  W95 FAT32 (LBA) 52  CP/M            9f  BSD/OS          e4  SpeedStor      
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi eb  BeOS fs        
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a5  FreeBSD         ee  EFI GPT        
10  OPUS            55  EZ-Drive        a6  OpenBSD         ef  EFI (FAT-12/16/
11  Hidden FAT12    56  Golden Bow      a7  NeXTSTEP        f0  Linux/PA-RISC b
12  Compaq diagnost 5c  Priam Edisk     a8  Darwin UFS      f1  SpeedStor      
14  Hidden FAT16 <3 61  SpeedStor       a9  NetBSD          f4  SpeedStor      
16  Hidden FAT16    63  GNU HURD or Sys ab  Darwin boot     f2  DOS secondary  
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fd  Linux raid auto
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fe  LANstep        
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid ff  BBT            
1c  Hidden W95 FAT3 75  PC/IX          

Hex code (type L to list codes): 7

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

Command (m for help): t

Partition number (1-4): 2

Hex code (type L to list codes): 0

Type 0 means free space to many systems (but not to Linux). Having partitions of type 0 is probably unwise. You can delete a partition using the `d' command.

Changed system type of partition 2 to 0 (Empty)

Command (m for help): n

Command action

   e   extended
   p   primary partition (1-4)

e

Partition number (1-4): 3

First sector (195312564-1172198726, default 195312564): 
Using default value 195312564

Last sector or +size or +sizeM or +sizeK (195312564-1172198726, default 1172198726): +195312500

Command (m for help): n

Command action

   l   logical (5 or over)
   p   primary partition (1-4)

l

First sector (195312627-390625064, default 195312627): 
Using default value 195312627
Last sector or +size or +sizeM or +sizeK (195312627-390625064, default 390625064): +3906250

Command (m for help): n

Command action

   l   logical (5 or over)
   p   primary partition (1-4)

l

First sector (199218941-390625064, default 199218941):         
Using default value 199218941

Last sector or +size or +sizeM or +sizeK (199218941-390625064, default 390625064): +97656250

Command (m for help): n

Command action

   l   logical (5 or over)
   p   primary partition (1-4)

l

First sector (296875255-390625064, default 296875255): 
Using default value 296875255

Last sector or +size or +sizeM or +sizeK (296875255-390625064, default 390625064): 
Using default value 390625064

Command (m for help): p

Disk /dev/dm-1: 600.1 GB, 600165748224 bytes
255 heads, 63 sectors/track, 72965 cylinders, total 1172198727 sectors
Units = sectors of 1 * 512 = 512 bytes

     Device   Boot      Start         End      Blocks   Id  System
/dev/dm-1p1   *          63   195312563    97656250+   7  HPFS/NTFS
/dev/dm-1p2       195312564   878906314   341796875+   0  Empty
/dev/dm-1p3       195312564   390625064    97656250+   5  Extended
/dev/dm-1p5       195312627   199218877     1953125+  83  Linux
/dev/dm-1p6       199218941   296875191    48828125+  83  Linux
/dev/dm-1p7       296875255   390625064    46874905   83  Linux



Command (m for help): t

Partition number (1-7): 5

Hex code (type L to list codes): 0

Type 0 means free space to many systems (but not to Linux). Having partitions of type 0 is probably unwise. You can delete a partition using the `d' command.

Changed system type of partition 5 to 0 (Empty)

Command (m for help): t

Partition number (1-7): 6

Hex code (type L to list codes): 0

Type 0 means free space to many systems (but not to Linux). Having partitions of type 0 is probably unwise. You can delete a partition using the `d' command.

Changed system type of partition 6 to 0 (Empty)

Command (m for help): t

Partition number (1-7): 7

Hex code (type L to list codes): 0

Type 0 means free space to many systems (but not to Linux). Having partitions of type 0 is probably unwise. You can delete a partition using the `d' command.

Changed system type of partition 7 to 0 (Empty)

Command (m for help): p

Disk /dev/dm-1: 600.1 GB, 600165748224 bytes
255 heads, 63 sectors/track, 72965 cylinders, total 1172198727 sectors
Units = sectors of 1 * 512 = 512 bytes

     Device    Boot      Start          End           Blocks       Id  System
/dev/dm-1p1   *          63        195312563    97656250+    7  HPFS/NTFS
/dev/dm-1p2       195312564   878906314    341796875+  0  Empty
/dev/dm-1p3       195312564   390625064    97656250+    5  Extended
/dev/dm-1p5       195312627   199218877    1953125+      0  Empty
/dev/dm-1p6       199218941   296875191    48828125+    0  Empty
/dev/dm-1p7       296875255   390625064    46874905      0  Empty

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.

ubuntu@ubuntu:~$ sudo /sbin/fdisk /dev/dm-1

The number of cylinders for this disk is set to 72965.
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/dm-1: 600.1 GB, 600165748224 bytes
255 heads, 63 sectors/track, 72965 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

     Device Boot      Start         End      Blocks   Id  System

/dev/dm-1p1   *           1       12158    97656250+   7  HPFS/NTFS
/dev/dm-1p2           12158       54710   341796875+   0  Empty
/dev/dm-1p3           12158       24316    97656250+   5  Extended
/dev/dm-1p5           12158       12401     1953125+   0  Empty
/dev/dm-1p6           12401       18480    48828125+   0  Empty
/dev/dm-1p7           18480       24316    46874905    0  Empty

Command (m for help): q
Eventually I get Ubuntu installed however I cannot for the life of me get Fedora, Debian and Ubuntu to all work together. By this time I’m so fed up with all of the crap I’ve had to go through to get this far that I decide to scrap dmraid– it’s not worth the trouble. Supposedly Linux software RAID is better than fakeRAID, and is supposed to be easier to set-up. Initially I went with fakeraid because it can only be used by Linux, and I wanted something that Windows could use too, but it’s really not worth the trouble. I can live without Windows RAID install.
As for fakeRAID’s performance, I really can’t say much. I only ran it for a day or so before wiping the drives again in preparation to setup software RAID. /Shrug. Oh well, At least I can say I ran linux on RAID now.
The moral of the story?– Don’t use SATA RAID on a multi-boot machine unless you enjoy pain.



Follow

Get every new post delivered to your Inbox.