国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
Step 1: Identify the Added New Drive
Step 2: Create a New Partition in Linux
Step 3: Format a New Partition in Linux
Step 4: Mount New Partition in Linux
Step 5: Copy Home Directory Files to New Partition
Step 6: Create a New Home Directory and Mount Drive
Step 7: Permanent Partition Mount in Linux
Home System Tutorial LINUX How to Convert a /Home Directory to Partition in Linux

How to Convert a /Home Directory to Partition in Linux

Jul 04, 2025 am 09:09 AM

This topic might seem a bit peculiar. I mean, why should you convert your home directory into a separate partition?

Whenever you are installing Linux, the installer already selects the ‘guided‘ partitioning by default. When you go with this option, the installer places the home directory plus all the other system directories under the root ( / ) partition.

While this setup works quite well, it presents a huge risk. If your system crashes or something corrupts the root partition, all your personal files residing in the home directory are lost.

For this reason, it is important to create a separate home partition during installation. This guarantees the safety of your personal files during reinstallation of an operating system or in case the root partition crashes.

If you accepted the default option while partitioning your hard drive such that all our directories fall under the root partition, then this guide is for you.

In this guide, we will transfer the home directory to a separate partition on a newly added disk. For demonstration purposes, we will use a removable USB drive to serve the purpose of an additional drive. In the real world, this could be an SSD drive or an additional HDD that you want to be the home partition.

Let’s begin!

Step 1: Identify the Added New Drive

Before plugging in the removable drive, we only have a single hard drive (/dev/sda) with a home folder and all the system partitions mounted on the / or root partition.

Here is a glance of your hard drive configuration using the df command.

$ df -Th

How to Convert a /Home Directory to Partition in Linux

Next, we will plug in the 8GB removable USB drive. This is identified as /dev/sdb and is mounted on the /media/tecmint/USB mountpoint.

To confirm this, we will run the lsblk command.

$ lsblk

How to Convert a /Home Directory to Partition in Linux

The partition and mountpoint might vary according to your setup. For instance, a third drive will be indicated as /dev/sdc, a fourth one /dev/sdd and so on.

Step 2: Create a New Partition in Linux

We have newly added our second drive to our system, but in order to use it as a separate partition for our home directory, we need to create a partition on it. At the moment it doesn’t have one since it is a new drive.

The fdisk command confirms it as shown.

$ sudo fdisk -l

How to Convert a /Home Directory to Partition in Linux

In the highlighted section, you can see that the new drive does not have any partition associated with it unlike the first drive which has /dev/sda1, /dev/sda2, and /dev/sda5.

Now, we will create a partition using the command:

$ sudo fdisk /dev/sdb

When prompted, press 'n' to create a new partition. Then press 'p' to specify the creation of a primary partition, and hit '1' to specify the partition number. For the next two prompts, hit ‘ENTER‘ to accept the defaults in specifying the first and last sectors.

Since my removable drive comes with the NTFS filesystem, I will remove it by pressing 'Y'. To save all the changes made, press 'w', as this writes all the changes made to the partition.

How to Convert a /Home Directory to Partition in Linux

To confirm the changes made, once again, run the command:

$ sudo fdisk /dev/sdb

When prompted, press 'p' for print. This prints out the partition’s information. From the output, you can see that a new partition /dev/sdb1 has been created with Linux as the filesystem type. We need to format it to the ext4 filesystem type which we will do so in the next section.

How to Convert a /Home Directory to Partition in Linux

Step 3: Format a New Partition in Linux

The next step is to format the /dev/sdb1 partition using the ext4 filesystem format. Take note that we are formatting /dev/sdb1 (the partition) and not /dev/sdb which is the removable drive.

$ sudo mkfs.ext4 /dev/sdb1

How to Convert a /Home Directory to Partition in Linux

Step 4: Mount New Partition in Linux

For the drive to be accessible to the system, we need to mount it on the system’s filesystem. But first, we will create a mount point on which we will mount the partition.

$ sudo mkdir -p /srv/home

Next, we will mount the partition on the mountpoint as follows. This, in effect, makes the drive available to the system.

$ sudo mount /dev/sdb1 /srv/home

To confirm this, run the df command as shown:

$ sudo df -Th

How to Convert a /Home Directory to Partition in Linux

Step 5: Copy Home Directory Files to New Partition

We now need to copy the contents of the home directory to the mount point which is now located on the drive. So, we will run the command:

