• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Clone Linux disk partition over network using dd

By admin

In this tutorial, we will show you how to clone Linux harddisk partition over a network, in this tutorial we will use dd command. For the guys who don’t know what dd is – it is a command-line utility for Unix and Unix-like operating systems whose primary purpose is to convert and copy files.

Clone Linux harddisk has advantages because we don’t need to reinstall and configure again the applications especially in Linux that we used as a server.

Prerequisites

This article assumes you have at least basic knowledge of Linux, know how to use the shell, root user or non-root user account with sudo privileges set up on your server.

For other prerequisites :

  • Linux with network interface.
  • Make sure 2 linux have same storage size.
  • Both 2 linux has been booted using rescue OS or other live OS , so you not boot using installed OS in the disk.

We will use description for our example:

Source

server-A : /dev/sda

Destination

server-B : /dev/sda

Warning: Make sure all command below are executed under your rescue’s operating system.

1. Clone disk partition using dd over SSH

To clone entire Linux disk partition using dd over ssh from server-A to server-B. Let’s assume you use root user.

Run this command in server A (source):

# dd bs=16M if=/dev/sda | ssh root@serverB "dd bs=16M of=/dev/sda"

If you want to clone some partition only, just choose the partition you want to clone like these command below, for example, we will clone /dev/sda3 partition

Run this command in server A (source):

# dd bs=16M if=/dev/sda3 | ssh root@serverB "dd bs=16M of=/dev/sda3"

2. Clone disk partition using dd over telnet with bzip compression

Clone using telnet and bzip has advantages to reduce clone time, but make sure you use a secure network.

Lets assume server-B has ip address 192.168.100.2. Run this command in server B (destination):

# nc -l -p 19000 | bzip2 -d | dd bs=16M of=/dev/sda

Run this command in server A (source):

# dd bs=16M if=/dev/sda | bzip2 -c | nc 192.168.100.2 19000

Based on these 2 commands above we will connect to server-B using port 19000.

Conclusion

You can choose 2 kinds of the method above, clone disk partition over a network is useful when you need to migration from different datacenter with same disk storage space.

Filed Under: Linux

Some more articles you might also be interested in …

  1. CentOS / RHEL 5, 6 : how to disable NetworkManager
  2. Unable To Boot Up Linux OS with Auditd (CentOS/RHEL)
  3. How to change the default permissions on /var/log/audit/audit.log file in CentOS/RHEL
  4. Using iostat to monitor system performance in Linux (Examples included)
  5. How to Check if a Service Restart or Server Reboot is required After RPM Package Update (CentOS/RHEL/Fedora)
  6. How to Test Port [TCP/UDP] Connectivity from a Linux Server
  7. CentOS / RHEL 6 : How to password-protect single user mode
  8. CentOS / RHEL : How to add iptable rules
  9. LVM Commands Fail With “Failed to load config file /etc/lvm/lvm.conf”
  10. OpenLDAP Server and Client Utilities list

You May Also Like

Primary Sidebar

Recent Posts

  • How to Disable IPv6 on Ubuntu 18.04 Bionic Beaver Linux
  • How to Capture More Logs in /var/log/dmesg for CentOS/RHEL
  • Unable to Start RDMA Services on CentOS/RHEL 7
  • How to rename a KVM VM with virsh
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary