Question

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

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


Submit an answer


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!

Sign In or Sign Up to Answer

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.

Bobby Iliev
Site Moderator
Site Moderator badge
February 16, 2025

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

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

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.