Configure RAID 12022/08/30 |
Configure RAID 1 to add 2 new Disks on a computer.
|
|
[1] | This example is based on the environment like follows. It shows to install new Disks [sdb] and [sdc] on this computer and configure RAID 1. |
root@dlp:~# df -h Filesystem Size Used Avail Use% Mounted on tmpfs 796M 1.1M 795M 1% /run /dev/mapper/ubuntu--vg-ubuntu--lv 77G 8.2G 65G 12% / tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock /dev/vda2 2.0G 126M 1.7G 7% /boot tmpfs 796M 4.0K 796M 1% /run/user/0 |
[2] | Create a partition on new Disks and set RAID flag. |
root@dlp:~#
root@dlp:~# apt -y install parted parted --script /dev/sdb "mklabel gpt" root@dlp:~# parted --script /dev/sdc "mklabel gpt" root@dlp:~# parted --script /dev/sdb "mkpart primary 0% 100%" root@dlp:~# parted --script /dev/sdc "mkpart primary 0% 100%" root@dlp:~# parted --script /dev/sdb "set 1 raid on" root@dlp:~# parted --script /dev/sdc "set 1 raid on"
|
[3] | Configure RAID 1. |
root@dlp:~# mdadm --create /dev/md0 --level=raid1 --raid-devices=2 /dev/sdb1 /dev/sdc1
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store '/boot' on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=0.90
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
# show status root@dlp:~# cat /proc/mdstat Personalities : [raid1] md0 : active raid1 sdc1[1] sdb1[0] 83817472 blocks super 1.2 [2/2] [UU] [====>................] resync = 24.9% (20902592/83817472) finish=7.4min speed=140632K/sec unused devices: <none> # status turns like follows if syncing finished # that's OK to configure RAID 1 root@dlp:~# cat /proc/mdstat Personalities : [raid1] md0 : active raid1 sdc1[1] sdb1[0] 83817472 blocks super 1.2 [2/2] [UU] unused devices: <none> |
[4] | If a member Disk in RAID array would be failure, re-configure RAID 1 like follows after swapping new Disk. |
# the status is like follows in failure root@dlp:~# cat /proc/mdstat Personalities : [raid1] md0 : active raid1 sdc1[1] sdb1[0] 83817472 blocks super 1.2 [2/1] [U_] unused devices: <none> # after swapping new disk, re-configure like follows root@dlp:~# mdadm --manage /dev/md0 --add /dev/sdc1
mdadm: added /dev/sdc1
root@dlp:~# cat /proc/mdstat Personalities : [raid1] md0 : active raid1 sdc1[1] sdb1[0] 83817472 blocks super 1.2 [2/2] [UU] [====>................] resync = 24.9% (20902592/83817472) finish=7.4min speed=140632K/sec unused devices: <none> |
[5] | To use RAID partition, format with a filesystem and mount it on a directory as usual. |
# for example, format with ext4 and mount on /mnt root@dlp:~# mkfs.ext4 /dev/md0 root@dlp:~# mount /dev/md0 /mnt root@dlp:~# df -hT Filesystem Type Size Used Avail Use% Mounted on tmpfs tmpfs 795M 1.1M 794M 1% /run /dev/mapper/ubuntu--vg-ubuntu--lv ext4 76G 6.7G 66G 10% / tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock /dev/vda2 ext4 2.0G 127M 1.7G 7% /boot tmpfs tmpfs 795M 4.0K 795M 1% /run/user/0 /dev/md0 ext4 79G 24K 75G 1% /mnt # to set in fstab # because the name of md*** sometimes changes when hardwares are changed, set it with UUID root@dlp:~# blkid | grep md /dev/md0: UUID="de532c2c-67a6-44bf-84d8-8d5eba55e752" BLOCK_SIZE="4096" TYPE="ext4"
root@dlp:~#
vi /etc/fstab # set with UUID
/dev/disk/by-id/dm-uuid-LVM-OVORwCq99gl1jfieBtHmuXzxuK5vy6IBH9gC1yhsecDaXjqfv9aWK3K1rd7AZczP / ext4 defaults 0 1
# /boot was on /dev/vda2 during curtin installation
/dev/disk/by-uuid/53b66f54-ce3a-4717-87c8-c841549386bf /boot ext4 defaults 0 1
/swap.img none swap sw 0 0
/dev/disk/by-uuid/de532c2c-67a6-44bf-84d8-8d5eba55e752 /mnt ext4 defaults 0 0
# that's OK, even if the name of md*** are changed, it is mounted normally root@dlp:~# df -hT /mnt Filesystem Type Size Used Avail Use% Mounted on /dev/md127 ext4 79G 24K 75G 1% /mnt |
Sponsored Link |