View  Edit  Attributes  History  Attach  Print  Search

MediaDisk

This was created from http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch26_:_Linux_Software_RAID and http://www.linuxforums.org/forum/debian-linux-help/60295-problems-creating-raid-5-using-mdadm.html

Check what filesystems are availible

% sudo fdisk -l

Disk /dev/sda: 750.1 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sda doesn't contain a valid partition table

Disk /dev/sdb: 750.1 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 750.1 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table

Disk /dev/sdd: 750.1 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdd doesn't contain a valid partition table

Disk /dev/hda: 400.0 GB, 400088457216 bytes
255 heads, 63 sectors/track, 48641 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1        2432    19535008+  fd  Linux raid autodetect
/dev/hda2            2433        2554      979965   fd  Linux raid autodetect
/dev/hda3            2555       48641   370193827+  fd  Linux raid autodetect

Disk /dev/hdc: 400.0 GB, 400088457216 bytes
255 heads, 63 sectors/track, 48641 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdc1   *           1        2432    19535008+  fd  Linux raid autodetect
/dev/hdc2            2433        2554      979965   fd  Linux raid autodetect
/dev/hdc3            2555       48641   370193827+  fd  Linux raid autodetect

Disk /dev/md0: 20.0 GB, 20003749888 bytes
2 heads, 4 sectors/track, 4883728 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md0 doesn't contain a valid partition table

Disk /dev/md1: 1003 MB, 1003356160 bytes
2 heads, 4 sectors/track, 244960 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md1 doesn't contain a valid partition table

Disk /dev/md2: 379.0 GB, 379078377472 bytes
2 heads, 4 sectors/track, 92548432 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md2 doesn't contain a valid partition table

Ok starting with /dev/sda

% sudo fdisk /dev/sda

Now, m gives help text.

  • Set The ID Type To FD

Add a new primary, first, partition partition with n p 1 Partition /dev/sda1 is the first partition on disk /dev/sda. Modify its type using the t command, and specify the partition number and type code. You also should use the L command to get a full listing of ID types in case you forget.

  • Make Sure The Change Occurred

Use the p command to get the new proposed partition table:

Command (m for help): p

Disk /dev/sda: 750.1 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1       91201   732572001   fd  Linux raid autodetect

  Save The Changes

Use the w command to permanently save the changes to disk /dev/sda:

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

Calling ioctl() to re-read partition table.
Syncing disks.
  • Repeat For The Other Partitions

Now the four new disks are found

% sudo fdisk -l

Disk /dev/sda: 750.1 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1       91201   732572001   fd  Linux raid autodetect

Disk /dev/sdb: 750.1 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       91201   732572001   fd  Linux raid autodetect

Disk /dev/sdc: 750.1 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1       91201   732572001   fd  Linux raid autodetect

Disk /dev/sdd: 750.1 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1       91201   732572001   fd  Linux raid autodetect

  • Setting up RAID 5

Creating the md device. Looking above I see that I already have md0 - md1, originating from my RAID 1.

% sudo mdadm –-create –-verbose /dev/md3 –-level=raid5 --chunk=64 --parity=left-symmetric –-raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1

%mdadm --create --force /dev/md1 --level=raid5 --chunk=64 --
parity=left-symmetric --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 /
dev/sdd1

Looking at the progress

% sudo watch cat /proc/mdstat
Personalities : [raid1] [raid5] [raid4]
md3 : active raid5 sdd1[4] sdc1[2] sdb1[1] sda1[0]
      2197715712 blocks level 5, 64k chunk, algorithm 2 [4/3] [UUU_]
      [==================>..]  recovery = 90.2% (661495544/732571904) finish=23.8min speed=49710K/sec

md2 : active raid1 hda3[0] hdc3[1]
      370193728 blocks [2/2] [UU]

md1 : active raid1 hda2[0] hdc2[1]
      979840 blocks [2/2] [UU]

md0 : active raid1 hda1[0] hdc1[1]
      19534912 blocks [2/2] [UU]

unused devices: <none>

watch is a very useful linux command which will refresh the output of a command ever 2 seconds for you. It took about 160 minutes...

The mdadm.conf file contains information about your RAID array that the mdm daemon will need on boot to “re-assemble” your array ready for mounting. To create your mdadm.conf file, issue the following:

    sudo echo "DEVICE partitions" > /etc/mdadm/mdadm.conf
    sudo mdadm –detail –scan >> /etc/mdadm/mdadm.conf

I got permission denied there, so I manually edited the /etc/mdadm/mdadm.conf

