ubuntu16.04使用 raid0切换到raid5

官方说的raid0是可以在不删除数据的情况下切换到raid5的,没有成功,各种报device busy ;
最后是把数据全部删除并格式化后再做的raid5;本文采用的是storcli64做的,也可以用madam未做尝试。
1.查看raid状态 可以看到当前磁盘的raid情况,如下如所示,就是一个raid5的样例

#查看raid卡信息, 回显信息中的“Ctl”一列所对应的数字即为RAID卡的ID,
如下命令行回显信息表中所示,该RAID卡的ID为“0”。
$ storcli64 show
Status Code = 0
Status = Success
Description = None

Number of Controllers = 1
Host Name = PR2012GS21903150001
Operating System  = Linux4.4.0-148-generic

System Overview :
===============

------------------------------------------------------------------------------------
Ctl Model                   Ports PDs DGs DNOpt VDs VNOpt BBU  sPR DS EHS ASOs Hlth
------------------------------------------------------------------------------------
  0 AVAGOMegaRAIDSAS9361-8i     8  12  12     0  12     0 Msng On  -  Y      3 Opt
------------------------------------------------------------------------------------
#Description = Show Diskgroup Succeeded
$ storcli64 /c0/dall show
#显示某一块raid卡的版本、功能、状态、以及raid卡下的物理磁、逻辑盘信息,信息比较多
$ storcli64 /c0 show all
Controller = 0
Status = Success
Description = none
TOPOLOGY :
========
----------------------------------------------------------------------------
DG Arr Row EID:Slot DID Type  State BT      Size PDC  PI SED DS3  FSpace TR
----------------------------------------------------------------------------
 0 -   -   -        -   RAID0 Optl  N  12.732 TB dflt N  N   none N      N
 0 0   -   -        -   RAID0 Optl  N  12.732 TB dflt N  N   none N      N
 0 0   0   8:0      14  DRIVE Onln  N  12.732 TB dflt N  N   none -      N
 1 -   -   -        -   RAID0 Optl  N  12.732 TB dflt N  N   none N      N
 1 0   -   -        -   RAID0 Optl  N  12.732 TB dflt N  N   none N      N
 1 0   0   8:1      10  DRIVE Onln  N  12.732 TB dflt N  N   none -      N
 2 -   -   -        -   RAID0 Optl  N  12.732 TB dflt N  N   none N      N
 2 0   -   -        -   RAID0 Optl  N  12.732 TB dflt N  N   none N      N
 2 0   0   8:2      21  DRIVE Onln  N  12.732 TB dflt N  N   none -      N
 3 -   -   -        -   RAID0 Optl  N  12.732 TB dflt N  N   none N      N
 3 0   -   -        -   RAID0 Optl  N  12.732 TB dflt N  N   none N      N
 3 0   0   8:3      11  DRIVE Onln  N  12.732 TB dflt N  N   none -      N
 4 -   -   -        -   RAID0 Optl  N  12.732 TB dflt N  N   none N      N
 4 0   -   -        -   RAID0 Optl  N  12.732 TB dflt N  N   none N      N
 4 0   0   8:4      16  DRIVE Onln  N  12.732 TB dflt N  N   none -      N
 5 -   -   -        -   RAID0 Optl  N  12.732 TB dflt N  N   none N      N
 5 0   -   -        -   RAID0 Optl  N  12.732 TB dflt N  N   none N      N
 5 0   0   8:5      15  DRIVE Onln  N  12.732 TB dflt N  N   none -      N
 6 -   -   -        -   RAID0 Optl  N  12.732 TB dflt N  N   none N      N
 6 0   -   -        -   RAID0 Optl  N  12.732 TB dflt N  N   none N      N
 6 0   0   8:6      17  DRIVE Onln  N  12.732 TB dflt N  N   none -      N
 7 -   -   -        -   RAID0 Optl  N  12.732 TB dflt N  N   none N      N
 7 0   -   -        -   RAID0 Optl  N  12.732 TB dflt N  N   none N      N
 7 0   0   8:7      13  DRIVE Onln  N  12.732 TB dflt N  N   none -      N
 8 -   -   -        -   RAID0 Optl  N  12.732 TB dflt N  N   none N      N
 8 0   -   -        -   RAID0 Optl  N  12.732 TB dflt N  N   none N      N

