22.09.2023

How to clone or copy a Debian server

Introduction

Main trouble and pain in work for any system administrator, computer engineer or interested OS area IT—specialist: it's automating the system. Secure, fast and reliable setup OS with the prepared application and system configuration on many machines that sound pretty scary. Isn't it? However, all processes of setup it's quite simple. Suppose you need to replicate an existing server's configuration and settings. That's where cloning comes in — by creating a clone of a current server, you can quickly and easily deploy a new server with software.

The genisoimage is a command—line tool for creating ISO 9660 CD—ROM file system images. It is commonly used on Unix and Linux systems to create bootable CDs, backup discs, or for distributing large amounts of data in a single file. The resulting ISO image can then be burned to a CD or DVD using burning software or mounted as a virtual drive.

In this short guide, we'll display and explain the process of cloning a Debian server as possible as thoroughly. Whether you're a seasoned Linux veteran or a newcomer to the world of Debian, the guide will provide you with all the information you need to clone your server and save valuable time and effort successfully. So, without further ado, let's get started!

Requirements & installation

Here are the generally recommended minimum system requirements:

  1. Processor: 1 GHz or faster;
  2. RAM: 1 GB (2 GB or more recommended);
  3. Hard disk space: 20 MB of available space;
  4. Operating system: Linux or Unix—based systems.

If your system parameters are alright, we can start the installation with the commands below:

sudo apt update && sudo apt upgrade -y

This line means updating the index list of packages and starting the download process.

sudo apt-get install genisoimage -y

This command starts the installation package utility.

Screenshot №1 — Install genisoimage

Then for correct work software, you need to make a directory where data will prepare and compile into an ISO image, the command below helps to make this:

sudo mkdir /tmp/image

Now, copy all files from “root—directory” to “iso_contents”, if you want to make part of the backup, write a catalogue or file, that should be copied. The commands below display this step:

sudo fdisk -l

Screenshot №2 — Show disks

First, need to identify the device name of the root partition by running the command.

sudo mount /dev/sda1 /mnt

Then, you can use the "mount" command to attach the root partition to a mount point.

sudo cp -a /mnt/* /tmp/image/

Copy the entire contents of the machine’s root filesystem to the new directory.

umount /mnt

In that command, I am “unmount” this point.

sudo genisoimage -r -o debian.iso /tmp/image

I used genisoimage to create an ISO image of the copied files.

Screenshot №3 — Other steps

Note! This process may take some time depending on the size of the machine's root filesystem. Additionally, creating an ISO image of a running system may not be appropriate for all use cases, so make sure to consider your specific needs before proceeding.

Burn the ISO image to a CD or DVD, or save it to a USB drive to use as a bootable image. Create a new virtual machine in the virtualization software, specifying the amount of RAM and disk space you wish to allocate to the VM and significant notice: you need to choose the same configuration, as in the previous source machine!

Conclusion

The cloning process involves creating a new directory, copying the files from the root directory to the new directory, creating an ISO image of the copied files using genisoimage, and finally burning the ISO image to a CD or DVD or saving it to a USB drive. The guide also includes system requirements and installation instructions. It is important to note that creating an ISO image of a running system may not be suitable for all use cases!

You may be also interested in