Wednesday, October 18, 2023

copying linux system and boot

mounting and copying file

mkdir s     (for source).

mkdir d     (for destination)

sudo mount /dev/sda1  s     (mounted file system to be copied to)

mount /dev/sdb1 d              (destination device formatted ext4)

sudo cp -avrf s/* d/.

....    (bunch of message copy process)

sudo umount s    (unmount source device/running OS to has been copied)

 

setting up boot on destination device

sudo mount proc d/proc/ -t proc
sudo mount sys d/sys/ -t sysfs
sudo mount -o bind /dev/ d/dev/
sudo chroot d 

find device destination uuid (sdb1)

ls -al /dev/disk/by-uuid

drwxr-xr-x 2 root root 140 Oct 19 10:50 .
drwxr-xr-x 7 root root 140 Oct 19 09:49 ..
lrwxrwxrwx 1 root root  10 Oct 19 10:50 076e1fc2-c344-49ea-95de-e1b0d3f77be5 ->
../../sdb4
lrwxrwxrwx 1 root root  10 Oct 19 09:55 1712071f-7899-4496-8a5e-881821578813 ->
../../sda1
lrwxrwxrwx 1 root root  10 Oct 19 09:49 28944C55944C2820 -> ../../sdb2
lrwxrwxrwx 1 root root  10 Oct 19 09:49 5e24b64a-1d70-46f3-b820-70fd3e8f2d4e ->
../../sdb3
lrwxrwxrwx 1 root root  10 Oct 19 09:49 84DE5634DE561EAC -> ../../sdb1

edit /etc/fstab replace the root file system UUID with UUID new device  
 
vi /etc/fstab
 
#### Static Filesystem Table File
proc    /proc   proc    defaults        0       0
# /dev/sdd1
#UUID=1712071f-7899-4496-8a5e-881821578813      /       ext4    rw,errors=remoun
t-ro    0       1
# /dev/sdb1
UUID=
84DE5634DE561EAC       /       ext4    rw,errors=remoun
t-ro    0       1

Upgrade and install grub on destination device

update-grub

grub-install /dev/sdb

exit

sudo umount d/proc

sudo umount d/sys

sudo umount d/dev

sudo umount d/

 

Done! start boot on new device



No comments:

Post a Comment