View previous topic :: View next topic |
Author |
Message |
Jackie Lin Tux's lil' helper
Joined: 31 May 2017 Posts: 115
|
Posted: Wed Nov 15, 2017 1:35 pm Post subject: copy gentoo from A to B |
|
|
Hello! I have two pc with the same hardware. I have installed gentoo into A step by step. How can I copy gentoo from A into B? Is there a way?
Could anyone help me? Thanks in advance! _________________ peace, focus. |
|
Back to top |
|
|
C5ace Guru
Joined: 23 Dec 2013 Posts: 472 Location: Brisbane, Australia
|
Posted: Wed Nov 15, 2017 2:15 pm Post subject: Re: copy gentoo from A to B |
|
|
Jackie Lin wrote: | Hello! I have two pc with the same hardware. I have installed gentoo into A step by step. How can I copy gentoo from A into B? Is there a way?
Could anyone help me? Thanks in advance! |
The simple way (may or may not work:
- Remove the hard drive from PC B and install it into PC A.
- Boot A using SytemRescue CD.
- Verify that hard drive A is /dev/sda and hard drive B is /dev/sdb
- dd if=/dev/sda of=/dev/sdb bs=4096
- when done re-install hard drive B back into PC B
- Boot PC B
Ask for further instructions if it does not work. |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54237 Location: 56N 3W
|
Posted: Wed Nov 15, 2017 2:21 pm Post subject: |
|
|
C5ace,
Works if the HDD in both machines are the same size.
dd is slow for bs <1 MB, so 4096 is a bit small.
This approach and the others I can think of, also clones the machines identity, so the ssh host key, user(s) and passwords may all need to be changed on the target, along with other setup dependent things. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
Jaglover Watchman
Joined: 29 May 2005 Posts: 8291 Location: Saint Amant, Acadiana
|
|
Back to top |
|
|
cwr Veteran
Joined: 17 Dec 2005 Posts: 1969
|
Posted: Wed Nov 15, 2017 3:47 pm Post subject: |
|
|
If the recipient can boot Linux off a DVD or USB stick then the easiest way is to
tar up the source directories, copy them across with ssh, and then untar them.
Code: |
tar cz dir | ssh user@remotehost.com "cat >outfile.tar.gz"
|
Or you can use scp in recursive mode.
Or in the worst (slowest) case, copy the tar files across on a USB stick.
Will |
|
Back to top |
|
|
C5ace Guru
Joined: 23 Dec 2013 Posts: 472 Location: Brisbane, Australia
|
Posted: Wed Nov 15, 2017 4:08 pm Post subject: |
|
|
NeddySeagoon wrote: | C5ace,
Works if the HDD in both machines are the same size.
dd is slow for bs <1 MB, so 4096 is a bit small.
This approach and the others I can think of, also clones the machines identity, so the ssh host key, user(s) and passwords may all need to be changed on the target, along with other setup dependent things. |
Jackie Lin said: "I have two pc with the same hardware."
I presume this to be correct.
The user and other items can be created and/or changed when the PC B is working. |
|
Back to top |
|
|
Elleni Veteran
Joined: 23 May 2006 Posts: 1270
|
Posted: Wed Nov 15, 2017 6:55 pm Post subject: |
|
|
I had success with this. Following the link with the explanation of khayyam, which worked fine for me:
https://forums.gentoo.org/viewtopic-t-1058818-start-0-postdays-0-postorder-asc-highlight-elleni.html
The key was to create the archive from a non booted system, but from a livemedium, so proc, sys stuff had not to be excluded.
khayyam wrote: |
Elleni ... this simplest way to achieve the desire outcome is to rsync one install to the other: boot both machines via a USB or CD, mount the filesystem(s) to /mnt/gentoo (and /mnt/gentoo/<filesystem> if you have separate filesystems, ie for /boot), start ssh on the target machine, and then do the following (from the machine with the install to be copied):
Code: | # rsync -av --xattrs -e ssh --progress --delete /mnt/gentoo/ root@192.168.x.x:/mnt/gentoo |
I'm using --delete there with the assumption that this will correct xattrs, but to be safe you could mkfs.ext4 on the target machine so /mnt/gentoo is empty. You could also add --exclude 'home' so as not to copy user data.
Otherwise, you can build a 'stage4' without a script, all you need to is boot from a USB/CD and do the following:
Code: | # mount /dev/sda2 /mnt/gentoo
# mount /dev/sda1 /mnt/gentoo/boot
# mount /dev/sdb1 /mnt/my_external_usb_drive
# tar -jcvfp --xattrs /mnt/my_external_usb_drive/stage4-$(hostname)-$(date +%F).tar.bz2 /mnt/gentoo/ |
and you could similarly --exclude="/home". Then on the target machine:
Code: | # mount /dev/sda2 /mnt/gentoo
# mount /dev/sda1 /mnt/gentoo/boot
# mount /dev/sdb1 /mnt/my_external_usb_drive
# tar -jxvfp --xattrs /mnt/my_external_usb_drive/stage4-hostname-2017-02-05.tar.bz2 -C /mnt/gentoo |
One last example 'tar over ssh' (booted from a USB/CD):
Code: | # tar -jcvfp --xattrs - /mnt/gentoo/ | ssh root@192.168.x.x "cat > /path/to/disk/stage4-$(hostname)-$(date +%F).tar.bz2" |
|
|
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21633
|
Posted: Thu Nov 16, 2017 3:24 am Post subject: Re: copy gentoo from A to B |
|
|
C5ace wrote: | - dd if=/dev/sda of=/dev/sdb bs=4096 | Note that this copies free space, which is inefficient if the drive is mostly unused. Also, it is poor practice with SSDs, since the drive firmware will then believe all sectors are live. A trim (if supported by the drive) can correct that, but it's better to avoid the useless write in the first place. |
|
Back to top |
|
|
joanandk Apprentice
Joined: 12 Feb 2017 Posts: 169
|
Posted: Thu Nov 16, 2017 10:12 am Post subject: |
|
|
Sorry to give you with one more opinion:
a) Put the HDD A into PC B
b) Boot with Sysrescuecd
c) Create partition on HDD B according to the manual
d) If a boot-partition was created, mount boot of HDD B to /mnt/gentoo and mount boot of HDD A to /mnt/windows
e) cd /mnt/gentoo
f) execute rsync -auvz --progress /mnt/windows .
g) unmount /mnt/gentoo and /mnt/windows and do d) to g) for root, home and other partitions you have
h) mount your root partition to /mnt/gentoo again
i) chroot into /mnt/gentoo as done at the installation
j) install the bootloader again
k) change hostname, passwords if necessary. It would be advisable to regenerate ssh-keys.
l) shut the system down and remove HDD A
Now you should have an identical installation.
BR
PS: I have been doing this for a very long time and had no issues. |
|
Back to top |
|
|
Jackie Lin Tux's lil' helper
Joined: 31 May 2017 Posts: 115
|
Posted: Fri Nov 17, 2017 12:04 pm Post subject: |
|
|
Thanks! using rsync is a smart idea, and dd will also work when hard drive is small _________________ peace, focus. |
|
Back to top |
|
|
Roman_Gruber Advocate
Joined: 03 Oct 2006 Posts: 3846 Location: Austro Bavaria
|
Posted: Sat Nov 18, 2017 9:31 am Post subject: |
|
|
Jaglover wrote: | I've upgraded my hard drives many times, plain cp -a always did it for me. |
Basically I use sysrescue-cd, exernal usb 3, uas case(if thats the fast usb standard), and an internal drive with cp -avr, and all the mounting, partioning like in the handbook, + as always fixing the bootloader. Fixing hte bootloader needs also be done when uefi forgets about it.
I have 3 drives now again in a backup cycle. So I do this quite regularly. drive a -> b -> c -> a -> .... so one drive fails or gets ruined during backup i have at least third drive. 3 different brands of ssds, different years of purchase, different technology, and only 120GB each, I could have used 60gb too. always over 60gb free for everything
--
no idea why guys suggests dd, several reasons why it should be not used.
I recreate my file system everytime i do my backup.
rsync had issues on my side, too complicated, yes serious too complicated. plain cp does its job and its easy. rsyncbackup or what it'S called same.
I am even too lazy to use snapshot feature, although i use lvm. not worth, i want hole backup, and my backup process is less than 20 minutes, quite fast ssd => uas usb3.0ssd. includes swaping discs and reapply bootloader via command
--
dd should be only used when you deal with freaky android hardware where you need to know that certain bits are written to certain areas. dd is nasty hardware hack for that purpose
and ofc ddrescue or what it was called, else nope!
--
my backup approach works, I remove the original drive from my notebook, and swap it with the drive from the usb case. the internal drive goes on my bookshelf. I see instantly if it worked. and if my data is still there. those freaky rsync and such, still issues with restoring data. i just have to put in my old drive and reapply the bootloader, because uefi is bugridden microsoft software, and therefore needs everytime to be fixed. I can do it without network, without external help. Restoring from rsync, you probably need the gentoo handbook for that, or a second computer / tablet to lookup all the commands in question. time consuming procedure.
--
bonus with cp -avr
sometimes i see stuff which is hidden somewhere and very old, or not needed anymore. so i can remove it than. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|