Wednesday, December 8, 2010

playing with linear raid and ext4

The goal is to create linear raid with ext4 array from 4 disks. Than add 5. disk and verify data.

Create linear raid from 4 disks
$ sudo mdadm -v --create /dev/md0 -l linear -n 4 /dev/sdb /dev/sdc /dev/sdd /dev/sde

Make ext4fs
$ sudo mkfs.ext4 /dev/md0

Mount array
$ sudo mkdir array
$ sudo mount /dev/md0 /media/array


Information about array
$ sudo mdadm --detail /dev/md0
$ cat /proc/mdstat


Set the system recognize the raid after the reboot
$ sudo echo 'DEVICES /dev/sdb /dev/sdc /dev/sdd /dev/sde' >> /etc/mdadm/mdadm.conf
$ sudo mdadm --detail --scan >> /etc/mdadm.conf


Upload test data, make md5 checksum
$ cd /media/array/
$ wget http://cdimage.debian.org/debian-cd/5.0.7/amd64/iso-cd/debian-507-amd64-netinst.iso
$ md5sum debian-507-amd64-netinst.iso
971ddace926fc3f7765f595da5cce223 debian-507-amd64-netinst.iso


Add 5. disk and resize filesystem
$ mdadm --grow --add /dev/md0 /dev/sdf
$ sudo resize2fs /dev/md0


Add device at /etc/mdadm/mdadm.conf and rescan (change list line)

Compare checksum
$ md5sum debian-507-amd64-netinst.iso
971ddace926fc3f7765f595da5cce223 debian-507-amd64-netinst.iso


Checksums are the same.

Add line to /etc/fstab and test reboot.

Sometimes there are problems with assemble, look in

cat /proc/mdstat


if there are not some dummy traits from one disk, that you can stop by

mdadm --stop /dev/md_d0


See also wiki

No comments:

Post a Comment