0

Got the following scenario in a two-disk RAID1 (mdadm) Debian-based server (no LVM involved):

Partitions (same for mirror /dev/sdb):

  • Unassigned space (formerly /dev/sda1 with Windows).
  • /dev/sda2 linux-raid /dev/md0 (/)
  • /dev/sda3 extended:
    • /dev/sda5 linux-raid /dev/md1 (swap)
    • /dev/sda6 linux-raid /dev/md2 (/home)
    • /dev/sda7 linux-raid /dev/md3 (/usr/local/share/data)

Ideally, for the sake of disk space, I would like to achieve:

  • /dev/sda1 linux-raid /dev/md0 (/).
  • /dev/sda2 linux-raid /dev/md1 (/home)
  • /dev/sda3 extended:
    • /dev/sda5 linux-raid /dev/md2 (swap)
    • /dev/sda6 linux-raid /dev/md3 (/usr/local/share/data)

Following a (at first sight) simpler approach I'm also willing to try:

  • /dev/sda1 linux-raid /dev/md0 (/) (hoping mdadm --grow /dev/md0 --size=max command will be able to auto-take care of occupying the unused space before)
  • /dev/sda3 extended:
    • /dev/sda5 linux-raid /dev/md1 (swap)
    • /dev/sda6 linux-raid /dev/md2 (/home)
    • /dev/sda7 linux-raid /dev/md3 (/usr/local/share/data)

All of which I assume it has to be done offline (i.e. by means of a live distro).

What I'm not sure (regarding the first approach) is whether I have firstly to fully dismiss the RAID1 array and then to hard-copy the partitions one by one, then re-create the RAID1 or there is another simpler approach.

I would like to know your experience / suggestions regarding both / other approaches.

  • 2
    start using LVM-2, don't multiply MDs needlessly. – poige Nov 26 '18 at 10:55
  • I don't need LVM-2 by now as I'm not intending (yet) to expand storage size. Plus, adding LVM right now would imply formatting the whole disks. But I'm curious about you stating to not multiply MDs needlessly, so I kindly ask you: is there something wrong with having several /dev/mdX devices? – Antonio López Nov 26 '18 at 12:45
  • 1
    Yet, would you have used LVM-2 previously, it would have been very easy to add /dev/sd[ab]1 to a new md device and include it in the VolumeGroup and you would have been done. And you are actually expanding storage size right now. – silmaril Nov 26 '18 at 13:47
0

(almost) Live migration should be possible, granted you don't need to resize volumes.

  • Create a new md on /dev/sd[ab]1:
    • mdadm --create device=servername:root --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
  • Rsync your / on this md
    • mount /dev/md/root /mnt/target
    • mount /dev/md0 /mnt/source
    • rsync -avr /mnt/source /mnt/target
  • chroot new root edit fstab and reinstall bootloader:
    • mount -t proc /mnt/target/proc
    • mount -t sysfs /mnt/target/sys
    • mount -t udev /mnt/target/dev
    • chroot /mnt/target
    • [edit fstab with new root device]
    • [reinstall bootloader]
  • reboot the system (and pray you didn't forget anything)

After reboot you should be on the new root md device (check with /proc/mounts), and then you only have to repeat the process to use /dev/md0 partition for the /home mountpoint.

As for merging sd[ab]6 and sd[ab]7, then it will depend on how many free space you have on the other partitions, as you will need to delete and recreate them.

Personnally i would suggest to use the opportunity to migrate onto an LVM-based system: * create new md * create new VolumeGroup on md * create new Volume "root" on VG * go on with the previous steps.

And then progressivelly add the freed md devices space onto the volumegroup, create volumes for the next partition, copy data and restart the process for next partition

  • Excellent! I'll try that. Could I even do the mount/rsync stuff on the running system? – Antonio López Nov 27 '18 at 9:29
  • Obviously ! the mount/rsync can be done live – silmaril Nov 29 '18 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.