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 http://moinmo.in 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.
- Source disk: 8 GB SSD in an Asus netbook Eee PC 900A
- Intermediate disk: USB HD 250 GB with ext4 file system
- Destination disk: 16 GB SSD in an Asus netbook Eee PC 900A
Cloning Tool: bootable USB-Stick (8 GB) with Ubuntu with ddrescue (.deb package gddrescue)
- It must have setup a writeable area
ddrescue is used instead of dd, because it gives more information about the copy process
# If needed: $ sudo add-apt-repository universe $ sudo apt update # program ddrescue install with $ sudo apt-get install gddrescue
Duplicate the source disk
Boot to the Source disk and switch off the SWAP space:
# -a = all swap spaces, -v = verbose $ sudo swapoff -av swapoff for /dev/sda5 # Test for success $ free -h # shows no more swap space
Shutdown the Source disk, only a not mounted disk could be copied
- Insert the USB-Stick, power up and with key F2 select in the BIOS the USB-Stick and boot
Select in Ubuntu your language and click on Try Ubuntu
- It takes about 10 minutes to boot
Mount the Intermediate disk with a click in nautilus (file browser)
Find out the name of the Intermediate disk in /media (UUID=758a8a5c-9879-43ea-b5ce-160c8b3cd93e)
Duplicate the Source disk content to an image file
In case of a problem look here
- before you can do a second try, you must first delete the write protected log file from ddrescue, or give it a new name
# 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)
- Power down and remove the USB-HD
- Exchange the netbook with the backup unit with a 16 GB SSD disk
- Power up with the USB-Stick as before and insert the USB-HD with the image file sda.img
- Copy the image file back to the new 16 GB SSD disk
# 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)
Start gparted and delete the swap partition on /dev/sda, and expand partition /dev/sda1 to the SSD disk size - 512 MB.
- Next, setup the left 512 MB free space as a primary swap partition.
- That takes about 1 minute
- Power down, remove USB-Stick and USB-HD and boot with the SSD, for test
Adjust Network MAC and Disk UUID
Because the network MAC address has changed, also the UUID of the disk partitions, they must be adopted.
Delete the old network LAN setup eth1 and setup with the new MAC number
Usually Ubuntu replaces at boot the UUID of the boot partition in file /etc/fstab, but not for the Swap Drive
# 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 d Partition number (1 - 4): 2 # write to disk w # exit fdisk q
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