Server Disk Cloning

Target is to clone the Ubuntu 18.04 installation of an Asus netbook Eee PC 900A server to a backup unit.

/!\ Ubuntu 18.04 is the last 32 Bit edition. After 2012-04 change to a 64 Bit computer, and make a new installation.

The netbook was selected as a server, because it needs less than 10 W power, has an UPS (Uninterruptable Power Supply) for a short power failure, has enough computing power for the job (CPU Intel Atom 1,6 GHz, RAM 1-2 GB) and is low cost. The selected model has a SSD disk drive (8 - 16 GB), which should be more reliable than a mechanical disk drive.

In the same task also the internal SSD disk size was changed from 8 GB to 16 GB, in order to have more free disk space.

The server is used for a documentation wiki, a House building Blog (iweb) and a TYPO3 installation (backup). Additionally it is used as a web proxy for a heating system Temperature Control with web cam (Debian based).

Ubuntu was used for the server operating system, because it is user friendly, an can be administrated with SSH terminal and VNC display.


# If needed:
$ sudo add-apt-repository universe
$ sudo apt update

# program ddrescue install with
$ sudo apt-get install gddrescue

Duplicate the source disk

# -a = all swap spaces, -v = verbose
$ sudo swapoff -av
swapoff for /dev/sda5

# Test for success
$ free -h
# shows no more swap space

# change directory to the Intermediate Drive, use the key TAB to auto complete the drive name
$ ls /media
$ cd /media/758a8a5c-9879-43ea-b5ce-160c8b3cd93e 

# copy drive content to image file, -b 1M = buffer size 1 MByte for best speed
$ time sudo ddrescue -b 1M /dev/sda sda.img logfile1

# It takes about 5 minutes to copy 8 GB to the Intermediate Drive (USB-HD)

# If there is an old logfile, it must be deleted, or give it every time a new name
$ rm logfile
# answer question for delete with "y" ("j")

# change directory to the Intermediate Drive, use the key TAB to auto complete the drive name
$ ls /media
$ cd /media/758a8a5c-9879-43ea-b5ce-160c8b3cd93e 

# -f = force, needed if target is a drive, -v = verbose
$ time sudo ddrescue -b 1M -fv sda.img /dev/sda logfile2

# It takes about 10 minutes to copy 8 GB to the Target Drive (SSD)

Adjust Network MAC and Disk UUID

Because the network MAC address has changed, also the UUID of the disk partitions, they must be adopted.

# Find out the UUID of the swap drive
$ blkid
/dev/sda1: UUID="89cb8d0c-200e-4022-8746-18603304d2c8" TYPE="ext4" 
/dev/sda2: UUID="f7aee6fb-ecb5-4918-b0a7-f36169cd3592" TYPE="swap" 

# Edit with root rights file /etc/fstab
$ gksu nautilus

# Activate the Swap partition
$ sudo swapon -a

# Test for active Swap partition
$ free
             total       used       free     shared    buffers     cached
Mem:       2051336    1011732    1039604          0     166968     467980
-/+ buffers/cache:     376784    1674552
Swap:       525308          0     525308

Partition size correction

After the image restore to /dev/sda check the partition size with gparted. If gparted tells with a red "!":

can't have a partition outside the disk

the partition size of the image does not fit the actual disk size (SSD). The solution is to shrink fit the partitions:

# stop swapping
$ sudo swapoff -a

# delete swap partition
$ sudo fdisk /dev/sda
# delete partition #2 /dev/sda2
  Partition number (1 - 4): 2
# write to disk
# exit fdisk

Next start gparted and resize partition /dev/sda1, that the free space for a new swap partition is about 512 MB. Then create a new swap partition with the rest of the free space. Exit gparted, reboot without USB-stick and type in the terminal:

# start swap operation
$ sudo swapon -a

# check for success
$ free
# should show 512 MB for the total swap area

Last, correct in file /etc/fstab the UUID of the swap partition, as explained before.

List of pages in this category:

-- RudolfReuter 2012-11-12 12:37:38

Go back to CategoryServer or FrontPage ; KontaktEmail (ContactEmail)

ServerDiskCloning (last edited 2020-06-07 17:40:13 by RudolfReuter)