RAID (Redundant Array of InExpensive Disks) & Logical Volume Manager

[root@RAID ~]# lsblk 
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0    7:0    0  3.6G  1 loop /mnt/iso
sda      8:0    0   20G  0 disk
├─sda1   8:1    0  300M  0 part /boot
├─sda2   8:2    0 17.7G  0 part /
├─sda3   8:3    0  104M  0 part [SWAP]
└─sda4   8:4    0    1K  0 part
sr0     11:0    1 1024M  0 rom

[root@RAID ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009149c

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          39      307200   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              39        2350    18566144   83  Linux
/dev/sda3            2350        2363      106429+  82  Linux swap / Solaris
/dev/sda4            2364        2610     1984027+   5  Extended

[root@RAID ~]# fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
switch off the mode (command ‘c’) and change display units to
sectors (command ‘u’).

Command (m for help): n
First cylinder (2364-2610, default 2364):
Using default value 2364
Last cylinder, +cylinders or +size{K,M,G} (2364-2610, default 2610): +300M

Command (m for help): n
First cylinder (2403-2610, default 2403):
Using default value 2403
Last cylinder, +cylinders or +size{K,M,G} (2403-2610, default 2610): +300M

Command (m for help): n
First cylinder (2442-2610, default 2442):
Using default value 2442
Last cylinder, +cylinders or +size{K,M,G} (2442-2610, default 2610): +300M

Command (m for help): n
First cylinder (2481-2610, default 2481):
Using default value 2481
Last cylinder, +cylinders or +size{K,M,G} (2481-2610, default 2610): +300M

Command (m for help): p

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009149c

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          39      307200   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              39        2350    18566144   83  Linux
/dev/sda3            2350        2363      106429+  82  Linux swap / Solaris
/dev/sda4            2364        2610     1984027+   5  Extended
/dev/sda5            2364        2402      313236   83  Linux
/dev/sda6            2403        2441      313236   83  Linux
/dev/sda7            2442        2480      313236   83  Linux
/dev/sda8            2481        2519      313236   83  Linux

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

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

[root@RAID ~]# partprobe 
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.
[root@RAID ~]# reboot

Broadcast message from root@RAID
(/dev/pts/0) at 11:47 …

The system is going down for reboot NOW!
[root@RAID ~]# Connection to 172.16.28.170 closed by remote host.
Connection to 172.16.28.170 closed.

mohammedrafi@NOC-RAFI:~$ ssh root@172.16.28.170
root@172.16.28.170’s password:
Last login: Sat Mar 26 11:46:26 2016 from 172.16.28.1

[root@RAID ~]# lsblk 
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0    7:0    0   3.6G  1 loop /mnt/iso
sda      8:0    0    20G  0 disk
├─sda1   8:1    0   300M  0 part /boot
├─sda2   8:2    0  17.7G  0 part /
├─sda3   8:3    0   104M  0 part [SWAP]
├─sda4   8:4    0     1K  0 part
├─sda5   8:5    0 305.9M  0 part
├─sda6   8:6    0 305.9M  0 part
├─sda7   8:7    0 305.9M  0 part
└─sda8   8:8    0 305.9M  0 part
sr0     11:0    1  1024M  0 rom

[root@RAID ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009149c

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          39      307200   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              39        2350    18566144   83  Linux
/dev/sda3            2350        2363      106429+  82  Linux swap / Solaris
/dev/sda4            2364        2610     1984027+   5  Extended
/dev/sda5            2364        2402      313236   83  Linux
/dev/sda6            2403        2441      313236   83  Linux
/dev/sda7            2442        2480      313236   83  Linux
/dev/sda8            2481        2519      313236   83  Linux

[root@RAID ~]# rpm -qa mdadm
mdadm-3.3.2-5.el6.x86_64
[root@RAID ~]# yum install mdadm*

[root@RAID ~]# mdadm -C /dev/md0 -n3 /dev/sda5 /dev/sda6 /dev/sda7 -l5
mdadm: /dev/sda5 appears to be part of a raid array:
level=raid5 devices=3 ctime=Sat Mar 26 11:21:34 2016
Continue creating array?
Continue creating array? (y/n) y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

[root@RAID ~]# mdadm -D /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Sat Mar 26 11:52:00 2016
Raid Level : raid5
Array Size : 623616 (609.10 MiB 638.58 MB)
Used Dev Size : 311808 (304.55 MiB 319.29 MB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent

Update Time : Sat Mar 26 11:52:06 2016
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0

Layout : left-symmetric
Chunk Size : 512K

Name : RAID:0  (local to host RAID)
UUID : 11298ee5:005b8f36:a07230a7:96f8c723
Events : 18

Number   Major   Minor   RaidDevice State
0       8        5        0      active sync   /dev/sda5
1       8        6        1      active sync   /dev/sda6
3       8        7        2      active sync   /dev/sda7

[root@RAID ~]# mkfs.ext4 /dev/md0 
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=128 blocks, Stripe width=256 blocks
39040 inodes, 155904 blocks
7795 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=163577856
5 block groups
32768 blocks per group, 32768 fragments per group
7808 inodes per group
Superblock backups stored on blocks:
32768, 98304

Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@RAID ~]# mkdir /raid

[root@RAID ~]# mount /dev/md0 /raid/

[root@RAID ~]# mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext=”system_u:object_r:tmpfs_t:s0″)
/dev/sda1 on /boot type ext4 (rw)
/root/rhel-server-6.7-x86_64-dvd.iso on /mnt/iso type iso9660 (ro,loop=/dev/loop0)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
/dev/md0 on /raid type ext4 (rw)

[root@RAID ~]# mount -a

[root@RAID ~]# cd /raid/

[root@RAID raid]# ls -l
total 16
drwx——. 2 root root 16384 Mar 26 11:52 lost+found

[root@RAID raid]# cat > file1
hai this is first file for raid

[root@RAID raid]# cat > file2
this will be second file

[root@RAID raid]# ls -l
total 24
-rw-r–r–. 1 root root    32 Mar 26 11:55 file1
-rw-r–r–. 1 root root    25 Mar 26 11:55 file2
drwx——. 2 root root 16384 Mar 26 11:52 lost+found

[root@RAID raid]# mdadm /dev/md0 -f /dev/sda7
mdadm: set /dev/sda7 faulty in /dev/md0

[root@RAID raid]# cat file1 
hai this is first file for raid

[root@RAID raid]# mdadm -D /dev/md0 
/dev/md0:
Version : 1.2
Creation Time : Sat Mar 26 11:52:00 2016
Raid Level : raid5
Array Size : 623616 (609.10 MiB 638.58 MB)
Used Dev Size : 311808 (304.55 MiB 319.29 MB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent

Update Time : Sat Mar 26 11:56:29 2016
State : clean, degraded
Active Devices : 2
Working Devices : 2
Failed Devices : 1
Spare Devices : 0

Layout : left-symmetric
Chunk Size : 512K

Name : RAID:0  (local to host RAID)
UUID : 11298ee5:005b8f36:a07230a7:96f8c723
Events : 24

Number   Major   Minor   RaidDevice State
0       8        5        0      active sync   /dev/sda5
1       8        6        1      active sync   /dev/sda6
4       0        0        4      removed

3       8        7        –      faulty   /dev/sda7

[root@RAID raid]# mdadm /dev/md0 -r /dev/sda7
mdadm: hot removed /dev/sda7 from /dev/md0

[root@RAID raid]# mdadm -D /dev/md0 
/dev/md0:
Version : 1.2
Creation Time : Sat Mar 26 11:52:00 2016
Raid Level : raid5
Array Size : 623616 (609.10 MiB 638.58 MB)
Used Dev Size : 311808 (304.55 MiB 319.29 MB)
Raid Devices : 3
Total Devices : 2
Persistence : Superblock is persistent

Update Time : Sat Mar 26 11:57:18 2016
State : clean, degraded
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

Layout : left-symmetric
Chunk Size : 512K

Name : RAID:0  (local to host RAID)
UUID : 11298ee5:005b8f36:a07230a7:96f8c723
Events : 25

Number   Major   Minor   RaidDevice State
0       8        5        0      active sync   /dev/sda5
1       8        6        1      active sync   /dev/sda6
4       0        0        4      removed

[root@RAID raid]# cat file1 
hai this is first file for raid

[root@RAID raid]# cat file2
this will be second file

[root@RAID raid]# ls -l
total 24
-rw-r–r–. 1 root root    32 Mar 26 11:55 file1
-rw-r–r–. 1 root root    25 Mar 26 11:55 file2
drwx——. 2 root root 16384 Mar 26 11:52 lost+found

[root@RAID raid]# cat /proc/mdstat 
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sda6[1] sda5[0]
623616 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2] [UU_]

unused devices: <none>

[root@RAID raid]# cat >> /etc/fstab 
/dev/md0  /raid  ext4 defaults  0  0

[root@RAID raid]# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Sat Oct 24 05:43:58 2015
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk’
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=d74ee9d4-00d3-42d7-b4aa-494f88ddf74a /                       ext4    defaults        1 1
UUID=5402dab1-f174-41e1-a3f8-ad386c26924c /boot                   ext4    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/root/rhel-server-6.7-x86_64-dvd.iso /mnt/iso iso9660 loop,ro   0   0

/dev/sda3 swap swap defaults 0 0
/dev/md0  /raid  ext4 defaults  0  0

[root@RAID raid]# mount -va
mount: UUID=5402dab1-f174-41e1-a3f8-ad386c26924c already mounted on /boot
mount: tmpfs already mounted on /dev/shm
mount: devpts already mounted on /dev/pts
mount: sysfs already mounted on /sys
mount: proc already mounted on /proc
mount: /root/rhel-server-6.7-x86_64-dvd.iso already mounted on /mnt/iso
mount: /dev/md0 already mounted on /raid
nothing was mounted

[root@RAID raid]# mdadm -a /dev/md0 /dev/sda8
mdadm: added /dev/sda8

[root@RAID raid]# mdadm -D /dev/md0 
/dev/md0:
Version : 1.2
Creation Time : Sat Mar 26 11:52:00 2016
Raid Level : raid5
Array Size : 623616 (609.10 MiB 638.58 MB)
Used Dev Size : 311808 (304.55 MiB 319.29 MB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent

Update Time : Sat Mar 26 12:12:21 2016
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0

Layout : left-symmetric
Chunk Size : 512K

Name : RAID:0  (local to host RAID)
UUID : 11298ee5:005b8f36:a07230a7:96f8c723
Events : 52

Number   Major   Minor   RaidDevice State
0       8        5        0      active sync   /dev/sda5
1       8        6        1      active sync   /dev/sda6
3       8        8        2      active sync   /dev/sda8

[root@RAID raid]# cat *
hai this is first file for raid
this will be second file
cat: lost+found: Is a directory

[root@RAID raid]# lsblk 
NAME    MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
loop0     7:0    0   3.6G  1 loop  /mnt/iso
sda       8:0    0    20G  0 disk
├─sda1    8:1    0   300M  0 part  /boot
├─sda2    8:2    0  17.7G  0 part  /
├─sda3    8:3    0   104M  0 part  [SWAP]
├─sda4    8:4    0     1K  0 part
├─sda5    8:5    0 305.9M  0 part
│ └─md0   9:0    0   609M  0 raid5 /raid
├─sda6    8:6    0 305.9M  0 part
│ └─md0   9:0    0   609M  0 raid5 /raid
├─sda7    8:7    0 305.9M  0 part
└─sda8    8:8    0 305.9M  0 part
└─md0   9:0    0   609M  0 raid5 /raid
sr0      11:0    1  1024M  0 rom

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s