Report this

What is the reason for this report?

after using the tutorial for how-to-create-raid-arrays-with-mdadm-on-debian-9, I was left with one step missing

Posted on February 15, 2025

So first off that was one of the best tutorials I have followed, it worked the first time. But I was setting up a data raid1 array and wanted to move my entire /home directory to the new array /mnt.md0/home and removed the old home. I have been unable to find a proper way to mv /home /mnt/md0/home and to delete the /home directory and update the fstab to work. /dev/md0 /mnt/md0 /home ext4 defaults,nofail,discard 0 0



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

Glad the tutorial worked well for you! Before making any changes, make sure you have a backup in case anything goes wrong:

https://docs.digitalocean.com/support/how-do-i-manually-back-up-my-droplet/

Once you have your backup, to move /home to your RAID 1 array you should be able to:

  1. Mount the RAID array (if not already mounted):

    sudo mount /dev/md0 /mnt/md0
    
  2. Copy /home data to the new array while preserving permissions:

    sudo rsync -aX /home/ /mnt/md0/home/
    
  3. Update fstab to mount /home from RAID on boot:

    sudo cp /etc/fstab /etc/fstab.bak
    echo "/dev/md0 /home ext4 defaults,nofail,discard 0 0" | sudo tee -a /etc/fstab
    
  4. Check if /home is on a separate mount:

    df -h /home
    
    • If /home is on a separate partition (e.g., /dev/sdX or another disk), you’ll need to unmount it first before updating fstab.
    • If /home is just part of /, they don’t need to unmount it, and they can proceed with remounting it from the RAID array.

    Before unmounting, make sure that there are no active processes running on /home:

    sudo lsof /home
    

    Once you’ve confirmed that there are no active processes, unmount /home and remount it:

    sudo umount /home
    sudo mount -a
    
  5. Verify everything is working:

    df -h /home
    
  6. Reboot and confirm that /home is properly mounted.

If anything goes wrong, you can revert by restoring from your backup and updating fstab again.

Let me know how it goes.

- Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.