recreate raid1 on swap after upgrading disks

159 views
Skip to first unread message

Gilles Martinoty

unread,
Dec 9, 2020, 12:09:21 PM12/9/20
to Alt-F
Hello,
I've decide to upgrade my 2x2 To disks to 2x4 To disks. My problem has been that it is a situation where a lot has to be modified: metadata 0.9 are not fine, I would like to keep a partition for Alt-f, and the swap has to be twice as big.
I think that  I've done the right things so far: with the partionner, I created a "swap" on the first partition, and then I used the partionner to create a RAID sdb2 partition and a small sdb4 partition for Alt-f. I created /dev/md1 by adding sdb2 to it. When rebooting, I had the problem of a 16-byte mismatch between the superblock and the filesystem, which I solved with "mkfs.ext4 /dev/md1".

So far so good, I have :
/dev/md1 as a degraded raid ;
/dev/sdb4 as a ext4 partition for Alt-f ;
/dev/sdb1 as swap.

However, I would like the swap to be on top of RAID1, like it was before, in order to avoid any crash in case of one disk failure. I don't know what I should do to achieve that. I would like it as /dev/md0.
In addition, there seems to be a problem with the previous RAID1 swap, as /dev/md0 still exists, but is "inactive". See my screenshots. If I "start" it, it shows /dev/sda1 in it, with a size of 0.5 Gb (which is the case). But I cannot "destroy" it: /dev/md0 disappears on the disk but it's still shown in the webUI.

Could you please help me move forward, as I'm stuck at this step?
Thank you for your help and best regards.
Gilles


Capture-2.jpg
Capture-4.jpg
Capture-3.jpg
Capture-5.jpg
Capture-1.jpg

João Cardoso

unread,
Dec 9, 2020, 2:27:15 PM12/9/20
to Alt-F

From the screen shots I believe that you have broken your previous RAID into two fs, have sda2 with your data, have replaced the old 2TB with a new 4TB disk (sdb) created a degraded RAID1 md1 with sdb2 (you are at this point), you intend to copy from sda2 to the degraded RAID md1, replace the 2TB (sda) with a 4TB disk (luckily it will be sda, check that first), and finally add sda2 to md1. Right?
All this can be done using the webUI (notice that copying such huge amounts of data using the webUI will be slower than copying using the command line).

I'm afraid that you will have to resort to the command line to create swap over RAID. This is because swap is not a filesystem (not handled in Disk->Filesystem) and at "conception" time it was considered a resource waste to have swap over RAID on underpowered systems (I have meanwhile partly changed my mind and now offer that possibility in Disk->Utilities, and also Disk->Wizard creates swap over RAID1 when RAID is selected by the user).

So, in your current situation:

swapoff -a  # stop all active swap
sed -i '/swap/d' /etc/fstab # remove swap entries from fstab

mdadm --zero-superblock /dev/sda1 # remove RAID info
mdadm --zero-superblock /dev/sdb1

# hypothetical next two steps, it depends on
# 'cat /proc/mdstat', 'ls /dev/md0', 'ls /dev/md', 'mdadm --detail /dev/md0'  output
mdadm --stop /dev/md0 # this might fail if the device node does not exists
rm /dev/md0 # or the device node might still exists

mdadm --create /dev/md0 --run --level=1 --raid-devices=2 missing /dev/sdb1 # create degraded md0 with sdb1
mkswap /dev/md0 # create swap itself on md0
echo "/dev/md0 none swap pri=1 0 0" >> /etc/fstab # update fstab
swapon -a -p1 # activate all fstab swap entries

At this point a degraded md0 RAID swap built from sdb1 should exist and be active.
When you finally add the 2nd 4TB disk (sda, check it) with sda1 as a swap partition, all you need to do is:

mdadm /dev/md0 --add /dev/sda1 

I think this is it.

PS: attaching The System Configuration log file from System->Utilities, View Logs supplies all (and more) info than the one supplied in the screen shots.

Gilles Martinoty

unread,
Dec 12, 2020, 5:22:53 PM12/12/20
to Alt-F
Hello,
Yes, you had understood everything I had done so far, and everything i was planning to do!
What you described worked well for the swap, and I added the second drive for rebuilding both raid partitions. It has just finished without any problem.
So my system is completely up and running, with 2x 4TB hard drives in raid1 configuration, and swap also in raid1. My previous alt-f and entware configurations are still on sda4, working perfectly.
Thank you again so much for your help.
Gilles

Reply all
Reply to author
Forward
0 new messages