没有不值得去解决的问题,也没有不值得去学习的技术!

Ubuntu Disk Planning: Migrate /home to a Second SSD

Figure 10 – New partition information (UUID, label, file system)

1. Background and Goal

My ThinkPad T570 has two SSDs:

  • sda (238G): The original Windows 10 F drive, now with Ubuntu installed.
  • sdb (953G): The original Windows 10 data drive (C/D/E), entirely composed of NTFS partitions.

Goal: Wipe the second, high-capacity SSD, format it to the Linux ext4 file system, and mount it as the /home partition. This way, all personal files (Desktop, Downloads, Documents, configurations, etc.) will reside on the high-capacity drive, and the system drive will never fill up.

2. Check Current Disk Layout (Command Line)

Open the terminal (Ctrl+Alt+T) and enter the following command to view the disks and partitions:

Bash
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT

The output looks like this:

Plaintext
sda    238.5G disk
├─sda1     1G part vfat     /boot/efi
└─sda2 237.4G part ext4     /
sdb    953.9G disk
├─sdb1   260M part vfat
├─sdb2    16M part
├─sdb3 300.1G part ntfs
├─sdb4   290G part ntfs
├─sdb5    10G part vfat
├─sdb6 352.5G part ntfs
└─sdb7  1000M part ntfs

You can see that:

  • sda is the system drive, which already has Ubuntu installed (/ and /boot/efi).
  • sdb is the data drive, which still has 7 residual Windows partitions (NTFS, EFI, recovery partitions, etc.).

Our next step is to wipe the entire sdb drive and then create a new ext4 partition to serve as /home.

3. Optional: Back Up Files You Want to Keep on sdb

If you have old photos, documents, or other files on sdb that you need to keep, copy them to your home directory first:

Bash
mkdir ~/old_backup_from_sdb

Then open /run/media/你的用户名/ using the graphical file manager, locate the files you need, and copy them to ~/old_backup_from_sdb.

If you do not have any files you need on sdb, you can skip the backup.

4. Using the GParted Partition Tool (Graphical)

GParted is a graphical partition editing application. It is more intuitive than the command line and very beginner-friendly.

4.1 Install GParted

Bash
sudo apt update
sudo apt install gparted -y

4.2 Launch GParted

Bash
sudo gparted

After entering your password, the GParted main window will open. The first thing you see is the status of the system drive /dev/sda, as shown in Figure 1.

Figure 1 – Partition layout of the system drive /dev/sda in GParted

4.3 Switch to the Second Hard Drive /dev/sdb

In the drop-down menu in the upper right corner of the GParted window, select /dev/sdb (capacity approximately 953.87 GiB). You will now see all the original Windows partitions on /dev/sdb, as shown in Figure 2.

Figure 2 – Original Windows partitions on the data drive /dev/sdb

4.4 Delete All Old Partitions

Perform the following steps for each partition in turn:

  1. Right-click the partition → select Unmount (if the partition is already mounted).
  2. After unmounting, right-click again → select Delete.

Once you have performed “Unmount → Delete” on multiple partitions, GParted will list all pending operations, as shown in Figure 3.

Figure 3 – Confirming the partition deletion operations

After right-clicking, you might find that some partitions cannot be deleted and need to be unmounted first, as shown in Figure 4.

Figure 4 – After right-clicking, you might find that some partitions cannot be deleted and need to be unmounted first

⚠️ Common Issue: “Cannot unmount, target busy” Prompt During Deletion

When unmounting certain partitions (such as /dev/sdb6), the error shown in Figure 5 might pop up: “Cannot unmount, target busy”.

Figure 5 – Unmount failed with "target busy" prompt

This happens because a program is currently using the partition (usually because the file manager has it open). Check the taskbar or file manager windows, find the corresponding volume, and close it. For example, Figure 6 shows a window named “379 GB Volume”; simply close it.

Figure 6 – Partition currently in use within the file manager

If that still does not work, you can force unmount it in the terminal:

Bash
sudo umount /dev/sdb6

Then return to GParted to continue unmounting and deleting.

Repeat the above steps until all partitions in /dev/sdb are deleted. Eventually, the entire disk will show as “Unallocated”, as shown in Figure 7.

Figure 7 – After deleting all partitions, the disk shows as "Unallocated"

4.5 Create a New ext4 Partition

Right-click the “Unallocated” space → New, and the dialog box shown in Figure 8 will appear.

Figure 8 – Create new partition dialog box (parameter settings)

Fill in the following parameters:

OptionValue
Free space preceding1 MiB (default, cannot be changed)
New sizeKeep the maximum value (e.g., 976761 MiB)
Free space following0 MiB
Align toMiB
File systemext4
Labelhome (customizable, English recommended)
Partition nameLeave blank

