文档章节

How to Move Your Home Folder to Another Partition

j
 jims
发布于 2016/07/16 20:13
字数 915
阅读 22
收藏 0

If you have accepted the default option while installing Ubuntu, or that your computer comes with Ubuntu pre-installed, chances are that your Home folder and the system folders all lie in the same partition. This is perfectly fine, but if you want to upgrade your existing Ubuntu version, or reinstall Ubuntu, you won’t be able to preserve your app settings, or even retain your files and documents. One of the good practice is to give the Home folder its own partition, so whatever changes you made to the System folder won’t affect your Home directory, and you can easily upgrade or reinstall Ubuntu with ease.

 

If you want to move your Home folder to another partition, here is how you can do so.

Creating a new partition

Note: You can skip this step if you already has an existing external partition that you can use.

Assuming that your computer has only one hard disk and it contains only one partition. To create a new partition, you have to first obtain a Ubuntu Live CD/USB and boot into it. You can’t partition the hard disk when it is running.

Once you are booted into the Live session, open the app “GParted”. Select the hard disk from the list. It should be labelled something like “sda”.

gparted-select-hard-disk

You should see a number of entries in the list. Select the entry that corresponds to the main partition. It should be the one with the biggest file size and is either in the ext3 or ext4 filesystem format. Right click on it and select “Resize/Move”.

gparted-resize-move-partition

Set the size for the new partition in the “Free Space Following” field. The number is represented in MB, so if you want to set aside 10GB for the new partition, enter “10000”. You will notice that as you enter the number, the number in the “New Size” field will decrease accordingly. My usual practice is to set aside 10GB for the system files and allocate the rest to the Home partition. Click “Resize/Move”.

gparted-set-new-partition-size

Back to the GParted main screen, you should now see a new “Unallocated” entry with the file size that you have set earlier. Right click on it and select “New”. Select “ext4” as the filesystem and click “Add”.

gparted-add-new-partition

Lastly. click the green check button to apply the changes. Depending on your hard disk size, the resizing process might take a long time

gparted-apply-changes

After the process is completed, you should see something like the screen below. Record down the new partition number.

gparted-new-partition-number

Now shut down the live session, remove the live CD/USB and boot up the computer.

Migrating the Home folder

To migrate your current Home folder to an external partition, there are four things that you need to do:

  1. Mount the external partition onto a temporary Home location.
  2. Copy the files from your current Home folder to this temporary Home folder.
  3. Relocate the current Home folder
  4. Mount the new Home folder.

1. Create a temporary Home folder

Open a terminal and type the following:

sudo blkid

This will display the UID of all the partitions. Record down the UUID for the partition that you have created earlier.

ubuntu-get-uid-of-partition

Next, open the fstab file:

sudo nano /etc/fstab

and add the following line to the end of the file.

UUID=xxx-xxxxx-xxxxx   /media/home    ext4          nodev,nosuid       0       2

Replace the UUID with the UUID value of the external partition.

ubuntu-new-entry-in-fstab

Save (Ctrl + o) and exit (ctrl + x) the file.

Next, create a mount point:

sudo mkdir /media/home

and reload the updated fstab.

sudo mount -a

You should now see a “home” folder in the Media directory.

2. Copy the files from your current Home folder to the new Home folder

The next thing we are going to do is to copy all the files from the current Home folder to the new Home folder. You can simply do a “Select all”, “Copy” and “Paste” to transfer all the files to the new Home folder. However, you might be missing out the hidden files and some of the file permissions might not be preserved. A more complete method would be using rsync.

sudo rsync -aXS /home/. /media/home/.

3. Relocate the current Home folder

Once we have set up the new Home folder, we need to remove the existing Home folder to make way for the new Home folder in the external partition. To do that, type the following commands in the terminal:

cd /
sudo mv /home /home_backup
sudo mkdir /home

What the above commands do is to move the existing Home folder to Home_backup, and create an empty Home folder for the new Home folder to mount to.

4. Mount the new Home folder

The last step to complete the migration is to mount the new Home folder as “/home”. To do that, we have to revisit the fstab file again.

