On the test, I use the Ubuntu Server 14.04.5 LTS system.
And so, on a running system, switch to root user:
sudo -i
Check which drives are connected:
fdisk -l
In my case, the first disk used is /dev/sda (automatically marked up by the system upon installation) and /dev/sdb is a new one not marked up:
/dev/sdb1 * Linux
/dev/sdb2 Advanced
/dev/sdb5 Linux swap / Solaris
/dev/sdb
Partition the new disk /dev/sdb in the same way as /dev/sda:
sfdisk -d /dev/sda | sfdisk --force /dev/sdb
Format the main partition and swap on the new disk:
mkfs.ext4 /dev/sdb1
mkswap /dev/sdb5
Create an empty directory, mount the first main partition of the new disk into it:
mkdir /newhdd
mount /dev/sdb1 /newhdd
Let’s see what the directories are and copy all the information into the new section:
ls /
cp -ax /bin/ /boot/ /etc/ /home/ /lib/ /lib64/ /opt/ /root/ /sbin/ /tmp/ /usr/ /var/ /initrd.img vmlinuz /newhdd
cd /newhdd
mkdir /dev /proc /srv /sys /mnt
chmod 777 /tmp
After copying, see the UUID of the new disk partitions:
lsblk -o NAME,UUID
blkid
Change the UUID of the old partitions to the new ones in the /newhdd/etc/fstab file.
And finally, we will execute commands in the terminal to update the grub:
mount /dev/sdb1 /newhdd
mount --bind /dev /newhdd/dev
chroot /newhdd
update-grub
exit
After that, you can turn off the system and disconnect the old disk, when you turn on a copy of the system will start from the new disk.
By the way, once I copied all the information except the lib64 directory and the error was displayed while chroot:
chroot: failed to run command ‘/bin/bash’: No such file or directory
See also my article:
Backup Linux to archive and restore from it