Click Add → then click the green checkmark Apply on the toolbar. GParted will ask you to confirm again, as shown in Figure 9.

Figure 9 – Confirming the apply partition creation operation

Click Apply, wait a few seconds, and the new partition will be created.

4.6 Record the New Partition’s UUID

Right-click the newly created /dev/sdb1 → Information, and the window shown in Figure 10 will pop up.

Figure 10 – New partition information (UUID, label, file system)

Copy the UUID from it, for example:

Plaintext
d24cf7c9-f6a9-49dd-bf37-62ed9bb0ffb0

Important: Save this UUID to a temporary text file (for example, using vi uuid.txt to record it); it will be used in later steps.

5. Migrate /home to the New Partition

5.1 Mount the New Partition to a Temporary Directory

Bash
sudo mkdir -p /mnt/newhome
sudo mount /dev/sdb1 /mnt/newhome

5.2 Copy All Data from the Current /home

Bash
sudo rsync -avxP /home/ /mnt/newhome/
  • -a: Archive mode (preserves permissions, timestamps, etc.)
  • -v: Display detailed information
  • -x: Do not cross file system boundaries
  • -P: Show progress and support resume

The copy time depends on the amount of data in /home, usually taking a few to over ten minutes.

5.3 Replace /home with the New Partition

Bash
sudo mv /home /home.old          # 把旧的 /home 改名为备份
sudo mkdir /home                 # 创建新的空 /home 目录
sudo mount /dev/sdb1 /home       # 临时挂载新分区到 /home

5.4 Set Up Automatic Mount at Boot

Edit the /etc/fstab file:

Bash
sudo vi /etc/fstab

If you are not familiar with vi, you can use nano: sudo nano /etc/fstab.

Move the cursor to the end of the file, press o (to create a new line and enter insert mode), and enter the following content (replace UUID=... with the UUID you recorded):

Plaintext
UUID=d24cf7c9-f6a9-49dd-bf37-62ed9bb0ffb0 /home ext4 defaults 0 2

Save and exit:

  • vi: Press Esc, type :wq, and press Enter
  • nano: Press Ctrl+O and Enter to save, then press Ctrl+X to exit

5.5 Test the Mount Configuration

Bash
sudo mount -a
df -h /home

If the output shows /dev/sdb1 and the capacity is about 938G (or close to 953G), the configuration is correct.

6. Restart and Clean Up

6.1 Restart the Computer

Bash
sudo reboot

If you are prompted with “Operation inhibited” during restart, you can force a restart:

Bash
sudo systemctl reboot -i

6.2 Verify the Mount

After restarting and logging in, run the following again:

Bash
df -h /home

It should still show /dev/sdb1.

6.3 Delete the Old /home.old Backup (Free Up System Drive Space)

Bash
sudo rm -rf /home.old

Make sure the new /home is working properly (Desktop, Documents, etc. are all present) before performing the deletion.

7. Final Result

  • System drive /dev/sda2 (root directory /): Stores only the system and software, taking up very little space (e.g., 14G)
  • Data drive /dev/sdb1 (mount point /home): Stores all user files, with a capacity of nearly 1TB
  • The disk layout is clean, without any junk partitions

8. Common Beginner Issues and Solutions

8.1 How Do I Paste Commands into the Terminal?

  • Keyboard shortcut: Ctrl + Shift + V (not Ctrl+V)
  • Middle mouse button: After selecting text, press the scroll wheel to paste

8.2 sudo gedit /etc/fstab Shows “Command Not Found”?

Newer versions of Ubuntu no longer pre-install gedit; please use vi or nano, as mentioned above.

8.3 Constantly Prompted with “Target Busy” When Deleting Partitions?

  • Close all file manager windows (Nautilus)
  • Execute sudo umount /dev/sdbX in the terminal (X is the partition number)
  • If it still does not work, restart the computer and then execute sudo gparted

8.4 sudo mount -a Reports an Error?

  • Check whether the UUID in /etc/fstab is correct (pay attention to letter case and hyphens)
  • Use sudo blkid /dev/sdb1 to confirm the correct UUID, then re-edit fstab

9. Subsequent Optimizations (Optional, I Did Not Perform the Following Operations)

  • Enable automatic SSD TRIM (improves lifespan):
Bash
  sudo systemctl enable fstrim.timer --now
  • Check if swap is working properly:
Bash
  swapon --show
  free -h
  • Organize home directory: After moving the files previously backed up in ~/old_backup_from_sdb to directories like ~/文档 and ~/Develop, delete that backup folder.

10. Summary

By following these steps, you have successfully configured the second SSD as an independent /home partition. The entire process does not require an external drive for backup (the old /home is kept as /home.old), and you can roll back even if an operation goes wrong. Now you can safely store movies, games, code, and other projects in /home without ever worrying about the root partition filling up.

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系