DG=Disk Group Index|Arr=Array Index|Row=Row Index|EID=Enclosure Device ID
DID=Device ID|Type=Drive Type|Onln=Online|Rbld=Rebuild|Dgrd=Degraded
Pdgd=Partially degraded|Offln=Offline|BT=Background Task Active
PDC=PD Cache|PI=Protection Info|SED=Self Encrypting Drive|Frgn=Foreign
DS3=Dimmer Switch 3|dflt=Default|Msng=Missing|FSpace=Free Space Present
TR=Transport Ready

2.将raid拆除

$ storcli64 /c0/v0 del
就是拆除了v0的raid0操作,如果有多个的话,逐个删除就好了storcli64 /c0/vx del

3.将所有的raid0拆除后可以通过fdisk -l 查看有多少块盘,raid5的话至少要有3块盘才能去做,一块盘挂了,还能通过另外两块盘恢复数据;raid5的命令如下

$ storcli64 /c0 add vd type=raid5 drives=8:0-7 pdcache=off WT direct
通过 storcli64 /c0 show all 
----------------------------------------------------------------------------
DG Arr Row EID:Slot DID Type  State BT      Size PDC  PI SED DS3  FSpace TR
----------------------------------------------------------------------------
 0 -   -   -        -   RAID5 Optl  N  50.937 TB dsbl N  N   dflt N      N
 0 0   -   -        -   RAID5 Optl  N  50.937 TB dsbl N  N   dflt N      N
 0 0   0   8:0      9   DRIVE Onln  N   7.276 TB dsbl N  N   dflt -      N
 0 0   1   8:1      12  DRIVE Onln  N   7.276 TB dsbl N  N   dflt -      N
 0 0   2   8:2      11  DRIVE Onln  N   7.276 TB dsbl N  N   dflt -      N
 0 0   3   8:3      10  DRIVE Onln  N   7.276 TB dsbl N  N   dflt -      N
 0 0   4   8:4      15  DRIVE Onln  N   7.276 TB dsbl N  N   dflt -      N
 0 0   5   8:5      17  DRIVE Onln  N   7.276 TB dsbl N  N   dflt -      N
 0 0   6   8:6      16  DRIVE Onln  N   7.276 TB dsbl N  N   dflt -      N
 0 0   7   8:7      13  DRIVE Onln  N   7.276 TB dsbl N  N   dflt -      N
----------------------------------------------------------------------------
pdcache 虚拟驱动器上的当前磁盘高速缓存策略设置为on
direct 设置逻辑驱动器高速缓存策略,默认是direct
WT 也是和缓存有关系的这个是直接写到内存中所以叫write through 直写,WB是仅写到缓存中当缓存被替换时再写回到内存中所以叫write back 写回

这样raid5就做好了。格式化并挂载后就可以使用了。

#不同的文件格式使用不同的后缀名去格式化,本例是ext4
$ mkfs.ext4 /dev/sda 

挂载到某个目录就可以使用了,挂载时要注意挂载目标文件夹是空的无进程使用的,不然挂载了也不能使用

$ mount /dev/sda /mnt/data

4.给现有的raid通过新增新的硬盘实现扩容

$ storcli64 /c0/v1 start migrate type=raid5 option=add drives=8:15-23

说明:c0一般指的是raid控制器的编号,v1代表的是逻辑分区的概念
执行过程中未成功,出现了migrate剩余时间为16天多很多小时的情况。
意外:
在执行过程中由于硬盘编号不是连续的,在执行的时候出现了invaid pds的错误;
可以这么使用:

$ storcli64 /c0 add vd type=raid5 drives=8:0-13,15-23 pdcache=off WT direct

你可能感兴趣的:(ubuntu16.04使用 raid0切换到raid5)