Initialize the devices you want to RAID and set the RAID flag to ON.
The sample code is for the device /dev/sdb
.
# parted /dev/sdb
(parted) print
Error: /dev/sdb: unrecognised disk label
Model: ATA TOSHIBA MD05ACA8 (scsi)
Disk /dev/sdb: 8002GB
Sector size (logical/physical): 512B/4096B
Partition Table: unknown
Disk Flags:
(parted) mklabel gpt
(parted) unit GB
(parted) mkpart primary xfs 0 8002
(parted) set 1 raid on
(parted) print
Model: ATA TOSHIBA MD05ACA8 (scsi)
Disk /dev/sdb: 8002GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 0.00GB 8002GB 8002GB primary raid
(parted) quit
To build a new RAID0 (mirror) with 4 new disks from device sdb
to sde
.
# mdadm --create /dev/md0 --level=0 --raid-devices=4 /dev/sd[bcde]1
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
ext4
has a bug in dealing with areas over 10TB, so initialize it with xfs
.
# mkfs -t xfs /dev/md0
meta-data=/dev/md0 isize=512 agcount=32, agsize=244184192 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=7813894144, imaxpct=5
= sunit=128 swidth=512 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=521728, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
# blkid /dev/md0
/dev/md0: UUID="0aaf1f16-c156-4c09-a481-43f9f630c526" TYPE="xfs"
Add a configuration of auto-mounting to fstab with the UUID specified by blkid
. Create a mount point in advance. In the example, create an empty folder named /DATA
(permission 777).
# vi /etc/fstab
/dev/disk/by-uuid/0aaf1f16-c156-4c09-a481-43f9f630c526 /DATA xfs nosuid,nodev,nofail,x-gvfs-show 0 0
- Unmounting RAID Volumes
- Disabling the fstab mount setting
- Shut down the RAID array
- Check (stop) RAID information
- Set the RAID flag on the disk to OFF【IMPORTANT】
# umount /DATA
# vi /etc/fstab
delete description about auto-mount
# mdadm --stop /dev/md127
# cat /proc/mdstat
Personalities : [raid0]
unused devices: <none>
# mdadm --misc --zero-superblock /dev/sda1 /dev/sdc1 /dev/sdd1
If you forget to turn off the RAID flag and try to format the disk as a normal disk, an error will occur during the formatting process and you will not be able to use the disk again. If you format it normally and it is impossible to turn off the RAID flag and complete the formatting process, you can use it by writing all areas 0 as follows (it will take a long time and put a lot of strain on the disk).
# dd if=/dev/zero of=/dev/sdb
If the RAID array does not start automatically, such as when you move a disk to another machine, enable the services as follows
# mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1 ...
mdadm --scan --detail >> /etc/mdadm.conf
Check the contents of the configuration file and comment out the old ones.
(previously mentioned)
== EOF ==