% cat /etc/mdadm/mdadm.conf
DEVICE partitions
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=6806c80e:31715d1b:65497909:3105ce17
ARRAY /dev/md1 level=raid1 num-devices=2 UUID=d3f3313c:0ee1e56f:85061e90:08950fdc
ARRAY /dev/md2 level=raid1 num-devices=2 UUID=4267e7b6:53f00be3:79baa5de:2dad767b
ARRAY /dev/md3 level=raid5 num-devices=4 UUID=4c4ca9ef:2edb18ec:1f3755d9:45e96112

Creating ext3 filesystem

sudo mkfs.ext3 /dev/md3

The next step is to create a mount point for /dev/md3. In this case we'll create one called /mnt/media

% sudo mkdir /mnt/media
  • Edit The /etc/fstab File

The /etc/fstab file lists all the partitions that need to mount when the system boots. Add an Entry for the RAID set, the /dev/md0 device.

/dev/md3      /mnt/media     ext3    defaults    0 2

Do not use labels in the /etc/fstab file for RAID devices; just use the real device name, such as /dev/md3.

% cat /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
# /dev/md0
UUID=1d3a0339-d521-4c72-9035-b1013d7053e5 /               ext3    defaults,errors=remount-ro 0       1
# /dev/md2
UUID=55a6cd1f-32ea-4593-b5d6-03f6cc3b6e72 /home           ext3    defaults        0       2
# /dev/md1
UUID=a78fd647-076a-4a41-85b5-24a0b95d9be2 none            swap    sw              0       0
/dev/hdd        /media/cdrom0   udf,iso9660 user,noauto     0       0
/dev/md3        /mnt/media      ext3    defaults        0       2
% mount /dev/md3
% sudo mount /dev/md3
% ls /mnt/media/
lost+found
% cd /mnt/media/
%  df -h .
Filesystem            Size  Used Avail Use% Mounted on
/dev/md3              2.1T  209M  2.0T   1% /mnt/media
% cd /mnt/media/
% sudo mkdir public_media
% sudo chmod a+w public_media
% cd /home/public/
% ln -s /mnt/media/public_media media
  • Update

All I got from the above was fsck: Device or resource busy while trying to open /dev/hda3.

Then somebody started talking about blkid.tab which looks like this:

% cat /etc/blkid.tab
<device DEVNO="0x0301" TIME="1173629516" UUID="1d3a0339-d521-4c72-9035-b1013d7053e5" SEC_TYPE="ext2" TYPE="ext3">/dev/hda1</device>
<device DEVNO="0x0302" TIME="1173629516" UUID="a78fd647-076a-4a41-85b5-24a0b95d9be2" TYPE="swap">/dev/hda2</device>
<device DEVNO="0x0303" TIME="1173629516" UUID="55a6cd1f-32ea-4593-b5d6-03f6cc3b6e72" SEC_TYPE="ext2" TYPE="ext3">/dev/hda3</device>
<device DEVNO="0x1601" TIME="1173629516" UUID="1d3a0339-d521-4c72-9035-b1013d7053e5" SEC_TYPE="ext2" TYPE="ext3">/dev/hdc1</device>
<device DEVNO="0x1602" TIME="1173629516" UUID="a78fd647-076a-4a41-85b5-24a0b95d9be2" TYPE="swap">/dev/hdc2</device>
<device DEVNO="0x1603" TIME="1173629516" UUID="55a6cd1f-32ea-4593-b5d6-03f6cc3b6e72" SEC_TYPE="ext2" TYPE="ext3">/dev/hdc3</device>
<device DEVNO="0x0900" TIME="1185573556" PRI="10" UUID="1d3a0339-d521-4c72-9035-b1013d7053e5" SEC_TYPE="ext2" TYPE="ext3">/dev/md0</device>
<device DEVNO="0x0901" TIME="1173629516" PRI="10" UUID="a78fd647-076a-4a41-85b5-24a0b95d9be2" TYPE="swap">/dev/md1</device>
<device DEVNO="0x0902" TIME="1173629517" PRI="10" UUID="55a6cd1f-32ea-4593-b5d6-03f6cc3b6e72" SEC_TYPE="ext2" TYPE="ext3">/dev/md2</device>

That did not seem right, the /dev/md0 have not been moved here so I tried:

 sudo blkid
