Assumptions:

partition on both disks already set and equal

 

  • create an array(for SWAP)

# mdadm –create /dev/md1 –level=mirror –raid-devices=2 /dev/sda2 /dev/sdb2

 

Continue creating array? y

check our new array

# mdadm –detail /dev/md1

/dev/md1:
Version : 1.2
Creation Time : Tue Dec 25 10:11:58 2012
Raid Level : raid1
Array Size : 15622116 (14.90 GiB 16.00 GB)
Used Dev Size : 15622116 (14.90 GiB 16.00 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent

Update Time : Tue Dec 25 10:11:58 2012
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

Name : sec:1 (local to host sec)
UUID : 745325ec:bbac31fd:56475afa:528918ac
Events : 0

Number Major Minor RaidDevice State
0 8 2 0 active sync /dev/sda2
1 8 18 1 active sync /dev/sdb2

 

add this partition to mdadm.conf file so next reboot will be recognized

# mdadm -Es | grep :1 >> /etc/mdadm/mdadm.conf

 

 create swap

# mkswap -c /dev/md1

enable swap(mount)

# swapon /dev/md1

 

 

– before mounting swap

# free -m
total used free shared buffers cached
Mem: 16002 559 15443 0 2 142
-/+ buffers/cache: 414 15588
Swap: 0 0 0

– after mounting swap

# free -m
total used free shared buffers cached
Mem: 16002 542 15460 0 3 144
-/+ buffers/cache: 395 15607
Swap: 15255 0 15255

 

add swap partition to /etc/fstab (in my fstab file it looks like below)

# swap was on /dev/md1
UUID=da6ad2c4-9f38-4ffb-ba1e-2303649d075f none swap sw 0 0

  • create array(for /home)

# mdadm –create /dev/md2 –level=mirror –raid-devices=2 /dev/sda3 /dev/sdb3

mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store ‘/boot’ on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
–metadata=0.90
Continue creating array?y

mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md2 started.

 

disaplay all arrays

# mdadm -Es
ARRAY /dev/md/0 metadata=1.2 UUID=02b817b7:41dad749:67c03f7a:bfee433d name=sec:0
ARRAY /dev/md/1 metadata=1.2 UUID=745325ec:bbac31fd:56475afa:528918ac name=sec:1
ARRAY /dev/md/2 metadata=1.2 UUID=8e3c1dbb:6ff07a83:364a66a5:bd43c518 name=sec:2

add our new array(2) to mdadm.conf file

# mdadm -Es | grep :2 >> /etc/mdadm/mdadm.conf

 format /dev/md2

# mkfs -t ext3 -L /home /dev/md2

mke2fs 1.41.12 (17-May-2010)
Etykieta systemu plikow=/home
Typ OS: Linux
Rozmiar bloku=4096 (log=2)
Rozmiar fragmentu=4096 (log=2)
Stride=0 blokow, szerokosc Stripe=0 blokow
57024512 i-wezlow, 228076310 blokow
11403815 blokow (5.00%) zarezerwowanych dla superuzytkownika
Pierwszy blok danych=0
Maksymalna liczba blokow systemu plikow=4294967296
6961 grup blokow
32768 blokow w grupie, 32768 fragmentow w grupie
8192 i-wezlow w grupie
Kopie zapasowe superbloku zapisane w blokach: 
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
102400000, 214990848

Zapis tablicy i-wezlow: 1252/6961
zakonczono 
Tworzenie kroniki (32768 blokow): wykonano
Zapis superblokow i podsumowania systemu plikow: wykonano

Ten system plikow bedzie automatycznie sprawdzany co kazde 34 montowan„
lub co 180 dni, zaleznie co nastapi pierwsze. Mozna to zmienic poprzez
tune2fs -c lub -i.

 

check status of array md2

# mdadm –detail /dev/md2

/dev/md2:
Version : 1.2
Creation Time : Tue Dec 25 11:05:20 2012
Raid Level : raid1
Array Size : 912305240 (870.04 GiB 934.20 GB)
Used Dev Size : 912305240 (870.04 GiB 934.20 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent

Update Time : Tue Dec 25 11:12:49 2012
State : active, resyncing
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

Rebuild Status : 3% complete

Name : sec:2 (local to host sec)
UUID : 8e3c1dbb:6ff07a83:364a66a5:bd43c518
Events : 1

Number Major Minor RaidDevice State
active sync /dev/sda3
active sync /dev/sdb3

 

add /home to fstab

# blkid | grep md2

/dev/md2: LABEL=”/home” UUID=”785a8b54-46e1-4b8e-b2f9-e8e0eac0c37d” SEC_TYPE=”ext2″ TYPE=”ext3″

# /home
UUID=785a8b54-46e1-4b8e-b2f9-e8e0eac0c37d /home ext3 nodev,nosuid,noexec,usrquota,grpquota 0 2

 

mount /home

# mount /dev/md2
# df

System plikow bl. 1K B uzyte dostepne uzyte. zamont. na
/dev/md0   48059200   3445756   42172132   8% /
tmpfs 8193516 0 8193516 0% /lib/init/rw
udev 8188492 144 8188348 1% /dev
tmpfs 8193516 0 8193516 0% /dev/shm
/dev/md2  897989168  204872   852169036   1%   /home

 

dzbanek2012-12-25