Back to Top

Mirroring in Linux

Here are the steps by which one can do mirroring in Linux running system after installation of the Operating system.

1. #sudo apt-get install mdadm

2. Partition the disk

fdisk -l

fdisk /dev/sdb (second hard disk)

Change the partition type to auto raid (use m for options during partitioning)

3. creating RAID

# mdadm –create /dev/md0 –level=mirror –raid-devices=2 /dev/sdb1 /dev/sdc1

results: mdadm: Defaulting to version 1.2 metadata

mdadm: array /dev/md0 started

This will create /dev/md0 virtual drive created from the two real block devices /dev/sdb1 and /dev/sdc1

4. cat  /proc/mdstat

Personalities : [raid1]

md0: active raid1 adc1[1] sdb[0]

create mdadm.conf

# sudo mdadm –detail –scan –v > /etc/mdadm/mdadm.conf

5. Create file system on the RAID

sudo mkfs.ext4 /dev/md0

(ignore the errors if come)

6. sudo mkdir    /data   (creating directory so that we can mount our drive here)

sudo mount  /dev/md0   /data (mount the virtual drive)

sudo chmod   777   /data (giving permissions)

sudo chmod  +t   /data (By doing this other uses can view and add files but only the owner can delete the data)

# echo “/dev/ md0 /data/ext4 defaults 1 2” >> /etc/fstab (append entries in fstab)

 

your mirror is ready…. enjoy 😛

 

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home