Password:
/dev/hda1: UUID="1d3a0339-d521-4c72-9035-b1013d7053e5" SEC_TYPE="ext2" TYPE="ext3"
/dev/hda2: UUID="a78fd647-076a-4a41-85b5-24a0b95d9be2" TYPE="swap"
/dev/hda3: UUID="55a6cd1f-32ea-4593-b5d6-03f6cc3b6e72" SEC_TYPE="ext2" TYPE="ext3"
/dev/hdc1: UUID="1d3a0339-d521-4c72-9035-b1013d7053e5" SEC_TYPE="ext2" TYPE="ext3"
/dev/hdc2: UUID="a78fd647-076a-4a41-85b5-24a0b95d9be2" TYPE="swap"
/dev/hdc3: UUID="55a6cd1f-32ea-4593-b5d6-03f6cc3b6e72" SEC_TYPE="ext2" TYPE="ext3"
/dev/md0: UUID="0bdf6cba-849c-4073-b154-01918b93d6bc" SEC_TYPE="ext2" TYPE="ext3"
/dev/md1: UUID="1d3a0339-d521-4c72-9035-b1013d7053e5" SEC_TYPE="ext2" TYPE="ext3"
/dev/md2: TYPE="swap" UUID="a78fd647-076a-4a41-85b5-24a0b95d9be2"
/dev/sda1: UUID="0bdf6cba-849c-4073-b154-01918b93d6bc" SEC_TYPE="ext2" TYPE="ext3"
/dev/sdd1: UUID="0bdf6cbe-849c-4073-b154-01918b93d6bc" SEC_TYPE="ext2" TYPE="ext3"
/dev/md3: UUID="55a6cd1f-32ea-4593-b5d6-03f6cc3b6e72" SEC_TYPE="ext2" TYPE="ext3"

% cat /etc/blkid.tab
<device DEVNO="0x0301" TIME="1186950780" UUID="1d3a0339-d521-4c72-9035-b1013d7053e5" SEC_TYPE="ext2" TYPE="ext3">/dev/hda1</device>
<device DEVNO="0x0302" TIME="1186950780" UUID="a78fd647-076a-4a41-85b5-24a0b95d9be2" TYPE="swap">/dev/hda2</device>
<device DEVNO="0x0303" TIME="1186950780" UUID="55a6cd1f-32ea-4593-b5d6-03f6cc3b6e72" SEC_TYPE="ext2" TYPE="ext3">/dev/hda3</device>
<device DEVNO="0x1601" TIME="1186950780" UUID="1d3a0339-d521-4c72-9035-b1013d7053e5" SEC_TYPE="ext2" TYPE="ext3">/dev/hdc1</device>
<device DEVNO="0x1602" TIME="1186950780" UUID="a78fd647-076a-4a41-85b5-24a0b95d9be2" TYPE="swap">/dev/hdc2</device>
<device DEVNO="0x1603" TIME="1186950780" UUID="55a6cd1f-32ea-4593-b5d6-03f6cc3b6e72" SEC_TYPE="ext2" TYPE="ext3">/dev/hdc3</device>
<device DEVNO="0x0900" TIME="1186950780" PRI="10" UUID="0bdf6cba-849c-4073-b154-01918b93d6bc" SEC_TYPE="ext2" TYPE="ext3">/dev/md0</device>
<device DEVNO="0x0901" TIME="1186950780" PRI="10" UUID="1d3a0339-d521-4c72-9035-b1013d7053e5" SEC_TYPE="ext2" TYPE="ext3">/dev/md1</device>
<device DEVNO="0x0902" TIME="1186950780" PRI="10" UUID="a78fd647-076a-4a41-85b5-24a0b95d9be2" TYPE="swap">/dev/md2</device>
<device DEVNO="0x0801" TIME="1186950780" UUID="0bdf6cba-849c-4073-b154-01918b93d6bc" SEC_TYPE="ext2" TYPE="ext3">/dev/sda1</device>
<device DEVNO="0x0831" TIME="1186950780" UUID="0bdf6cbe-849c-4073-b154-01918b93d6bc" SEC_TYPE="ext2" TYPE="ext3">/dev/sdd1</device>
<device DEVNO="0x0903" TIME="1186950780" PRI="10" UUID="55a6cd1f-32ea-4593-b5d6-03f6cc3b6e72" SEC_TYPE="ext2" TYPE="ext3">/dev/md3</device>

Now we got an md3 in there as well, comparing that with the fstab

% cat /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
# /dev/md0
UUID=1d3a0339-d521-4c72-9035-b1013d7053e5 /               ext3    defaults,errors=remount-ro 0       1
# /dev/md2
UUID=55a6cd1f-32ea-4593-b5d6-03f6cc3b6e72 /home           ext3    defaults        0       2
# /dev/md1
UUID=a78fd647-076a-4a41-85b5-24a0b95d9be2 none            swap    sw              0       0
/dev/hdd        /media/cdrom0   udf,iso9660 user,noauto     0       0
#/dev/md3        /mnt/media      ext3    defaults        0       2
#UUID=0bdf6cba-849c-4073-b154-01918b93d6bc /mnt/media      ext3    defaults        0       2

And it worked!!! Now I just removed the comment on the last row to see if that still works.