多块大于2T硬盘构建RAID

前言

Ubuntu18.04系统下,2块4T硬盘构建RAID,挂载起来并做简单的磁盘读写测试。
我目前了解的Linux下构建大容量存储池有三种方式,mdadm、LVM、ZFS。这三种之间的优劣后续继续研究。本例使用mdadm。

参考

mdadm创建RAID
https://cloud.tencent.com/developer/article/1346533
https://www.jianshu.com/p/f087257665d3
格式化大于2T的硬盘
https://blog.csdn.net/u012150360/article/details/81333051

格式化硬盘

通常格式化硬盘使用fdsik命令,由于单个硬盘大于2T的时候这个命令便无法使用。需要使用parted命令给硬盘标记为gpt再创建分区和格式化
1)找到需要挂载和格式化的硬盘。

$lsblk
loop24   7:24   0   151M  1 loop /snap/gnome-3-28-1804/36
sda      8:0    0 111.8G  0 disk 
|-sda1   8:1    0   512M  0 part /boot/efi
|-sda2   8:2    0     1K  0 part 
`-sda5   8:5    0 111.3G  0 part /
sdb      8:16   0   3.7T  0 disk 

2)选择要格式的硬盘设备

$ parted /dev/sdb 
$ sudo parted /dev/sdb 
[sudo] password for yh01: 
GNU Parted 3.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)  

3)建立GPT磁盘标签

(parted) mklabel gpt
(parted) 

4)创建分区并退出parted

(parted) mkpart primary xfs 1 -1
(parted) print                                                            
Model: ATA TOSHIBA MG04ACA4 (scsi)
Disk /dev/sdb: 4001GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  4001GB  4001GB  xfs          primary

(parted) quit

5)格式化硬盘

$ sudo mkfs.ext4 /dev/sdb1 
mke2fs 1.44.1 (24-Mar-2018)
Creating filesystem with 976754176 4k blocks and 244195328 inodes
Filesystem UUID: dfa51066-1826-425f-bade-7940625aae3c
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
    102400000, 214990848, 512000000, 550731776, 644972544

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (262144 blocks): 
done
Writing superblocks and filesystem accounting information:            
done

使用mdadm创建RAID

以创建RAID 0为例
1)创建raid 0 的虚拟盘md0

sudo mdadm --create --verbose /dev/md0 --level=0 --raid-devices=2 /dev/sdb1 /dev/sdc1
$ cat /proc/mdstat 
Personalities : [raid0] [linear] [multipath] [raid1] [raid6] [raid5] [raid4] [raid10] 
md127 : active raid0 sdc1[1] sdb1[0]
      7813769216 blocks super 1.2 512k chunks
      
unused devices: 

2)格式化虚拟盘md0

sudo mkfs.ext4 -F /dev/md0

3)开机挂载,推荐使用UUID进行挂载

查看设备uuid
$ sudo blkid |grep md
/dev/md127: UUID="6390e5d3-6b14-4fb7-bac2-061791fef320" TYPE="ext4"
echo "UUID=6390e5d3-6b14-4fb7-bac2-061791fef320 /mnt ext4 defaults 0 0" >> /etc/fstab

至此软RAID0的构建完成。推荐测试,

虚拟盘简单读写测试

参考上篇

你可能感兴趣的:(多块大于2T硬盘构建RAID)