Moving /home on Ubuntu to a second drive

By: ( +David Herron; Date: January 30, 2018

Tags: Ubuntu

It's common to mount the entire Ubuntu system on one partition on one drive. It's very easy to set that up, simply format an ext4 filesystem for the entire disk, and away we go. How do you transition such a system to have /home on a second drive? The GUI tools don't support doing this, so what do you do? A big consideration is that while logged in you're using /home, and therefore can't delete that filesystem while it's in use.

The presumption is that you've already partitioned and formatted all the drives you'll use in the resulting system. See How to set-up a multi-drive SSD/HDD Ubuntu desktop system

Moving your home folder to another partition in Ubuntu is fairly straight-forward. You may want, as I do, to move /home to another drive, or you may want to set up multiple partitions on one drive, with /home as its own partition.

In this case we're focused on moving the /home partition to a new partion on a second drive. The instructions should work for other scenarios.

$ sudo su -
# cd /
# rsync -aXS /home/. /media/home/.
# mv home home_backup
# mkdir home

This assumes you'd mounted the new partition as /media/home. If not, substitute its mount point in the rsync command. Pay careful attention, because the trailing /. on each path is important to rsync.

What this does is:

  1. duplicate everything in the existing /home into the new partition
  2. Rename the existing /home directory to something else
  3. Make a directory, /home, that will serve as the mount point for the new partition.

Now it's necessary to edit /etc/fstab to change the new partition mountpoint to /home. You may have this in /etc/fstab

UUID=7b9210d7-219f-4fc8-8501-677277a05f19 /home-tmp ext4 errors=remount-ro 0 2

Simply change /home-tmp (or whatever you have) to /home.

Then you run: mount -a and the mountpoint for the new partition will change to /home.

Except that - df -h still shows the new partition mounted as /home-tmp (or whatever you had it mounted as). What happened is that the partition is now mounted at both mountpoints. It's necessary to unmount the old mount:

# umount /home-tmp

At that point the new partition will show in df -h as /home.

The old /home is still on the drive as /home_backup. We did that so that the GUI/X11 environment could still use any open files it had. But we need to log-out, then log-in, so our login session can start using the new /home partition. The rsync command will have ensured everything was copied, and when logged back in you should have the exact same user setup as before.

To remove the old files:

$ sudo rm -rf /home_backup
« Move Windows Laptop to SSD drive without reinstall, for greater performance Moving Docker's files to a custom location »
2016 Election Acer C720 Ad block AkashaCMS Amazon Amazon Kindle Amazon Web Services America Amiga Android Anti-Fascism AntiVirus Software Apple Apple Hardware History Apple iPhone Apple iPhone Hardware April 1st Arduino ARM Compilation Artificial Intelligence Astronomy Asynchronous Programming Authoritarianism Automated Social Posting AWS DynamoDB AWS Lambda Ayo.JS Bells Law Big Brother Big Finish Bitcoin Mining Black Holes Blade Runner Blockchain Blogger Blogging Books Botnet Botnets Cassette Tapes Cellphones China China Manufacturing Christopher Eccleston Chrome Chrome Apps Chromebook Chromebooks Chromebox ChromeOS CIA CitiCards Citizen Journalism Civil Liberties Clinton Cluster Computing Command Line Tools Comment Systems Computer Accessories Computer Hardware Computer Repair Computers Cross Compilation Crouton Cryptocurrency Curiosity Rover Currencies Cyber Security Cybermen Daleks Darth Vader Data backup Data Storage Database Database Backup Databases David Tenant DDoS Botnet Detect Adblocker Developers Editors Digital Photography Diskless Booting Disqus DIY DIY Repair DNP3 Do it yourself Docker Docker MAMP Docker Swarm Doctor Who Doctor Who Paradox Drobo Drupal Drupal Themes DVD E-Books E-Readers Early Computers Election Hacks Electric Bicycles Electric Vehicles Electron Emdebian Encabulators Energy Efficiency Enterprise Node EPUB ESP8266 Ethical Curation Eurovision Event Driven Asynchronous Express Face Recognition Facebook Fake News Fedora VirtualBox File transfer without iTunes FireFly Flickr Fraud Freedom of Speech Gallifrey git Github GitKraken Gitlab GMAIL Google Google Chrome Google Gnome Google+ Government Spying Great Britain Heat Loss Hibernate Hoax Science Home Automation HTTP Security HTTPS Human ID I2C Protocol Image Analysis Image Conversion Image Processing ImageMagick In-memory Computing InfluxDB Infrared Thermometers Insulation Internet Internet Advertising Internet Law Internet of Things Internet Policy Internet Privacy iOS Devices IoT iPad iPhone iPhone hacking Iron Man Iternet of Things iTunes Java JavaScript JavaScript Injection JDBC John Simms Journalism Joyent Kaspersky Labs Kindle Kindle Marketplace Lets Encrypt LibreOffice Linux Linux Hints Linux Single Board Computers Logging Mac Mini Mac OS Mac OS X Machine Learning Machine Readable ID macOS MacOS X setup Make Money Online March For Our Lives MariaDB Mars Matt Lucas MEADS Anti-Missile Mercurial Michele Gomez Micro Apartments Microsoft Military Hardware Minification Minimized CSS Minimized HTML Minimized JavaScript Missy Mobile Applications MODBUS Mondas Monetary System MongoDB Mongoose Monty Python MQTT Music Player Music Streaming MySQL NanoPi Nardole NASA Net Neutrality Node Web Development Node.js Node.js Database Node.js Testing Node.JS Web Development Node.x North Korea npm NVIDIA NY Times Online advertising Online Community Online Fraud Online Journalism Online Photography Online Video Open Media Vault Open Source Open Source Governance Open Source Licenses Open Source Software OpenAPI OpenVPN Paywalls Personal Flight Peter Capaldi Photography PHP Plex Plex Media Server Political Protest Postal Service Power Control Privacy Production use Public Violence Raspberry Pi Raspberry Pi 3 Raspberry Pi Zero Recaptcha Recycling Refurbished Computers Remote Desktop Republicans Retro Computing Retro-Technology Reviews RFID Right to Repair River Song Robotics Rocket Ships RSS News Readers rsync Russia Russia Troll Factory Russian Hacking Rust SCADA Scheme Science Fiction Search Engine Ranking Season 1 Season 10 Season 11 Security Security Cameras Server-side JavaScript Serverless Framework Servers Shell Scripts Silence Simsimi Skype SmugMug Social Media Social Media Warfare Social Networks Software Development Space Flight Space Ship Reuse Space Ships SpaceX Spear Phishing Spring Spring Boot Spy Satellites SQLite3 SSD Drives SSD upgrade SSH SSH Key SSL Stand For Truth Strange Parts Swagger Synchronizing Files Telescopes Terrorism The Cybermen The Daleks The Master Time-Series Database Torchwood Total Information Awareness Trump Trump Administration Trump Campaign Ubuntu Udemy UDOO Virtual Private Networks VirtualBox VLC VNC VOIP Web Applications Web Developer Resources Web Development Web Development Tools Web Marketing Website Advertising Weeping Angels WhatsApp Window Insulation Windows Windows Alternatives Wordpress World Wide Web Yahoo YouTube YouTube Monetization