How to clone your ubuntu OS using rsync.

2nd pc – install ssh-server
make a partition with ext4

$sudo su
#apt-get install openssh-server
#mount /dev/sda<num> /<mount_point> eg. #mount /dev/sda4 /mnt

1st pc – run rsync
(PC1)$sudo rsync -av –one-file-system –exclude=/proc/* –exclude=/dev/*
–exclude=/sys/* –exclude=/tmp/* –exclude=/home/* –exclude=/lost+found
–exclude=/var/tmp/* –exclude=/boot/grub/* –exclude=/root/*
–exclude=/var/mail/* –exclude=/var/spool/* –exclude=/media/*
–exclude=/etc/fstab –exclude=/etc/mtab –exclude=/etc/hosts
–exclude=/etc/timezone
–exclude=/etc/X11/xorg.conf* –exclude=/etc/gdm/custom.conf
–exclude=/etc/lightdm/lightdm.conf /[email protected]<ipaddress_of_second_pc>:/<mount_point_to_ext4>

after rsync complete

ssh from 1st pc to 2nd pc

(PC1)$ssh [email protected]<ipaddress_of_second_pc>

#cd /<mount_point_to_ext4>
#mount -t proc /proc proc/
#mount -t sysfs /sys sys/
#mount -o bind /dev dev/
#mount -t devpts /dev/pts dev/pts/
#chroot . /bin/bash

#grub-install /dev/sda –force
#update-grub

#mkdir home/<standard_username_from_pc1>

#chown -Rf <standard_username_from_pc1>:<standard_username_from_pc1> home/<standard_username_from_pc1>/

#chmod 755 home/<standard_username_from_pc1> -Rf

if you want to change username and home dir.

#usermod -l <newname> -d /home/<newdir> -m <current_username>

#groupmod -n <newgroup> <current_group>

if you want to enable swapfile

#dd if=/dev/zero of=/swapfile bs=1G count=4 (This will create 4GB swapfile)
#mkswap /swapfile

#nano /etc/fstab
and add the following line

/swapfile   none    swap    sw    0   0
 

#reboot