Hi Craig,
Thanks a lot. I referenced your idea and finally extend it recently.
Here is full commands for others who might need to do in the future.
Assuming /dev/sdb and /dev/sdc are existing 4TB drive, and we are going to add /dev/sdd which is 8TB drive
Code
==================================================
Simulate current status in Windows
==================================================
1. open disk management to create vhdx
$diskmgmt.msc
2. get DiskPath of vhdx by
$wmic diskdrive list brief
3. $wsl --mount <DiskPath> --bare
==================================================
Simulate current status in WSL2
==================================================
1. Check it's detected
$lsblk -ap
2. Format with gdisk, mark them as fd00 (Linux Raid)
$sudo gdisk /dev/sdb
$sudo gdisk /dev/sdc
3. Create Raid 1
$sudo mdadm --verbose --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
4. Check mdadm progress
$sudo mdadm --detail /dev/md0
$cat /proc/mdstat
5. Format new md0
$sudo mkfs -t ext4 /dev/md0
6. Mount
$sudo mkdir -p /mnt/md0
$sudo mount -t ext4 /dev/md0 /mnt/md0
7. Write some file to test
==================================================
Start real processing in WSL2, Stop FTP, SMB, all service except SSH in WebGui first
==================================================
1. Now, mount new drive, format with gdisk, mark it as 8300 (Linux Filesytem), so we can copy from /mnt/md0 to /dev/sdd
$sudo gdisk /dev/sdd
$sudo mkfs -t ext4 /dev/sdd1
2. Mount sdd
$sudo mkdir -p /mnt/sdd1
$sudo mount -t ext4 /dev/sdd1 /mnt/sdd1
3. Copy data from old md0 device to sdd
$sudo rsync -avh --progress /mnt/md0/ /mnt/sdd1/
Choose either 4-1 or 4-2, I use 4-2 in the end
4-1. Convert md0 to Raid 0, will be slow because it will convert to Raid 4 first
$sudo mdadm --grow --level=0 /dev/md0
4-1-A. Check which disk is removed by previous step, add it back to md0
$sudo mdadm --detail /dev/md0
$sudo mdadm --grow --level=0 /dev/md0 --raid-devices=2 --add /dev/sdc1
4-2. Another faster way is to create a new md0
$df -h, find all location using /dev/md0, and umount them
$sudo mdadm --stop /dev/md0
$sudo mdadm --verbose --create /dev/md0 --level=0 --raid-devices=2 /dev/sdb /dev/sdc
5. Create md1 which is Raid 1 with missing, because you have to create ext4 later
$sudo umount /mnt/md0
$sudo mdadm --verbose --create /dev/md1 --level=1 --raid-devices=2 /dev/md0 missing
$sudo mkfs -t ext4 /dev/md1
6. Copy all files to md0
$sudo mount -t ext4 /dev/md1 /mnt/md1
$sudo rsync -avh --progress /mnt/sdd1/ /mnt/md1/
7. Unmount and format sdd, convert sdd to raid, add it back to md1
$sudo umount /mnt/sdd1
$sudo gdisk /dev/sdd
$sudo mdadm --manage /dev/md1 --add /dev/sdd1
8. Update the path of fsname and mount directory in /etc/openmediavault/config.xml
$sudo vim /etc/openmediavault/config.xml
<mntent>
<fsname>/dev/md1</fsname>
<dir>/srv/MYRAID</dir>
9. Edit /etc/fstab to make sure it mount /mnt/md1, options are copied from existing entry created by openmediavault previously
$sudo vim /etc/fstab
/dev/md1 /srv/MYRAID ext4 defaults,nofail,user_xattr,noexec,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0,acl 0 2
10. Done. And if someday need to replace one disk, use /dev/md0 for example
$sudo mdadm --manage /dev/md1 --fail /dev/md0
$sudo mdadm --manage /dev/md1 --remove /dev/md0
$sudo mdadm --manage /dev/md1 --add <new device>
Trouble shooting:
$sudo mdadm --details
$sudo cat /proc/mdstat
$sudo fdisk -l
$sudo mdadm --assemble --scan
$sudo df -h
==================================================
Original thought which will failed because md0 has smaller size than md1
(possibly to fix by ensuring all device doesn't reserve any space at head and end)
==================================================
1. Now, mount new drive, format with gdisk, mark it as fd00 (Linux Raid)
$sudo gdisk /dev/sdd
2. Create Raid 1 with missing parameter
$sudo mdadm --verbose --create /dev/md1 --level=1 --raid-devices=2 /dev/sdd1 missing
$sudo mkfs -t ext4 /dev/md1
$sudo mkdir -p /mnt/md1
$sudo mount -t ext4 /dev/md1 /mnt/md1
3. Copy data from old md0 device to new md1 device
$sudo rsync -avh --progress /mnt/md0 /mnt/md1
4. Edit /etc/fstab to make sure it mount /mnt/md1
5. Convert md0 to Raid 0
$sudo mdadm --grow --level=0 /dev/md0
6. Add the disk which was removed in previous step back to md0
$sudo mdadm --grow /dev/md0 --raid-devices=2 --add /dev/sdb1
7. Logout and login again. Then add md0 to md1. Error happen because md0 has smaller size than md1 (because md0 is consist of 2 devices while md1 is only one device currently)
Alles anzeigen