0

I am about to buy a new computer. I will be installing Ubuntu 16.04 on it obviously :P

In my mind, I have the following plan for migrating to the new computer. I would like advice as to how easy/sensible this is:

I will buy a new computer with an SSD but no traditional hard drive. The idea would be to install Ubuntu on the SSD. But, I would also like to install the hard drive from my old computer.

The idea would be to have the Ubuntu system files on the SSD, but also retain all my stuff (i.e. user files) from the old computer's hard disk without having to do a complicated copy/reformat process.

I guess there would be some non-standard configuration to do (ie mounting "/home" on the old HD).

I have installed Ubuntu before, but only ever with the default options. I should also say the existing hard disk is a single partition and has ubuntu system files as well as /home, but I guess after completing the installation I could simply remove the old Ubuntu system stuff from the disk (... i.e. everything except "/home"?).

How easy would this be to achieve? Are there any pitfalls to be aware of?

1
  • What you describe sounds like a reasonable approach. Just make sure you have a backup of your important data, just in case...
    – Byte Commander
    Sep 5, 2016 at 11:38

1 Answer 1

1

First make sure you have a reliable backup of all your important files!

Make sure the user IDs (UID/GID) on the new system will match the ones on the old one, so you do not have to change the ownership of all the files in the old /home directory (getent passwd <username> will give you the information). In newer Ubuntu sytems, UIDs of new users will start with 1000.

As the old /home directory is not a partition but a directory you cannot mount the old partition (say /dev/sdb1) at the new /home and be done. But with some manual correction this is not that difficult.

Assuming the old disk is connected when you install the new Ubuntu on the ssd, one possible way could be:

Say the new SDD is on /dev/sda and the old disk on /dev/sdb. Start the installation of Ubuntu (from CD or USB) as usual, up to the partitioning of the disks. Maybe the installer tells you about already mounted partitions; let it unmount them for you.

Select "manual" in the upcoming dialog to override default in partitioning. Then select the new disk (pay attention to select the corrct one; should be sda1 here, but you may make sure from the size of the disk). If there is no partition table yet, let the installer create one. Select the "FREE SPACE" then and select "Automatically partition the free space". Now you will be given two new partitions on /dev/sda (/ and swap). Leave them as they are.

Then select the partition on the old disk your data are on (usually primary partition on sdb, ext4 formatted). In partition settings, select "Use as" and select the filesystem already on the disk (usually ext4).

In the partition settings now MAKE SURE in the option "Format the partition:" "No, keep existing data" is selected. Otherwise you might lose all your data!

Select "Mount point", and in the upcoming dialog, select "/home". Then select "Done setting up the partition". You will be returned to the partitioning dialog; here you should again control the partitioning thoroughly. Up to now, nothing has been done to the disks. If everything is as expected, select "Finish partitioning and write changes to disk", then after again controlling the suggested actions, say "Yes" to "Write changes to disk?". This will affect your disks, so better look twice before! There must be no formatting on partitions of your old disk!

At the end of the installation process, you will be ask where to install the boot loader. Select your SSD (/dev/sda). There will also be a GRUB menu which will let you select and start your old system (as long as it is not deleted from disk).

After finishing the installation process and logging in to the new system, your old "/" will be mounted to /home, and for the user you created there will be a new subdirectory. Additional, all directories of your old system will be there as subdirectories, and your old /home as /home/home. Now just sudo mv /home/home/<username> to /home/<username>(or if there are more than one users, sudo mv /home/home/* /home) and your done.

If the default user you created during installation has the same name (and therefore the same name of the home directory) as one of your old users, this will not be possible for this user, as there is a new user directory with the same name created. So it is best to create the default user with a different name and correct this after having moved the user's home. I also assume that you have no user named after the system directories like /bin, /tmp, /usr..., as these directories of the old system still exist in /home. You may later on (re)move them, if everything works OK.

There is one additional problem in this approach: You will reuse all the old user configurations (as in .cache, .config and the like). Maybe there will be some weird behaviour especially when using the GUI (like unity, gnome, ..) and new versions of software.

1
  • Nice, detailed answer. As it happened I installed Ubuntu before adding the extra hard disk - I was a bit worried about getting the HD formatting/partitioning options right. Then, I used a combination of your answer, plus info in this link help.ubuntu.com/community/Partitioning/Home/Moving to correct mount the /home partition in /etc/fstab. Now working great, thanks!
    – Steve
    Sep 11, 2016 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.