Article Title: Adjust partitions when the system is working. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
In this new tip set, Daniel Robbins explains how to change the partition layout on a running system. He also introduced several tips to minimize the downtime and avoid serious errors. In this article, he will explain how to move/home to another partition.
/Home is one of the most moving partitions. In some cases, all space in/home is used up, and a hard drive needs to be added. In other cases,/home is set as part of the root partition. To improve performance or facilitate backup, you may need to move it elsewhere. I will describe how to move/home safely and effectively in each case.
Warning
The following technique explains how to move one or more partitions. Although the design of this technology enables you to "undo" failed partition movement, it does not prevent user errors. In other words, as long as you format a partition or copy a large number of files, a large amount of data may be damaged due to incorrect input. Therefore, it is strongly recommended that you take appropriate measures to back up all important files before proceeding.
Now you are ready to move/home. The exact steps you want to complete depend on whether/home is currently residing in its own separate partition or on the Root partition. Note this when we complete the following steps (I will remind you if necessary ). If you are moving/home to a new hard drive, the drive should now be physically installed in your system.
1. Create a New partition if necessary
If you are moving/home to an existing partition (there is no need to be an ext2 file system, as long as the target primary partition or extended partition exists, you can directly go to step 2.
If the new partition does not exist, use cfdisk (preferred) or fdisk to create a new partition. If this partition is not on the first drive, do not forget to specify the device name as the first parameter of cfdisk or fdisk. After creating an appropriate primary partition or extended partition, restart the system to read the Partition Table correctly. This is the only time to restart the system.
2. Create a file system on the new partition
To create a file system in a new partition, you must first know the accurate device name of the new partition (for example,/dev/sda5 ). If you cannot determine the exact device name, stop immediately and check the device name carefully. Then, enter the following command as root:
# Mkfs. ext2/dev /--?
In the above and later code samples, replace the --? With the target partition name --?. After executing this command, the target partition will contain an empty ext2 file system.
3. Mount the new file system under/mnt
Create a directory named/mnt/newpart and mount the new partition to this directory:
# Mount/dev /--? /Mnt/newpart
4. Enter the single-user mode
To maximize the availability of the system, I try to postpone this step, but now we have to enter single-user mode and then copy the files in/home to/mnt/newpart. You should not open any file in/home, but enter single-user mode to eliminate this possibility:
# Init 1
If a prompt is displayed, enter the root password to execute the system maintenance task. You should be in root shell now.
[1] [2] Next page