sudo nano /etc/fstab

All you have to do is to change the “/media/home” to “/home”. Save and exit the file.

ubuntu-mount-new-home-in-fstab

Lastly, reload the fstab file:

sudo mount -a

That’s it. You have now migrated your Home folder to an external partition.

Optional: removing the Home_backup folder

 

Once you are done with the migration, you can either use the old Home folder as a backup, or remove it to release the storage space. To remove it, use the command:

sudo rm -rf /home_backup

Let us know in the comments if you encountered any difficulty.

本文转载自:https://www.maketecheasier.com/move-home-folder-ubuntu/

共有 人打赏支持
j
粉丝 4
博文 170
码字总数 29865
作品 0
合肥
Mac OS: iMovie and iMovie HD Troubleshooting(英/中)

iMovie and iMovie HD Troubleshooting Disk Partition Format: iMovie project must be created/opened/modified on a Mac OS Extended or Mac OS Extended(Journaled) partition. If not, ......

junwong
2012/03/09
0
0
linux自动挂载远程网盘到本地

sudo vim /etc/fstab 添加如下内容 //192.168.1.110/MyFiles /path/to/mount cifs username=adminz,password=passwordz 服务器端是windows共享目录,或者是linux用samba共享的目录 关于默认权......

lieefu
2016/12/15
31
0
Porteus Kiosk 4.1.0 发布,轻量级 Linux 操作系统

Porteus Kiosk 4.1.0 发布了,Porteus Kiosk 是轻量级的Linux操作系统,它基于 GentooLinux 但却被限制为只允许运行一个应用程序即 Firefox网页浏览器。该浏览器被锁定从而阻止用户去改动设置...

催呀催呀
2016/09/06
2.3K
9
ORACLE SQL总结三:DDL语句

5、DDL语句 5.1 Enable/Disable/Validate/Novalidate 组合特性说明: 是否要求满足约束 Validate Novalidate 已有记录 新增/修改记录 已有记录 新增/修改记录 Enable Yes Yes No Yes Disabl...

yeyelei
2012/07/15
0
0
Ubuntu 添加新分区 并设置挂载点

最近在做Android项目,可是解压根文件系统以后,就报警说硬盘不够。当初设置使用的大小为15G。不过扩展分区还是很方便的。当然首先你得设置添加使用的硬盘大小,这次我一下提高到了30G,看它...

长平狐
2012/08/28
686
1

没有更多内容

加载失败,请刷新页面

加载更多

下一页

设计模式:简单工厂模式(静态共产方法模式)

简单工厂的构成包括三个角色: 1)抽象产品类 2)具体产品类(继承抽闲产品类) 3)工厂类(生产具体产品) 具体代码实现 1、抽象产品类 /** * 抽象类 */public abstract class Car ...

京一
2分钟前
0
0
Lombok使用

1 介绍 Lombok是一个简单的Java库,改工具可以通过注解自动地提供一些方法,简化开发。比如编写POJO时需要为每个属性提供getter()方法和setter()方法,这就可以使用Lombok实现。 2 配置 Lomb...

SuperHeroes
10分钟前
0
0
Confluence 6 删除垃圾内容

属性(profile)垃圾 属性垃圾的定义为,一个垃圾用户在 Confluence 创建了用户,但是这个用户在自己的属性页面中添加了垃圾 URL。 如果你有很多垃圾用户在你的系统中创建了属性,你可以使用...

honeymose
12分钟前
0
0
java虚拟机之内存模型

1. 概述 对于从事 C、C++ 程序开发的人员来说,在内存管理领域,他们既是拥有最高权力的「皇帝」又是从事基础工作的「劳动人民」 --- 既拥有每个对象的「所有权」,又担负着每一个对象生命开...

firepation
15分钟前
0
0
解决linux的-bash: ./xx: Permission denied

解决linux的-bash: ./xx: Permission denied 在linux下执行sh文件时提示下面信息: -bash: ./xx.sh: Permission denied解决:chmod 777 xx.sh 1 2 3 4 Linux chmod +755和chmod +777 ......

DemonsI
26分钟前
0
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部