Skip to main content
Home
The Baheyeldin Dynasty
The journey for wisdom starts with knowledge
  • Home
  • About
  • Site Map
  • Contact

How To Migrate Old Linux Computer Disk To A New Computer

  1. Home

By Khalid on 2025/08/07 - 21:07, last updated 2025/08/07 - 21:10

Like many people, I need to upgrade from the used laptop that I am using, to a newer (still used) laptop. This is usually every 3 years or so.

Because I don't want to install the operating system that I use (Xubuntu Linux) from scratch when doing so, I used to remove the disk in the old computer, and install it in the new one, and things would work right away, with all my applications still there, and my desktop the way it is when I shutdown the older computer.

But sometimes, this method is not practical. For example, if the particular laptop is hard to open, or when the old and new disks are of different technologies (e.g. old computer has a SATA SSD, and the new one has an NVMe drive.

In this case, I need to copy the old computer's disk to the new computer's disk.
The easiest way to do this, without having to open the computers, and disconnect disks and such, is over a local area network (LAN).

But there are several steps involved. Here is an overview:

  • Connect both computers to your router using Ethernet.
  • Boot both computers from a live Linux drive (e.g. USB drive).
  • From the terminal, dump the old disk to a pipe over the network.
  • Fix the partition table using gdisk.
  • Resize the root partition using GParted.

The rest of this article details the steps outlined above.

Security Notice

Before you start, you should be aware that doing this requires a LAN that is well protected from outside threat, like port scanners, bots, scans, penetration attempts and the like.

If your LAN is not well protected from outside threats threats, then you can use ssh instead of nc with minor modifications.

Connect Both Computers To Your LAN Over Ethernet

You can do the copy over WiFi, but any wired technology would be more stable and consistent over wireless protocols.

So, you need two Ethernet cables, one for each computer.

If your laptop lacks an Ethernet port, you need to get a USB to Ethernet Adapter.

Boot From A Live Linux Image

Because we will be copying the main disk of the old computer, we need this disk to be quiescent and not having any activity on it. To do so, we need to boot the computer from a Live Linux Image.

You can use any Live Linux Image that you are familiar with. In my case, I use the Xubuntu Live Image from a USB drive.

Once you have a desktop on each of the computers, start a terminal program.

Find Out The IP Address Of The New Computer

From the terminal, enter this command:

ip a

The output from this command will be very verbose, but you want the Ethernet interface (usually starts with enpxxxx), and to look for a line that starts with something like:

inet 192.168.0.123/24 ....

The number after the word 'inet' and before the '/' character is the IP address of the new computer.

So in this case, it is 192.168.0.123.

Start The Listener, With Disk Dump

Then, you need to start a pipeline to consume the data from the LAN, and dump it to the disk.
We add gzip so that the data is compressed, and less time is taking copying the data.

nc -l -p 9999 |
  gzip -d |
  dd bs=10M conv=fsync status=progress of=/dev/nvme0n1

The port we will use is 9999.

Send The Old Computer's Disk Data To The New Computer

On the source machine (the older one that we will be copying from), you will need the IP address from the steps above, and the port:

DEST_IP=192.168.0.123
DEST_PORT=9999

dd bs=10M status=progress if=/dev/sda |
  gzip -c -9 |
  nc $DEST_IP $DEST_PORT

Depending on the size of the disks, this will take over an hour.
In my case, 500GB took 1 hour 41 minutes.

Fix The Partition Table

You then need to fix the partition table using gdisk, on the new computer.

Execute the following command:

sudo gdisk /dev/nvme0n1

Then enter the following:

Command (? for help): w
Warning! Secondary header is placed too early on the disk! Do you want to
correct this problem? (Y/N): Y
Have moved second header and partition table to correct location.

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sdc.
The operation has completed successfully.

Resize The Root Partition

Then run GParted, which should be available if you use the Xubuntu Live Image or a similar version.
From there, you should resize the root partition and make all the unallocated space part of it.

This article by Wolfgang Ziegler shows screenshots of how to do this.

And that is it ... you are done.

Reboot your new computer and you should have the exact same desktop, applications, data and everything.

Contents: 
Linux
Tags: 
Ubuntu
  • Add comment

Current

Pandemic

  • COVID-19
  • Coronavirus

Search

Site map

Contents

  • Family
    • Khalid
    • Ancestry
    • Extended
  • Friends
  • Nokat نكت
  • Writings
    • Cooking
    • Culture
    • Science
    • History
    • Linguistics
    • Media
    • Literature
    • Politics
    • Humor
    • Terrorism
    • Business
    • Philosophy
    • Religion
    • Children
  • Technology
    • Linux
    • Arabization
    • Drupal
      • Association
    • Software
    • Internet
    • Technology in Society
    • Digital Archeology
    • NCR History
    • MidEast Internet
    • Programming
    • Saudi ISPs
    • Miscellaneous
  • Places
    • Canada
      • Weather
    • Egypt
      • Cuisine
      • Alexandria
      • E.G.C.
    • USA
    • Saudi Arabia
  • Interests
    • Astronomy
    • Fishing
    • Photography
    • Snorkeling
    • Nature
    • Photomicroscopy
  • Miscellany

In Depth

  • al-Hakim bi Amr Allah: Fatimid Caliph of Egypt الحاكم بأمر الله
  • Alexandria, Egypt
  • Arabic on the Internet
  • Articles on the history of Muslims and Arabs in the Iberian Peninsula تاريخ المسلمين و العرب في الأند
  • DIY GOTO Telescope Controller With Autoguiding and Periodic Error Correction
  • E.G.C. English Girls College in Alexandria, Egypt
  • Egyptian Cuisine, Food and Recipes مأكولات مصرية
  • George Saliba: Seeking the Origins of Modern Science?
  • Internet Scams and Fraud
  • Mistaken for an Arab or Muslim: Absurdities of being a victim in the War on Terror
  • Mistaken Identity: How some people confuse my site for others
  • One People's Terrorist Is Another People's Freedom Fighter
  • Overview of Google's Technologies
  • Photomicroscopy
  • Pseudoscience: Lots of it around ...
  • Resources for using Google Adsense with Drupal
  • Rockwood Conservation Area, Southern Ontario
  • Selected Symbolic Novels And Movies
  • Snorkeling the Red Sea near Jeddah
  • Updates and Thoughts on the Egyptian Revolution of 2011

Recent Content

Most recent articles on the site.

  • How To Migrate Old Linux Computer Disk To A New Computer
  • wrtbwmon: A Bandwidth Monitoring Tool for OpenWRT Routers
  • Ancestry - Paternal Side
  • Evidence Against Ivermectin Efficacy For COVID-19
  • Origin Of COVID-19: Natural Spillover, Lab Leak Or Biological Weapon?
more

Most Comments

Most commented on articles ...

  • Another scam via Craigslist: offering more than asking price
  • Warning to female tourists thinking of marrying Egyptians
  • Craigslist classified for used car: Cheque fraud scam
  • Winning the lottery scam email: World Cup South African lottery
  • Email Scam: BMW 5 Series car and lottery winning
more

About Khalid

Various little bits of information ...

  • Khalid Baheyeldin: brief biography
  • Presentations and Talks
  • Youtube Videos
  • GitHub Projects
  • Drupal.org Profile
  • Astrophotography @ Flickr

Sponsored Links

Your Link Ad Here

Tags

Android Mobile Ubuntu Sony OnStep OpenWRT Router Ericsson COVID-19 Rogers Coronavirus Arabic Kubuntu Home Assistant GSM Telescope tablet Spectrum Scam Python 419 Laptop Firefox DIY CPU Conspiracy Comet Balkanization backup App
More

© Copyright 1999-2025 The Baheyeldin Dynasty. All rights reserved.
You can use our content under the Terms of Use.
Please read our privacy policy before you post any information on this site.
All posted articles and comments are copyright by their owner, and reflect their own views and opinions, which may not necessarily be consistent with the views and opinions of the owners of The Baheyeldin Dynasty.

Web site developed by 2bits.com Inc.