Ubuntu 16.04 用mdadm创建Raid0 P3608 PCI-E SSD

操作系统 Ubuntu16.04.3

操作系统盘:Intel DC S3520 SSDSC2BB480G701 2.5 in. 480 GB SATA III SSD

数据盘:Intel DC P3608 SSDPECME016T401 Half-Height Half-Length 1.6TB PCI-Express SSD

 

parted /dev/nvme0n1
print
rm 1

cat /proc/mdstat

mklabel gpt
mkpart nvme0n1p1 ext4 0% 100%
quit

mkfs.ext4 /dev/nvme0n1p1
sudo mount /dev/nvme0n1p1 /mnt/p1/

sudo parted -l /dev/nvme0n1

lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT

sudo mdadm –create –verbose /dev/md0 –level=0 –raid-devices=2 /dev/nvme0n1p1 /dev/nvme1n1p1
nvme的硬盘用磁盘创建重启后不能自动,需要用分区,而普通的sd磁盘可以

sudo mkfs.ext4 -F /dev/md0

sudo mkfs.xfs -f /dev/md0
注:如果已有其他文件系统创建在此分区,必须加上”-f”参数来覆盖它。

mount -t ext4 /dev/md0 /mnt/md0
mount -t xfs /dev/md0 /mnt/md0

df -h -x devtmpfs -x tmpfs

sudo mdadm –detail –scan | sudo tee -a /etc/mdadm.conf
sudo update-initramfs -u
echo ‘/dev/md0 /mnt/test ext4 defaults,nofail,discard 0 0’ | sudo tee -a /etc/fstab

ove@localhost:/dev$ sudo mdadm –create –verbose /dev/md0 –level=0 –raid-devices=2 /dev/nvme0n1 /dev/nvme1n1
[sudo] password for ove:
mdadm: chunk size defaults to 512K
mdadm: /dev/nvme0n1 appears to be part of a raid array:
level=raid0 devices=0 ctime=Thu Jan 1 08:00:00 1970
mdadm: partition table exists on /dev/nvme0n1 but will be lost or
meaningless after creating array
mdadm: /dev/nvme1n1 appears to be part of a raid array:
level=raid0 devices=0 ctime=Thu Jan 1 08:00:00 1970
mdadm: partition table exists on /dev/nvme1n1 but will be lost or
meaningless after creating array
Continue creating array? y

 

ove@localhost:/mnt/p1$ sudo update-initramfs -u
update-initramfs: Generating /boot/initrd.img-4.4.0-62-generic
W: Possible missing firmware /lib/firmware/ast_dp501_fw.bin for module ast

 

彻底删除RAID.请确保该RAID没有被挂载,否则请先卸载,卸载格式:umount /dev/md0 目录路径

停止运行RAID command: mdadm -S /dev/md0

删除自动配置文件
将/etc/mdadm/mdadm.conf文件中关于该md0的配置信息删除即可,这个方式有很多种。由于我的配置信息中只有一个RAID,所以我选择将文件清空。
command: cat /dev/null > /etc/mdadm/mdadm.conf

删除元数据
以前我一直以为删除来配置文件就算彻底结束了,可是再重启的话还是可以在/dev下找到md设备,后来发现是没有将RAID分区中的元数据删除。

command:mdadm –zero-superblock /dev/nvme0n1p1,对于其他分区格式也一样。

至此,该software RAID已经彻底删除,重启后也不会自动安装了。

 

mdadm /dev/md0 –fail /dev/sdb –remove /dev/sdb
mdadm /dev/md0 –fail /dev/sdc –remove /dev/sdc
mdadm /dev/md0 –fail /dev/sdc –remove /dev/sdd
mdadm /dev/md0 –fail /dev/sde –remove /dev/sde
mdadm /dev/md0 –fail /dev/sdf –remove /dev/sdf

mdadm –stop /dev/md0
mdadm –remove /dev/md0

清除成员磁盘当中阵列的超级块信息

mdadm –misc –zero-superblock /dev/sdb
mdadm –misc –zero-superblock /dev/sdc
mdadm –misc –zero-superblock /dev/sdd
mdadm –misc –zero-superblock /dev/sde
mdadm –misc –zero-superblock /dev/sdf