$ sudo cp -aR /home/* /srv/home/

Just to confirm that everything went all we will check the contents of the home directory.

$ ls -l /srv/home/tecmint

From the output, you can clearly see that all the default directories expected to be in the home directory are present.

How to Convert a /Home Directory to Partition in Linux

Step 6: Create a New Home Directory and Mount Drive

We now need to create another home directory on which we will mount our home partition. To avoid confusion, we will rename our current home directory to /home.bak shown.

$ sudo mv /home /home.bak

Next, we will create a new home directory.

$ sudo mkdir /home

We will then unmount the /dev/sdb1 filesystem and mount it to the newly created home directory

$ sudo umount /dev/sdb1
$ sudo mount /dev/sdb1 /home

To confirm that the /home directory contains the default directories, we will navigate into and list its contents:

$ cd /home
$ ls -l tecmint

How to Convert a /Home Directory to Partition in Linux

Additionally, you can verify that our filesystem is mounted on the /home mount point using the df command as follows.

$ sudo df -Th /dev/sdb1

How to Convert a /Home Directory to Partition in Linux

The output confirms that the /dev/sdb1 filesystem on our drive is mounted on the /home partition. However, this will not survive a reboot. To make this persistent, an additional step is required and that is to modify the /etc/fstab file with the filesystem information.

Step 7: Permanent Partition Mount in Linux

To automatically ensure that the filesystem is mounted every time upon system startup, we are going to modify the /etc/fstab file. But first, let us get the UUID of the filesystem as follows.

$ sudo blkid /dev/sdb1

How to Convert a /Home Directory to Partition in Linux

Copy and paste the UUID somewhere on a text editor as this will be used in the next step.

Next, open the /etc/fstab file.

$ sudo vim /etc/fstab 

Append this line to the file as shown. Replace the uid in the square brackets with the actual UUID of the /dev/sdb1 filesystem that you copied and pasted earlier on the text editor.

UUID=[ uid ]     /home	   ext4	   defaults	0	2

How to Convert a /Home Directory to Partition in Linux

Save the changes and close the file. Then run the following command to mount all the partitions.

$ sudo mount -a

Now, your drive will be mounted every time on system startup on the /home partition.

$ df  -h /dev/sdb1

How to Convert a /Home Directory to Partition in Linux

To avoid going through all these steps, it’s always advised to have a separate home partition from the rest of the system partitions during installation in order to separate your personal files from system files. This makes it easy to recover your data should something go wrong.

The above is the detailed content of How to Convert a /Home Directory to Partition in Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SCP Linux Command – Securely Transfer Files in Linux SCP Linux Command – Securely Transfer Files in Linux Jun 20, 2025 am 09:16 AM

Linux administrators should be familiar with the command-line environment. Since GUI (Graphical User Interface) mode in Linux servers is not commonly installed.SSH may be the most popular protocol to enable Linux administrators to manage the servers

Gogo - Create Shortcuts to Directory Paths in Linux Gogo - Create Shortcuts to Directory Paths in Linux Jun 19, 2025 am 10:41 AM

Gogo is a remarkable tool to bookmark directories inside your Linux shell. It helps you create shortcuts for long and complex paths in Linux. This way, you no longer need to type or memorize lengthy paths on Linux.For example, if there's a directory

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux Jul 05, 2025 am 09:25 AM

LXD is described as the next-generation container and virtual machine manager that offers an immersive for Linux systems running inside containers or as virtual machines. It provides images for an inordinate number of Linux distributions with support

NVM - Install and Manage Multiple Node.js Versions in Linux NVM - Install and Manage Multiple Node.js Versions in Linux Jun 19, 2025 am 09:09 AM

Node Version Manager (NVM) is a simple bash script that helps manage multiple Node.js versions on your Linux system. It enables you to install various Node.js versions, view available versions for installation, and check already installed versions.NV

How To Install R Programming Language in Linux How To Install R Programming Language in Linux Jun 23, 2025 am 09:51 AM

R is a widely-used programming language and software environment designed for developing statistical and graphical computing tools within data science. It closely resembles the S programming language and environment, with R serving as an alternative

How to choose a Linux distro for a beginner? How to choose a Linux distro for a beginner? Jun 19, 2025 am 12:09 AM

Newbie users should first clarify their usage requirements when choosing a Linux distribution. 1. Choose Ubuntu or LinuxMint for daily use; programming and development are suitable for Manjaro or Fedora; use Lubuntu and other lightweight systems for old devices; recommend CentOSStream or Debian to learn the underlying principles. 2. Stability is preferred for UbuntuLTS or Debian; you can choose Arch or Manjaro to pursue new features. 3. In terms of community support, Ubuntu and LinuxMint are rich in resources, and Arch documents are technically oriented. 4. In terms of installation difficulty, Ubuntu and LinuxMint are relatively simple, and Arch is suitable for those with basic needs. It is recommended to try it first and then decide.

7 Ways to Speed Up Firefox Browser in Linux Desktop 7 Ways to Speed Up Firefox Browser in Linux Desktop Jul 04, 2025 am 09:18 AM

Firefox browser is the default browser for most modern Linux distributions such as Ubuntu, Mint, and Fedora. Initially, its performance might be impressive, however, with the passage of time, you might notice that your browser is not as fast and resp

Clear Linux Distro - Optimized for Performance and Security Clear Linux Distro - Optimized for Performance and Security Jul 02, 2025 am 09:49 AM

Clear Linux OS is the ideal operating system for people – ahem system admins – who want to have a minimal, secure, and reliable Linux distribution. It is optimized for the Intel architecture, which means that running Clear Linux OS on AMD sys

See all articles