Linux RAID and Backup Commands With Examples

Redundant Array of Independent Disks (RAID)

  • RAID is a technology that employs the simultaneoud use of two or more partitions on the same or different hard disk drives to achieve greater levels of performance and reliability.
  • It is a fault tolerance mechanism in which the data is not lost even if one of the disk fails.
Types of RAID
  • Hardware RAID
  • Software RAID
RAID levels
  • RAID 0 (striping without parity)
  • RAID 1 (disk mirroring )
  • RAID 4 (parity)
  • RAID 5 (striping with parity)
Parity
  • Parity is used for fault tolerance.
  • Parity is calculated by using XOR tables
  • If one hard disk is lost the data on the other hard disk is xor with the parity and the original data is retrived.
Next :  Create and Edit User and Group on CentOS 7 / RHEL 7
RAID 0
  • Minimum 2 hard disks required.
  • Can support maximum 32 hard disks.
  • Data is written simultaneously and evenly across the multiple hard disks.
  • The reading and writing speed is faster.
  • Fault tolerance is not available.
RAID 1
  • Works with only 2 hard disks.
  • Same data is simultaneous written on both the disk.
  • The reading speed is fast and the writing speed is slow.
  • Fault tolerance is available.
  • Overhead is 50%
RAID 4
  • Minimum 3 hard disks required.
  • Can support maximum 32 hard disks.
  • One of the disk is reserved for parity.
  • Data is written simultaneously and evenly across the remaining disks.
  • The reading and writing speed is fast.
  • Fault tolerance is available.
  • Overhead 1 hard disk
RAID 5
  • Minimum 3 hard disks required .
  • Can support maximum 32 hard disks.
  • Data is written simultaneously and evenly across multiple hard disks.
  • The parity is written equally on all disks.
  • The reading and writing speed is fast.
  • Fault tolerance is available.
Next :  Create Bootable USB Drive from Windows 10 / 7 / 8.1 ISO file
Creating Partitions
Make multiple partitions
[root@techbrown.com~]# fdisk <device>
 Update the partition table
[root@techbrown.com~]# partprobe <device>
RAID Commands
To club all partitions into a RAID array
[root@techbrown.com~]# mdadm –C /dev/md0 -n <No. of partitions> <partition 1> <partition 2> <partition 3> -l <level>
Formatting the RAID device
[root@techbrown.com~]# mkfs.ext3 /dev/md0
Making a mount point
[root@techbrown.com~]# mkdir <directory name>
Mounting the RAID partition
[root@techbrown.com~]# mount /dev/md0 < directory name>
To make a partition faulty
[root@techbrown.com~]# mdadm  -f  /dev/md0 < faulty partition>
To remove a partition from the RAID array
[root@techbrown.com~]# mdadm  -r  /dev/md0 < partition>
Add a new partition to the RAID array
[root@techbrown.com~]# mdadm  -a  /dev/md0 <new partition>
To display the RAID device
[root@techbrown.com~]# mdadm  -d  /dev/md0
To stop the RAID
[root@techbrown.com~]# mdadm  -s  /dev/md0

Note: first it has to be unmountd before it can be stopped.

To assemble a RAID
[root@techbrown.com~]# mdadm  -a  /dev/md0 <partition1> <partition2> <partition3>

Backup

  • Backup is the process of copying the data to another location.
  • It is used to prevent the loss of data.
  • Users can take a backup only of their own data.
  • The complete backup can only be taken by root.
Next :  How to Install and Configure Samba on Ubuntu 18.04 / 16.04 / Linux Mint 18.3
Types of Backup
  • Full backup
  • The backup of the complete data.
  • Incremental backup
  • It includes files that were changed since the last backup.
Commands for Backup
  • Tar (Tape Archive)
  • Dump
Backup using tar Command
To backup and restore using tar commands
[root@techbrown.com~]# tar <options> <destination> <source>

Options

-c            Create                                                  -t             table of  content

-x            Extract/restore                                 -z            zip

-v            Verbose                                               -f             File

 

Backup using dump Command
To backup using dump commands
[root@techbrown.com~]# dump <options> <destination> <source>

Options

-n            n is an integer between 0 and 19 () means full backup)

-u            Update dump database file (/etc/dumpdates)

-f             filename

To restore the backup created by using the dump command
[root@techbrown.com~]# restore <options> <destination> <source>

Options

-t             Table of contents

-r             Restore

-f             Filename

Congratulations now have learned the Linux RAID and Backup Commands.

Hot Right Now

Related Post

COMMENTS