The model installation assumes two identical SATA disks from which a software mirror (RAID 1) will be created later on. It is used in cases when the server has no HW RAID.
First hard drive is connected as /dev/sda and the second one as /dev/sdb.
If your hard drives are up to 160GB in size, create only 2 new disk partitions. One partition for creation of software RAID (md0 for the system), and the second one for SWAP purposes. First of all, create partition for system installation. The capacity of the first partition will be determined by the deduction of a maximal capacity of the disk and a space which is reserved for the storage space, approx. 2 to 4GB. Then from the remaining space a second primary partition will be created, where also the SWAP will be situated.
If you have greater hard disks (250GB, 320GB, 500GB, 1000GB ), you´d better separate the system from the backups and the NETflow data to your own partitions. So create the first system partition of approx. 100GB (md0 array), the second partition is for SWAP (approx. 4GB), and the last partition for backup/NETflow data (md1 array).
If there is already any SW raid activated, you have to delete it, otherwise it would be impossible to manipulate with the disk partitions. If not, you may continue.
mdadm --manage --stop /dev/md0
Run fdisk -l to see if the system has detected harddisks and how they are marked.
Often they are marked as /dev/sda and dev/sdb, yet they can be marked differently (e.g. /dev/hda).
Run fdisk with /dev/sda parameter (first harddisk).
fdisk /dev/sda
List disk partitions using "p” and, if applicable, delete already created ones using "d” to make sure the disk is empty.
If the disk is empty start creating a new primary partition using "n”.
- choose p for primary
- leave default partition number
- leave default first sector
- enter last sector according to your desired partition size, e.g. +7G
Create SWAP partition from remaining space accordingly.
List partitions to make sure they are big enough. If not, discard all partitions and start over.
The first - system - partition must be of FD (Raid Autodetect) type, and the second one - SWAP - of 82 (Linux swap / Solaris) type.
- press t
- select partition 2
- enter FD, or 82 for SWAP
Then mark the first - system - partition for booting.
- press a
- select partition 1
Check again, if partition size / type is correct as well as boot flag.
The last step is to save changes in fdisk which updates MBR table.
Configuration of the first disk /dev/sda is finished now. Apply the same procedure to /dev/sdb. First, run fdisk /dev/sdb and repeat previous steps on the second drive. If you have a big harddisk, create 3 partitions instead of 2.
ATTENTION! Created partitions must be identical on both disks! Check it by running fdisk -l.
Creating disk array RAID1 (mirror) and formatting
You now have to create RAID1 (mirror) from first partitions of both disks /dev/sda1 and /dev/sdb1. To do so, use
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
Display raid status by
cat /proc/mdstat
Here you can see that the array:
- is named /dev/md0,
- is active (md0 : active raid1),
- comprises of 2 disks (sdb1[1] sda1[0]),
- has both disks in U status, which means UP ( [2/2] [UU] ).
The array will be fully redundant upon completion.
Do not restart server prior to synchronization of disks!
If you use a big harddisk and create 3 partitions, you initiate second RAID1 by:
mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sda3 /dev/sdb3
Finally, format partitions. Formatting bigger harddisks may take up to several minutes.
mkfs.ext4 /dev/md0 #first array md0 format (physical partitions /dev/sda1 and /dev/sdb1) to ext4 file system
mkswap /dev/sda2 #creation of file system for swapping to second partition of first disk
mkswap /dev/sdb2 #creation of file system for swapping to second partition of second disk
Formatting possible second RAID array
mkfs.xfs /dev/md1 ### formatting second md1 array (physical partitions /dev/sda3 and /dev/sdb3) to xfs file system
Why using xfs for second data partitions? It is more efficient with big disk partitions and big amount of small files - Netflow data typically. Always use ext4 native file system for system partition (array md0)!