Detailed tutorial on migrating the home directory to a new partition under Ubuntu

Detailed tutorial on migrating the home directory to a new partition under Ubuntu

When the user's home directory becomes larger and larger, you can consider migrating the home directory to a new partition. How to achieve it? Let me introduce it to you below.

When I installed the system, I followed the online tutorial and allocated 20G space to the /home partition. After using Ubuntu for a while, I found that the disk where /home is located is about to be full, but there is no space to expand the disks where the /home directory is located. I had no choice but to "move". The following is the whole "moving" process:

First, you need a completely blank disk as the target disk and a USB boot disk, and format it with the disk partitioning software that comes with the Ubuntu system.
Disk to start the Ubuntu system.

Mount the target disk (mine is /dev/sda9) to any directory (assuming it is /test)

sudo mount /dev/sda5 /test

Copy all files in the home directory to the directory mounted on the target disk ( Be sure to add -a here, otherwise the owner of the copied file will become root, and the path must be set correctly, otherwise it will cause an infinite loop on the login interface when restarting and you will not be able to enter the graphical interface. )

sudo cp -ar home所在的目錄/* /test

Enter the original system /etc directory and modify the fstab file (note that the fstab file of the original system should be modified, not the fstab file of the boot disk system)

Back up first (backup is a good habit)

sudo cp -a fstab fstab.old

View the uuid of the target disk:

sudo blkid | grep /dev/sda5

insert image description here

Edit the fstab file. The two orange lines in the figure below are where the home directory is mounted. Replace the uuid in the file with the uuid found in the previous step.

sudo gedit fstab

insert image description here

Restart and find that the home directory has changed

insert image description here

Summarize

It is not advisable to blindly copy the methods on the Internet, especially when modifying important system files. Sometimes a wrong command may cause the system to crash. You should develop the habit of backing up files before modifying them, so that you will have room for regret after making mistakes. Try not to reinstall the system as soon as a problem occurs, as it will not solve any problems.

———A newbie who has just started using Linux for more than a week

This is the end of this article about moving the /home directory to a new partition in Ubuntu. For more information about moving the /home directory to a new partition in Ubuntu, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to add a Swap partition on Ubuntu 16.04
  • How to add a swap partition in Ubuntu
  • How to solve the problem of insufficient boot partition space in Ubuntu 16.04
  • Ubuntu is set to automatically mount all hard disk partitions at startup

<<:  jQuery achieves fade-in and fade-out effects

>>:  mysql8.0.11 winx64 installation and configuration tutorial

Recommend

js to realize automatic lock screen function

1. Usage scenarios There is such a requirement, s...

Detailed explanation of Windows time server configuration method

Recently, I found that the company's server t...

TypeScript Enumeration Type

Table of contents 1. Overview 2. Digital Enumerat...

Manual and scheduled backup steps for MySQL database

Table of contents Manual backup Timer backup Manu...

How to write the introduction content of the About page of the website

All websites, whether official, e-commerce, socia...

Provides helpful suggestions for improving website design

<br />Scientifically Design Your Website: 23...

Let you understand the deep copy of js

Table of contents js deep copy Data storage metho...

How to view and terminate running background programs in Linux

Linux task management - background running and te...

Tomcat maxPostSize setting implementation process analysis

1. Why set maxPostSize? The tomcat container has ...

Implementing custom scroll bar with native js

This article example shares the specific code of ...

HTML Marquee character fragment scrolling

The following are its properties: direction Set th...

Detailed explanation of HTML basics (Part 2)

1. List The list ul container is loaded with a fo...

Solve the problem of using linuxdeployqt to package Qt programs in Ubuntu

I wrote some Qt interface programs, but found it ...