How to Move Home Directory to New Partition or Disk in Linux

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

27 Responses

  1. David says:

    Thank you; simplest explanation of this I have found.

  2. Mitch says:

    Aaron, your procedure worked great! I installed and partitioned a Western Digital 1TB external USB drive (/dev/sdb) and created 1 partition (sdb1) with 500GB (the rest I left as free space). Using your procedure, I moved my /home directory and am successfully mounting it via /etc/fstab.

    However, this did not solve the problem that I’m having. I have an internal 250GB drive (/dev/sda) that is still being reported by the df command as having 0 free disk space available.

    Do you have any insights as to why this is happening on my Linux box (Debian 8)? I have checked lsof and found mainly files being held open by the systemd and X11 processes. df also sees that /home is now mounted on /dev/sdb1. I was expecting that the 660+MB /home to show as free. I have also shutdown hoping that any processes preventing the space on /dev/sda from being freed would release it.

    I was hoping to attach files with the output from df and parted -l but do not see any way of doing this. If you can add any suggestions or point me in any directions, i would appreciate your help. Once I get this issue solved I will probably use this process to create a second partition on /dev/sdb and move my /var to it as you mention in your article.

    Thanks in advance,
    Mitch

    • Aaron Kili says:

      @Mitch

      Did you delete the old home directory on /dev/sda after moving home to /dev/sdb? You can use this guide, to find directories and files consuming space on /dev/sda: https://www.tecmint.com/find-top-large-directories-and-files-sizes-in-linux/.

      • Mitch says:

        Aaron, Tried to recycle an old 1TB WD drive to use for /home and /var, it crashed! Bought a WD easy store portable USB 2TB drive for $59.00 and implemented using your procedure.

        Everything worked flawlessly. I now have Debian upgraded to 9.0, with /dev/sdb1 (500GB) as /home, /dev/sdb2 (750GB) as /var and /dev/sdb3 (750GB) as /tmp. /dev/sda (250GB) as the system/boot device with only 1% used. I should be good to go for a long time. The old /dev/sdba with everything physically on it lasted for 2 years.

        I modified your procedure by 2 steps for each /home, /var and /tmp. /srv has /home, /var and /tmp in it. When it came to the step to rm (/home/*, /var/* and /tmp/*) I renamed (mv) those directories to /-hold until I tested with root and user logins. This gave me the safety net of recovering easily if I needed to. Then I created new /home, /var and /tmp directories to mount to. In the end I removed the *-hold directories.

        Thank you for your article and help. This is a GREAT site, I’ve looked at your other suggested articles … all are of the highest quality. I WILL be bookmarking this site for future reference.

        Mitch

  3. Mike says:

    Newbie here, and wanting to isolate my data and worked very well, just for the info “rm -rf /home/*” failed initially because I had Nemo open there and “diff -r /home /srv/home” showed a few files in the “Trash“.

  4. Marc says:

    Nice HowTo !

    thanks you very much.

  5. jimG says:

    Saved me hours! Great writing!

  6. Maury Lee says:

    Very clear, elegant, simply, and it worked, first try for me. I had watched 20 videos and all kinds of complex ways to do this. I was sure there was a simpler method, but couldn’t find one. Then I found this post. WOW, is all I can say. Saved my a lot of trouble and fixed my no room on /root problem. THANK YOU SO MUCH!

  7. Nahuel Iglesias says:

    If you’re not using LVM this method is OK, but I’d strongly suggest stopping any service that allows users login or access in any way to the contents in /home wile the task is being executed. Think sshd, httpd (if allowing ~user), ftp. If possible, ‘telinit 1’ is the safest choice (in fact, it is a MUST if moving /var to another disk/partition).
    Bottom line: use LVM for a happier life :-)

    • Aaron Kili says:

      @Nahuel

      “but I’d strongly suggest stopping any service that allows users login or access in any way to the contents in /home wile the task is being executed.” – so true, actually forgot to mention this in the guide. Many thanks for the head up.

  8. Manu says:

    Hi Mate,

    That we can use LVM concept at here that make easy to manage filesystems ?plz advice.

  9. Alexey says:

    Thank you for your article, a very detailed explanation.

    But I have one question about the content of the /home folder after remounting on /dev/sdb1.

    As far as I understand, in the beginning you created /srv/home folder and then copy the content from /home folder to the /srv/home. After that you checked the difference between them by using diff tool.

    Then you removed everything inside of the /home and unmounted /srv/home.

    Everything is clear at this stage.

    And next, you remounted again /home to a new HDD /dev/sdb1.

    But in my opinion, in that case the new /home folder is empty since you removed the content of this folder earlier and didn’t copy the content from /srv/home to this /home before this mounting.

    What did I miss here?

    Thank you!

    • Aaron Kili says:

      @Alexey

      Yes, the new /home folder is empty since its content was removed earlier on. Remember we copied it into the /srv/home directory which was mounted to /dev/sdb1. Meaning the content was stored in the space on /dev/sdb1; here /srv/home only acted as the mount point.

      A mount point like /srv/home or /home is simply a directory from which we can access a filesystem space such as /dev/sdb1.

      Then we unmounted /srv/home but still the content is present on /dev/sdb1, finally we mounted /dev/sdb1 to /home which is the new mount point.

      I know it’s a little confusing but reading through the mount command manual page will help you understand better.

  10. Flavio says:

    Thanks for your great article! I’m a newbie so I have a question: why you partitioned the second hard drive in two partitions and why you have chosen to format the second one in xfs?

    Flavio

    • Aaron Kili says:

      @Flavio

      We have created two partitions with different filesystem types for demonstration purposes. You can choose to create one partition on the new disk depending on your needs.

      Thanks.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.