Create RAID Partitions on Ubuntu
Server Training - Server Management

 RAID, the Redundant Array of Inexpensive Disks, provides several features that are valuable for servers. RAID can provide speed enhancements for your server and RAID can provide redundancy or it can provide both.  There are several levels of RAID that you may use, these levels map to the tasks that you want RAID to perform.  This series of tutorials will take you through creating software RAID for levels 0,1 and 5.

 

Create RAID Partitions with fdisk
You must become familiar with fdisk as this is the tool you will use to create partitions.  Be sure you practice these skills on a test server before you work on a production server.  You will need to install the mdadm program to create software RAID.

sudo apt-get install mdadm


 


Create 4 raid devices with fdisk.  Be sure that you edit the correct drive so that you do not damage the drive you have your operating system on.

# fdisk /dev/sdb

Command (m for help): p
Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       48632   390636508+  83  Linux

Print the partition entries - see what is there before you begin the process. It is always a good idea to verify that what you are about to destroy is what you want to destroy. No doubt about it, if you partition it all information will be gone.

Command (m for help): n

n will create a new partition.

Command action
   e   extended
   p   primary partition (1-4)
e

An extended partition is created so that logical partitions may be created out of the extended partition.  You can only have 3 primary partitions and then an extended partition.

Partition number (1-4): 4
First cylinder (48633-60801, default 48633):
Using default value 48633
Last cylinder or +size or +sizeM or +sizeK (48633-60801, default 60801):
Using default value 60801

Command (m for help): p

It is always a good idea to verify the work you have done by viewing it with p.

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xe7ee79f4

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       48632   390636508+  83  Linux
/dev/sdb4           48633       60801    97747492+   5  Extended

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l

The l is a logical partition that is created from the large extended partition.  Note that the drive sizes that are created below are only for illustration purposes.  Your RAID partitions should be on separate drives and they should larger.  The small drives are just to illustrate the process.

First cylinder (48633-60801, default 48633):
Using default value 48633
Last cylinder or +size or +sizeM or +sizeK (48633-60801, default 60801): +500M

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (48695-60801, default 48695):
Using default value 48695
Last cylinder or +size or +sizeM or +sizeK (48695-60801, default 60801): +500M

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (48757-60801, default 48757):
Using default value 48757
Last cylinder or +size or +sizeM or +sizeK (48757-60801, default 60801): +500M

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (48819-60801, default 48819):
Using default value 48819
Last cylinder or +size or +sizeM or +sizeK (48819-60801, default 60801): +500M

Command (m for help): p

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xe7ee79f4

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       48632   390636508+  83  Linux
/dev/sdb4           48633       60801    97747492+   5  Extended
/dev/sdb5           48633       48694      497983+  83  Linux
/dev/sdb6           48695       48756      497983+  83  Linux
/dev/sdb7           48757       48818      497983+  83  Linux
/dev/sdb8           48819       48880      497983+  83  Linux

Here you can see 4 small partitions are created.  These are not RAID available as the type is 83 which is the ext3  partitions.  You will need to cahnge the type.  Type can be changed by using the t option.

Command (m for help): t

Partition number (1-8): 5
Hex code (type L to list codes): L

The L option will list the possibilities for types on partitions.

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): fd
Changed system type of partition 5 to fd (Linux raid autodetect)

The type you must use for creating RAID is fd.


Command (m for help): t
Partition number (1-8): 6
Hex code (type L to list codes): fd
Changed system type of partition 6 to fd (Linux raid autodetect)

Command (m for help): t
Partition number (1-8): 7
Hex code (type L to list codes): fd
Changed system type of partition 7 to fd (Linux raid autodetect)

Command (m for help): t
Partition number (1-8): 8
Hex code (type L to list codes): fd
Changed system type of partition 8 to fd (Linux raid autodetect)

Command (m for help): p

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xe7ee79f4

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       48632   390636508+  83  Linux
/dev/sdb4           48633       60801    97747492+   5  Extended
/dev/sdb5           48633       48694      497983+  fd  Linux raid autodetect
/dev/sdb6           48695       48756      497983+  fd  Linux raid autodetect
/dev/sdb7           48757       48818      497983+  fd  Linux raid autodetect
/dev/sdb8           48819       48880      497983+  fd  Linux raid autodetect

Note that the partitions types have now been changed.  Now they are RAID aware.

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

Write the information to disk
Nothing has changed on the drive until you use the w option, then all the information that you have created will be written to the drive. When you write to disk using the w option it will be forever changed!!!!!!! So be careful you have a backup. Once you use the w option you will see the disk syncing. You may have to restart to get both partitions setup. 


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

RAID partitions have now been created.  You will need to verify that the system recognizes those partitions with partprobe or restart.

# partprobe

Your partitions are now ready to be used by RAID.  The next step is to decide what level of RAID you want to use for your Ubuntu server.

 


Copyright CyberMontana Inc. and BeginLinux.com
All rights reserved. Cannot be reproduced without written permission. Box 1262 Trout Creek, MT 59874