1

How to convert linux SWAP memory from RAID1 to RAID0?

Start with:
2 exact size swap formatted partitions (/dev/sdc5 and /dev/sdd5) on 2 physically separate disks that are used via Software RAID
(named md127, located /dev/md/s) in RAID 1 (Mirroring)

cat /proc/mdstat

would show for md127 something like:

md127 : active raid1 sdc5[2] sdd5[0]
      7806976 blocks super 1.2 [2/2] [UU]

The task is to use the same:
2 exact size swap formatted partitions (/dev/sdc5 and /dev/sdd5) on 2 physically separate disks that are used via Software RAID
(named md127, located /dev/md/s) in RAID 0 (Striping)

cat /proc/mdstat

would show for md127 something like:

md127 : active raid0 sdc5[2] sdd5[0]
      15613952 blocks super 1.2 64k chunks

Convert SWAP /dev/md/s from RAID1 to RAID0 with mdadm

For this you need to know:

  • the difference between RAID0 and RAID1
  • when the Operating System uses SWAP partition (for ex: when you are about to run out of free available physical memory)
  • how to monitor the memory usage (via a tool like conky)
dankilev
  • 166
  • 8

1 Answers1

1

Please find below a simple way to achieve the requested.
I did not really need help. Mostly sharing to whoever it might help.

To start you may want to check the details of /dev/md/s

sudo mdadm --detail /dev/md/s

Then "grow" the RAID to RAID0.
This will loose one partition, but that's ok with us:

sudo mdadm /dev/md/s --grow --level=0

Then add the missing partition back using the command below. This will temporary change to a RAID4 and convert to RAID0 when completed

sudo mdadm --grow /dev/md/s --raid-devices=2 --add /dev/sdc5

To check progress you could use:

cat /proc/mdstat
dankilev
  • 166
  • 8