New Computer + old system: Teach you how to transfer Linux between different machines

Source: Internet
Author: User

Technology is growing so fast that you don't have to be surprised if you find that you frequently change your computer or computer accessories. For example, you may want to buy a brand new notebook or replace your hard drive. In these cases, if you can easily port your operating system to a new computer or hard disk, everything will be perfect.

However, if you are using Windows, this will be a great challenge, especially when you want to reactivate the system. In Linux, there will be a lot of pressure. In fact, there are many ways to port Linux, but I am only planning to recommend the simplest one I think.

Recommended reading:

[Linux tutorial] theoretical basics of Linux

[Linux tutorial] using DOS/Windows disks in Linux

Ubuntu 13.04 text tutorial on hard drive installation in Windows 7

New Installation

The most common "porting" method is to reinstall Linux on your new computer and copy all your files. Although this is the most common practice, I recommend that you do this only when you cannot connect two hard disks to one computer, whether you want to move the system to a new computer or a new hard disk. When backing up your personal files, you should focus on the/home,/etc,/opt,/root,/var folders. The desktop user should mainly look at the/home directory because there are all his personal files. Server users should focus on checking/etc and/var, because there are configuration files and managed data.

Record installation packages


Debian-based releases can easily List Installed packages on the system and write them into files. This list can be used for new systems to reinstall them. You only need to enter

Sudo dpkg-get-selections>/home/[your user name]/packagelist.txt

(Change [your user name] To your user name here) to create this list file. Copy the file to the new system, and then enter

Sudo dpkg-set-selections

This marks all the packages that have been installed in the system before you run

Sudo apt-get-u dselect-upgrade

These packages will be installed. It will install these packages from the official sources, and the software you are familiar with will be back soon. Don't forget to restore the files you backed up to the corresponding folder, and your Linux "porting" plan will be declared successful!

Copy Partition


If you can connect two hard disks to the same machine, you can easily copy the entire Linux partition to the new hard disk. This method makes the system better maintain its original appearance after transplantation, because you do not have to reinstall the system and the required package. In addition to two hard disks that have been successfully connected to the same machine in some way, you also need a DVD or USB that has been burned to any Linux release.
For example, a DVD/USB that burns an Ubuntu ISO file is quite good. Then, go to the live environment and open Gparted. You only need to select the partition you want to copy, copy it, and paste it on the new hard disk. When copying to a large hard disk, You can resize it after transplantation. However, if the size of the new hard disk is small, you must resize it before moving it. Once the copy and paste operations are completed, enter commands in sequence to install and start the boot guide program to the new hard disk. Enter:

Sudo mount/dev/sdX #/mnt

Sudo mount-bind/dev/mnt/dev

Sudo mount-bind/proc/mnt/proc

Sudo cp/etc/resolv. conf/mnt/etc/resolv. conf

Sudo chroot/mntgrub-install/dev/sdX

You must replace x with the drive number of the new hard disk and # With the Partition Number of the new system on the new hard disk. This information can be found in some disk management applications on the Dash board. Now install the new hard disk back to the original machine, and then start your Linux. After entering your system, you need to run

Sudo update-grub

To ensure that GRUB correctly identifies each system on each hard disk. This step is especially important if you have another operating system such as Windows on your hard disk.

Summary

We hope these two methods will allow you to easily and efficiently transplant Linux to a new hard disk or computer. If you follow the above instructions, there will be no problems. If you have any questions or need help, please comment below this article. I will do my best to help you.

Have you ever ported Linux? Do you think the above methods are difficult? Leave a message in the comment to let us know!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.