Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Cloning existing gentoo install to a second laptop (SOLVED)
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
eklebanow
n00b
n00b


Joined: 08 Sep 2019
Posts: 39

PostPosted: Wed May 06, 2020 4:22 pm    Post subject: Cloning existing gentoo install to a second laptop (SOLVED) Reply with quote

I have just procured a second laptop. I would like to set it up exactly like my existing laptop. I have a gentoo install. The existing install is on a 500 GB SSD the new install will be on a 128 GB drive.My existing install uses about 40 Gb of the 500 GB drive.

I am a NOOB. I have never done this before but I know I can save a lot of time by cloning the install rather than reinstalling gentoo and all of my files.

Can someone please walk me through the process with as complete description as possible.

I guess I have to go through the gentoo install for the new machine up to the point of creating the kernel that matches the hardware.on the new laptop.

I have done a lot of reading and understand there are many ways to do this....i.e dd, rsync, clonzilla..... but I do not completely understand any of the descriptions and how they match what I am trying to do....I understand that going from a larger SSD to a smaller SSD is problematic.

Do I have to be able to install both SSDs into one machine or do I do this via SSH?
Do I have to have a bootable USB in order to be able to do this?


Last edited by eklebanow on Mon May 11, 2020 1:31 am; edited 1 time in total
Back to top
View user's profile Send private message
dr_wulsen
Tux's lil' helper
Tux's lil' helper


Joined: 21 Aug 2013
Posts: 128
Location: Austria

PostPosted: Wed May 06, 2020 6:04 pm    Post subject: Reply with quote

Hi eklebanow,

it entirely depends on the situation, there is no definite and general yes or no about the chances of success.
Quote:
Can someone please walk me through the process with as complete description as possible.
Well, I can give you a quick overview of my approach,
Quote:
I guess I have to go through the gentoo install for the new machine up to the point of creating the kernel that matches the hardware.on the new laptop.
I would follow until the last line of Preparing the disks and then deviate from the path.
Quote:
Do I have to be able to install both SSDs into one machine or do I do this via SSH?
Do I have to have a bootable USB in order to be able to do this?
You can go any path you like, for speed and simplicity, I would do all locally on your new laptop without having to open it.
You can use your backup file (details below) from a flash drive or ssh/scp it to your new machine, once the live medium is booted, ssh is just a matter of comfort - for things like configuring a new kernel and to see if it boots, it will only be reasonable to do so in front of the laptop.

For the installation on your new laptop, you can make a "stage4" tarball of your system and extract it to your laptop.
Requirement for this to work is that the new machine is at least the same architecture (32 or 64bit processor; x86 or ARM, etc.) as your old machine was.
To put it short, if you have succeeded in installing gentoo on your primary machine, this should be somewhat painless for you.

Steps:
  • Become root in a terminal. Create a backup of your running machine with
    Code:
    cd /; tar --create --preserve-permissions --absolute-names --ignore-failed-read --xattrs-include='*.*' --numeric-owner --sparse --exclude-backups --exclude-caches --sort=name --verbose  --exclude=/boot/* --exclude=/home/*/.bash_history --exclude=/dev/* --exclude=/var/tmp/* --exclude=/media/* --exclude=/mnt/* --exclude=/proc/* --exclude=/run/* --exclude=/sys/* --exclude=/tmp/* --exclude=/var/lock/* --exclude=/var/log/* --exclude=/var/run/* --exclude=/var/lib/docker/* --exclude=YOUR_BACkUP_FILENAME --exclude=/var/db/repos/gentoo/* --exclude=/var/cache/distfiles/*  --verbose --file=YOUR_BACkUP_FILENAME /*
    and replace the two occurences of YOUR_BACkUP_FILENAME with the path to your to-be-created-backup file. The first occurcence excludes it from being included in your backup, which would lead to an infinite loop of reading the file we are writing to; the second occurence just tells tar where to write that file.
    Copy that file to some flash drive or whatever you have lying around.
  • Now you can follow the installation handbook as you would normally on your new laptop.
  • Instead of stage3-whatever-latest.tar.(bz2|xz) use your file
  • Be sure to assign a different hostname and IP address to your Laptop, otherwise things will get funny.
  • Be very careful on make.conf regarding any optimizations, most likely it will be safe to use -march=native -O2 -pipe -fomit-frame-pointer
  • Apply the same care to fstab, an error there will lead to problems up to "no boot" easily.
  • Configuring the kernel - That's a story on its own. But you don't need to install the sources, as they are included in your backup.
    The backup will also include your kernel config, so you will have a starting point if you configure it manually.
    You can use lspci -knn or lspci -vknnto see what's on your PCI(Express) bus and guess the drivers you need.
  • Install your new kernel, kernel modules, and initramfs if used, as the handbook says.
  • Install and configure your bootloader, just following the kandbook there.
  • Follow the handbook until the end, cross your fingers and reboot.
That is pretty much how I backup and restore my PC for a bare-metal recovery; the tar command is actually what the script app-backup/mkstage4 would put together for you.
By manually entering the line, you don't have to install anything. You may of course use app-backup/mkstage4.sh or my edited version which you can find here

Restoring the backup file to any drive that has sufficient capacity is usual and does not give any problem, since this is just a tarball to extract, no image.

For the purpose of hassle-free help, just copy the output of lspci -knn to some file you will later have access to, so you could post it on the forums if problems arise.
Should the system not boot - don't worry too much; you can always start the live media and chroot into your gentoo, edit and alter things, change the kernel and try to boot again without having to go through all the installation.
_________________
There's no stupid questions, only stupid answers.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 15294

PostPosted: Thu May 07, 2020 12:50 am    Post subject: Re: Cloning existing gentoo install to a second laptop Reply with quote

eklebanow wrote:
I have done a lot of reading and understand there are many ways to do this....i.e dd, rsync, clonzilla..... but I do not completely understand any of the descriptions and how they match what I am trying to do....I understand that going from a larger SSD to a smaller SSD is problematic.
Not necessarily. It is only a problem if the destination drive cannot hold everything you want to copy. If you were doing a block-level copy, then a smaller drive would automatically be a problem. You should never do a block-level copy when the destination is a solid state drive. If you are doing a file-level copy (rsync, tar, etc.), then as long as the used space on the large drive will fit within the capacity of the small drive, you should be fine.
eklebanow wrote:
Do I have to be able to install both SSDs into one machine or do I do this via SSH?
Do I have to have a bootable USB in order to be able to do this?
You will get better performance if both drives are in one machine, but you can do the transfer over the network if you prefer. You will need both drives installed in machines with functioning operating systems. If you put both in one machine, then you can boot from one and use it to copy to the other. (Note that copying from a live system is somewhat more complicated if you want the copy to be perfect.) If you put them in separate systems, then both systems need to be booted to working operating systems. A bootable USB makes both paths easier.
Back to top
View user's profile Send private message
eklebanow
n00b
n00b


Joined: 08 Sep 2019
Posts: 39

PostPosted: Thu May 07, 2020 3:07 am    Post subject: Reply with quote

Quote:
For the installation on your new laptop, you can make a "stage4" tarball of your system and extract it to your laptop.
Requirement for this to work is that the new machine is at least the same architecture (32 or 64bit processor; x86 or ARM, etc.) as your old machine was.


Do I need to worry about how I partition the SSD on the new machine to which I will copy the tarball?

Quote:
cd /; tar --create --preserve-permissions --absolute-names --ignore-failed-read --xattrs-include='*.*' --numeric-owner --sparse --exclude-backups --exclude-caches --sort=name --verbose --exclude=/boot/* --exclude=/home/*/.bash_history --exclude=/dev/* --exclude=/var/tmp/* --exclude=/media/* --exclude=/mnt/* --exclude=/proc/* --exclude=/run/* --exclude=/sys/* --exclude=/tmp/* --exclude=/var/lock/* --exclude=/var/log/* --exclude=/var/run/* --exclude=/var/lib/docker/* --exclude=YOUR_BACkUP_FILENAME --exclude=/var/db/repos/gentoo/* --exclude=/var/cache/distfiles/* --verbose --file=YOUR_BACkUP_FILENAME /*


Can someone explain what is going on here i.e. what is being included
and what is being excluded and why? What is the meaning of the CD at the very beginning?
Back to top
View user's profile Send private message
dr_wulsen
Tux's lil' helper
Tux's lil' helper


Joined: 21 Aug 2013
Posts: 128
Location: Austria

PostPosted: Thu May 07, 2020 4:00 am    Post subject: Reply with quote

will do, the cd just makes double-sure that we are backing up the root drive, but as it's specified at the end of tar ( /*) it is redundant.
the semicolon ( ; ) is used to chain commands together irregardless of their success. So here "&&" would have been more appropriate in the first place, but cd / ususally doesn't fail. ( && chains commands together with respect to their success, so in that case, if cd failed, tar would never start off)

you can partition it any way you like, as long as you later on put all that info to fstab to reflect that.
Of course, you will have to first mount your new partitions in the live environment to the places they'd later be mounted, sonwhen you extract your stage4, files get written in the right place (imagine a separate /home).
Included is pretty much everything under /

The exclude list is just most temporary files and contents of folders, as well as kernel auto-populated directories like /sys /dev and so on.
It's important e. g. /sys exists, but the contents do not need to be copied, as rhe kernel creates them dynamically at boot.
Also /mnt/* is excluded, imagine you have mounted a data partition with Gigabytes of files there, they should not be copied.
. bash_history is a file with recently entered commands in bash.

If you want more details, I'll do that after work :)
_________________
There's no stupid questions, only stupid answers.
Back to top
View user's profile Send private message
eklebanow
n00b
n00b


Joined: 08 Sep 2019
Posts: 39

PostPosted: Fri May 08, 2020 1:29 am    Post subject: Reply with quote

OK....l created the backup.tar file

I have some questions:

1. Why did you recommend that I create a .tar file (which has no compression) vs. a tar.gz or tar.bz2?

2. It took only 5 minutes or less to create the file.....,Does thiis file actually store all of the information that was on my disk? Is it correct that I will not have to install prorgrams on the restored disk (i.e emacs, dwm, ispell, qutebrowser, gimp,etc?

3. Will the tarball I created as a disk backup of my older laptop provide all of the files that the stage 3 tarball does diuring the gentoo install?

Thanks in advance.....Just trying to understand what I am doing before I do it.....
Back to top
View user's profile Send private message
dr_wulsen
Tux's lil' helper
Tux's lil' helper


Joined: 21 Aug 2013
Posts: 128
Location: Austria

PostPosted: Fri May 08, 2020 5:27 pm    Post subject: Reply with quote

Quote:
1. Why did you recommend that I create a .tar file (which has no compression) vs. a tar.gz or tar.bz2?
I have to admit, pure laziness.
I usually have --use-compress-program=pbzip2 in the tar options; as it's not installed by default I didn't want to bother you installing pbzip2 (a parallel bzip2 compressor). So the whole option was omitted, but of course, xz/bz2/gz in descending order of my preference would not make any difference except file size.

Quote:
2. It took only 5 minutes or less to create the file.....,Does thiis file actually store all of the information that was on my disk? Is it correct that I will not have to install prorgrams on the restored disk (i.e emacs, dwm, ispell, qutebrowser, gimp,etc?

Depends on, I can't tell if your machine is a high-powered thing with NVMe storage or an old mechanical computer you'd have to crank by hand.
But you can check plausibility by running df -h on the terminal, checking how much of your / is occupied and comparing the size to the actual tar file. If it's close (and it should be), there's everything you've installed.
The tar command does tell tar to archive everything under / except for the "--exclude=foo" portions.

Quote:
3. Will the tarball I created as a disk backup of my older laptop provide all of the files that the stage 3 tarball does diuring the gentoo install?

It will contain much more than that.
Earlier on, gentoo had stage1 and stage2 tarballs, stage1 was barely enough to compile your glibc and compiler, you had to build everything from there.
Stage2 contained a little more, while now stage3 is the only supported install, which contains gcc, glibc, openRC and some utilities, so you can start right off.

Now you've installed your stage3 file to your PC, you've updated your PC and thus updated the files included in stage3 for sure multiple times, and then you've added more files like gimp, qutebrowser, etc.
Your backup file is called "stage4", because it includes all of stage3 and much more. You'll never find an official stage4 file, as there is configurations done and decisions taken that you may or may not want.
If someone used your stage4, he'd likely be unhappy because it would be a fully configured system, but most likely not to his taste.

BTW, if you want tar to compress your stage file heavily to save space; --use-compress=program=xz
if you want bzip2 but use all CPUs, install pbzip2 and use --use-compress-program=pbzip2
for regular bzip2, you guessed it right: --use-compress-program=bzip2
and for a quick gzip, I think you can imagine.

Whatever of the above options you use, the live CD will be able to decompress it, as xz, bzip2 and gzip are included by default.

EDIT: for my system, which has a full desktop, media players, web browsers, gimp and raw photo editors, KiCAD EDA suite and more, a regular backup compressed through bzip2 will be ~5GB.[/list]
_________________
There's no stupid questions, only stupid answers.
Back to top
View user's profile Send private message
eklebanow
n00b
n00b


Joined: 08 Sep 2019
Posts: 39

PostPosted: Sat May 09, 2020 7:28 am    Post subject: Reply with quote

OK I have created the backup file....
It was too big to create without compression.....so I installed pbzip2...I created file which I call edkbackup.tar.pbzip2. This file is 16 Gb. I copied the file onto a USB using cp

Now i have run into problems

I have no idea how to transfer the edkbackup.tar.pbzip2 file to the new laptop. I have booted the new laptop with the minimal installation cd. I have created partitions on the hard drive and I have created filesuystems.I have corrected the date. I am up to the step where I am supposed to download the stage 3 tarball and unpack it.

I am also unsure of how to unpack the tar.pbzip2 file once I get it on the new laptop.

BTW thanks for the help!
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 7653
Location: Saint Amant, Acadiana

PostPosted: Sat May 09, 2020 10:21 am    Post subject: Reply with quote

Quote:
I guess I have to go through the gentoo install for the new machine up to the point of creating the kernel that matches the hardware.on the new laptop.

What about CFLAGS, will your new CPU be able to run binaries built in your other laptop?
_________________
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
sdauth
Tux's lil' helper
Tux's lil' helper


Joined: 19 Sep 2018
Posts: 134
Location: Frankreich

PostPosted: Sat May 09, 2020 10:57 am    Post subject: Reply with quote

An other option would be to use a nice tool like fsarchiver (available in sysrescuecd) to clone your first laptop / partition to an archive and then restore that on your new / partition on second laptop.
I used that to clone my root partition from my desktop to a laptop. It even saves UUID etc..

Then, after your restored it on your new laptop, chroot, and make the necessary modifications. (hostname, kernel, bootloader, cflags if needed etc..)
Back to top
View user's profile Send private message
dr_wulsen
Tux's lil' helper
Tux's lil' helper


Joined: 21 Aug 2013
Posts: 128
Location: Austria

PostPosted: Sat May 09, 2020 12:49 pm    Post subject: Reply with quote

Quote:
What about CFLAGS, will your new CPU be able to run binaries built in your other laptop?

If it's the same architecture and not the most ancient, I suppose it will work enough, so you can re-compile the system afterwards.

My guess is that most basic system tools will not be AVX512-code, so chances are good that there is some common denominator on the important things that is shared across most half-recent CPUs.

@eklebanow: Once you've created your booting system, the first thing to do would be: emerge -e --keep-going @world which will just emerge your whole system with respect to your make.conf settings.
So after that, your code will be optimized for your actual CPU, taking for granted that you've set -march=native or your specific hand-picked optimizations in make.conf.
_________________
There's no stupid questions, only stupid answers.
Back to top
View user's profile Send private message
eklebanow
n00b
n00b


Joined: 08 Sep 2019
Posts: 39

PostPosted: Sat May 09, 2020 1:09 pm    Post subject: Reply with quote

Thanks for the input BUT no one has answered my question... How do I get the backup tar file onto the new laptop from the USB and then how do I unpack it? I have minimal install.iso on one USB and backup.tar.pbzip2 on another USB stick.

Both laptops are similar... One is t430 Thinkpad... The new one is t440p Thinkpad


Last edited by eklebanow on Sat May 09, 2020 1:34 pm; edited 1 time in total
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 7653
Location: Saint Amant, Acadiana

PostPosted: Sat May 09, 2020 1:33 pm    Post subject: Reply with quote

Quote:
the first thing to do would be: emerge -e --keep-going @world

Then why all the trouble and transferring all the binaries? For emerge -e @world all you need is the contents of /etc/portage/* and your world file. And a few files from /etc/* (the ones which were edited by you). Using these configuration files the whole installation will be rebuilt exactly the same.

Quote:
Thanks for the input BUT no one has answered my question... How do I get the backup tar file onto the new laptop from the USB and then how do I unpack it?
:roll: I'd say you are in trouble. Have you tried to do it, all by yourself?
_________________
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
eklebanow
n00b
n00b


Joined: 08 Sep 2019
Posts: 39

PostPosted: Sat May 09, 2020 3:17 pm    Post subject: Reply with quote

Quote:
I'd say you are in trouble. Have you tried to do it, all by yourself?


Not sure what you meant by this? Are you saying that the strategy outlined by Dr wulsen will not work to clone the disk on my old laptop?

If the strategy is sound can you please help me by answering how I get the stage 4 tarball I prepared onto the new installation?
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 15294

PostPosted: Sat May 09, 2020 4:38 pm    Post subject: Reply with quote

I believe Jaglover was implying that the answer should be obvious, and you should show some initiative here. Asking for advice on the right way to do something is fine, as is asking for suggestions on the optimal options to use with a tool you do not know well. Moving a file to a different system or unpacking it are very basic system administration tasks.

How would you normally move a file from one computer to another, if you cannot use a network connection to do so? How do you normally unpack a tar file? Try those things here. If they fail, and you cannot solve it, tell us how it failed and ask us to help you solve it.
Back to top
View user's profile Send private message
Abraxas
l33t
l33t


Joined: 25 May 2003
Posts: 809

PostPosted: Sat May 09, 2020 7:51 pm    Post subject: Reply with quote

You can just use "cp -a" and copy files directly if that's an option.
_________________
Time makes more converts than reason. - Thomas Paine
Travel is fatal to prejudice, bigotry, and narrow-mindedness, and many of our people need it sorely on these accounts. - Mark Twain
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 45383
Location: 56N 3W

PostPosted: Sat May 09, 2020 8:36 pm    Post subject: Reply with quote

eklebanow,

The tarball you have is your entire install.
On the new system, follow the handbook from the start up to the point of fetching and installing the stage3.
At that point, you use your own tarball. As has already been said, it contain much more than the stage3.

Once the untar completes, do the chroot steps, install your boot loader, if you have one, set up /etc/fstab if its changed and reboot.

Now you will get horribly confused. As you have cloned the install, you have also cloned the identity of the donor system.
e.g. host name, ssh host keys, network setup ... if its static and both systems are on the same network, thats a very bad thing.

If the donor and recipient are not CFLAGS compaitible, you will get Illegal Instruction errors and the recipient may not boot.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
dr_wulsen
Tux's lil' helper
Tux's lil' helper


Joined: 21 Aug 2013
Posts: 128
Location: Austria

PostPosted: Sat May 09, 2020 9:10 pm    Post subject: Reply with quote

I can second that a quick search for "how to mount usb flash drive" will give you some ways to achieve what you want.

However, as the first steps with a new system can make or break a user willing to learn, I'll take you by the hand here.

  • Start your live environment
  • Check out which device your USB key is. blkid will tell you which block devices (storage) are connected and what their name is.
    It only shows devices already connected, so be sure you've plugged it in and wait a second or two before issuing the command.
    Example output:
    /dev/sdc1: LABEL="P32G" BLOCK_SIZE="512" UUID="1306E7656C5C5E8E" TYPE="ntfs" PARTUUID="be9076ce-01" - this is my NTFS-formatted USB key named P32G.

    Other option: Wait till the system is booted, then plug it in, then issue dmesg | grep -i sd
    dmesg does show the kernel ring buffer output, so: the messages your kernel gives you about what's happening. Much helpful in diagnosing a running kernel with issues.
    Piping the output to grep instead of the terminal, you can search for an expression; in this case we look for "sd"; this will match any SCSI device (yes, USB and SATA register as /dev/sd[a..z]).
    The most recent (bottom) lines will fit your USB drive.
    Example output:
    [48779.806646] sd 6:0:0:0: Attached scsi generic sg3 type 0
    [48779.806862] sd 6:0:0:0: [sdc] 60555264 512-byte logical blocks: (31.0 GB/28.9 GiB)
    [48779.807057] sd 6:0:0:0: [sdc] Write Protect is off
    [48779.807058] sd 6:0:0:0: [sdc] Mode Sense: 45 00 00 00
    [48779.807246] sd 6:0:0:0: [sdc] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
    [48779.861796] sdc: sdc1
    [48779.862442] sd 6:0:0:0: [sdc] Attached SCSI removable disk

    You'll see in both examples, that the USB key partition registers as /dev/sdc1 in my case.

  • Now you know where to find the USB key, you'll need to mount it in order to work with the files stored on it.
    Mounting is easy, all you need is a place where your stick should appear within your filesystem, usually you use an empty directory.
  • mkdir /mnt/myusb
    Will create the directory /mnt/myusb - we will mount the USB drive to there, so its contents will appear.
  • mount /dev/sdc1 /mnt/myusb
    Tells mount to take device /dev/sdc1 and mount it under /mnt/myusb
  • Now your file will be accessible in /mnt/myusb/myfile.tar
  • To extract it, use the command from the handbook, but alter it to reflect your situation.
    cd /mnt/gentoo; tar xpvf /mnt/myusb/myfile.tar --xattrs-include='*.*' --numeric-owner
    For an explanation, that is: tar --extract --preserve-permissions --verbose --file /mnt/myusb/myfile.tar --xattrs-include='*.*' --numeric-owner - that's the same command with the long option format, which is kinda self-explanatory.
    It extracts, keeps the permissions of the files it is extracting the same as they were when tarring them (so the user can't modify files owned by root beause they will again be owned by root),
    Verbose is what I am right now, it will show you every file it is extracting in the output, file is... well your file, also it wil keep all extended attributes it has backed up (that will blow the thread, you will have to qwant/duckduckgo/google extended filesystem attributes if you are interested in that),
    and it will keep the owner/group of files numeric, so if a file was owned by root and root had the UID 0 on your system, it will extract the file to have UID 0 again set as owner.
    Why that? Imagine a live CD running where root is UID 100, without the option tar would extract the files to be owned by root (UID 100 on the running live media), which would lead to the user id (UID) 100 being the owner of the file.
    Now you boot your restored system where root is UID 0, and suddenly you have funny situations where permissions are messed up.

    I assume here, that you've already mounted your new / partition under /mnt/gentoo, just as the handbook tells you to do earlier on.
    Follow the handbook as you would, but just deviate this single piece, use your file instead of the stage3 tarball.


Hooks and traps:
Don't format your stick as NTFS (like mine in the example is). The live CD does not have an NTFS driver, NTFS on USB is generally frowned upon by me and anytime you do that, a kid starts crying.
Don't use ExFAT, it's likely not included in the live CD.
Catch included in FAT32: It can't handle single files of more than 4GB size (Not in Linux, not in Windows, not in the known Universe).
If your file is bigger than 4G (or close to it), format your stick as ext4, this will work in pretty much any live Linux - EXT4/3/2 is the most common filesystem.

How do I format my USB key in ext4, you ask?
There's always qwant/duckduckgo/google, but today I'm in a talkative mood, so:
  • Put the stick in your working computer - and make sure there's nothing on it you'd like to keep, it will be lost.
  • Find out, which device it is (see above, dmesg or blkid or whatever works). I assume it could be /dev/sdd1
  • If it's mounted you'll have to un-mount it, Windows analogy: You can't format a drive that is in use.
    mount without parameters will tell you which paritions are mounted. If your stick is in that output list, it is mounted. you'll also see where the stick is mounted.
  • Become root
  • umount /dev/sdd1 Will un-mount your stick. (More precise: the partition1 of your stick)
  • mkfs.ext4 -O ^has_journal -L USB_Backup /dev/sdd1
    Create an EXT4 filesystem, extended option: NO journal, label: USB_Backup on device /dev/sdd1
    Filesystem journalling is something you'd have to qwant/duckduckgo/google - too much to cover in this thread. Ususally I don't have it on flash media.
  • Once the command has completed, Take a few seconds and remove your USB key.
  • Re-insert it and if it does not auto-mount (show up automagically), you now know what to do, see above.
  • Copy the file to your stick: cp /path/to/mybackupfile.tar /this/is/my/mountpoint/for/the/stick/
  • Un-mount the stick: umount /dev/sdd1
    This may take a few seconds up to half a minute (write buffer from RAM getting written out to the stick). Wait for the command to complete!
  • Now all is on your stick and you're good to go, safe to remove the stick from your machine.

_________________
There's no stupid questions, only stupid answers.
Back to top
View user's profile Send private message
dr_wulsen
Tux's lil' helper
Tux's lil' helper


Joined: 21 Aug 2013
Posts: 128
Location: Austria

PostPosted: Sat May 09, 2020 9:30 pm    Post subject: Reply with quote

Quote:
If the donor and recipient are not CFLAGS compaitible, you will get Illegal Instruction errors and the recipient may not boot.

Explanation for you, as you may not guess what we are assuming can easily happen:

Newer processors always have more and updated instruction sets. Instructions can be add, multiply, divide and so on.
There's a common set, supported by all processors of the same architecture - so if your CFLAGS read -march=x86-64 the code will be compatible with any x86_64 processor.
It will be "optimized" for the bare minimum instruction set any x86_64 has to support, so it will run on a core2, a skylake, a ryzen...whatever you get sold as 64-bit processor for a desktop.

Now if you optimize, say for -march=skylake, the code will be optimized for the instructions an intel skylake supports.
That is much, much more instructions and much more complex instructions than a, say, core2 knows of.
Imagine an instruction that can multiply multiple input numbers in parallel. The new CPU knows of this, the old does not. (Stupid example)
(Neddy, maybe you have a real-life example, as I am much aware that the core2 does have SSE/SIMD instructions :D )
Now you tell some older CPU: Hey, multiple-multiply that! And it doesn't know of this instruction and returns.....Error, Illegal instruction. It will just stop and stall your system.

So what we are guessing around is:
    Is your new laptops CPU:
  • New enough
  • Or similar enough to your current one?
...which only matters, if you have set your CFLAGS accordingly.

Can you please post the output of emerge --info | grep CFLAGS and let us know which CPU is built into your new laptop?
This will allow us to guess the chances of your binaries being executable on your new machine.

@Jaglover,
Quote:
Then why all the trouble and transferring all the binaries? For emerge -e @world all you need is the contents of /etc/portage/* and your world file. And a few files from /etc/* (the ones which were edited by you). Using these configuration files the whole installation will be rebuilt exactly the same.
You'd have to move /home, a couple of files from /etc (find out which ones, if you're not so familiar with the system) and still you'd surely forget to transfer some file.
I do quite get your point, but instead of re-configuring a new system, I can just start the emerge and get a good night of sleep or hit the bars (once covid-19 is over).
Let's see how this turns out.
_________________
There's no stupid questions, only stupid answers.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 45383
Location: 56N 3W

PostPosted: Sat May 09, 2020 10:00 pm    Post subject: Reply with quote

dr_wulsen,

Real world example ... Once upon a time, a long time ago, in the days of the original Pentium CPU, Intel introduced the mmx (Multi Media eXtensions) instructions to a CPU called the Pentium-mmx.

This was the beginning of the Single Instruction Multiple Data (SIMD) instruction set extensions in the PC world.
AMD CPUs did not have the mmx instructions so could not execute code that used them. The applications would crash with Illegal Instruction errors.

Not be be outdone, AMD added 3DNow! to their CPUs. Intel CPUs knew nothing of 3DNow!
So we have the beginning of instruction set incompatibilities between Intel and AMD.
Its always been there between CPU generations, so newer CPUs are backwards compatible with older CPUs.
If you have a swap partition wholly within the first 2G of your HDD, you can install MSDOS 3.3 and Windows 3.1 there, even on modern hardware. Anyway, I digress.

In the beginning of the Linux world was the 386DX. No FPU, that was the very expensive optional extra 387DX
Linux could still execute FPU instructions. It went through The Illegal Instruction trap but instead of terminating the program, the kernel had an FPU software emulator, so that would emulate the FPU instruction (slowly) and once the kernel had completed the emulation, the program continued normally.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Princess Nell
l33t
l33t


Joined: 15 Apr 2005
Posts: 785

PostPosted: Sat May 09, 2020 10:59 pm    Post subject: Reply with quote

If the hw isn't identical, I wouldn't even research cloning.

My personal preference is a complete new install with a kernel config appropriate for the new hw. rsync /var/cache/distfiles to get a head start and save on some downloading. Then replicate the package setup (equery l \*) and compare contents of /etc on both machines, in particular but not exclusively /etc/portage, and adjust the new system according to preference.

Filesystems with non-Gentoo system content, like /home or /usr/local, if applicable, can be rsync'd after installation.
Back to top
View user's profile Send private message
dr_wulsen
Tux's lil' helper
Tux's lil' helper


Joined: 21 Aug 2013
Posts: 128
Location: Austria

PostPosted: Sat May 09, 2020 11:08 pm    Post subject: Reply with quote

@NeddySeagoon: Thank you for the real world example; I've thought of the Pentium1 (Bless the burnt chips I produced back then); but didn't want to cross the boundary between 32 and 64bit for this comparison.
This does get quite hard to explain is a simple example then, so the Pentium will do just fine :D
Thanks!
_________________
There's no stupid questions, only stupid answers.
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3653
Location: Illinois, USA

PostPosted: Sun May 10, 2020 1:37 am    Post subject: Reply with quote

NeddySeagoon wrote:
Now you will get horribly confused. As you have cloned the install, you have also cloned the identity of the donor system.
e.g. host name, ssh host keys, network setup ... if its static and both systems are on the same network, thats a very bad thing.

Hint: Edit /etc/fstab and /etc/hosts and /etc/hostname and /etc/init.d/net.lo (assuming Openrc). I'm assuming that the old system will remain on the LAN. iI not, you can just reuse the hostname and assigned ip address (if it's static). If both machines remain on the LAN you need to change the hostname and ipaddress.
Been thinking of this subject because I also want to clone but the mirror image of your case. I am reusing an old motherboard to build a new Gentoo machine that will replace an even older Win 7 machine (Athlon64 and must boot from an IDE drive). A new case ($40, a new cheapie small SATA SSD and a big fat WD Gold SATA drive to store recordings. The spare motherboard is a 2GB (maybe 4G) Athlon II X3. I want to clone a Phenom II X6 install. Both are AMD k10 family so I won't have the agony of rebuilding everything on a one lung machine. But the donor machine has immense /home and /root. everything else together is about 30GB. Easy to port to a 128GB SSD.

here you have a different architecture and want to keep /root and /home and will need to rebuild /usr/bin /usr/lib and such.

If you do have to extract a stage3, just extract those various bin and lib directories, not the whole stage3 or you will overwrite world and /etc and maybe /home. The world overwite at least recently happened to a forum member. No sense in emerging pev @world then copying world over and emerging all that on top. Might as well do it in one fell swoop.

There was mention of problems copying /proc and /dev on the forum. I plan to boot install medium on both host and donor, and use either rsync or scp to copy the files after mounting the drives on both machines. That way there will be no /proc or /dev to worry about copying. Just copy /mnt/gentoo/<xyz> to <new ipaddress>:/mnt/gentoo/

thats my thoughts.
Back to top
View user's profile Send private message
dr_wulsen
Tux's lil' helper
Tux's lil' helper


Joined: 21 Aug 2013
Posts: 128
Location: Austria

PostPosted: Sun May 10, 2020 1:41 am    Post subject: Reply with quote

@tony: where's the different CPUs?
I don't see a reply from the OP yet....
_________________
There's no stupid questions, only stupid answers.
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3653
Location: Illinois, USA

PostPosted: Sun May 10, 2020 3:15 am    Post subject: Reply with quote

dr_wulsen wrote:
@tony: where's the different CPUs?
I don't see a reply from the OP yet....


A bit of googling says he is moving from a Sandy Bridge to a Haswell. Will Sandy Bridge code run on a Haswell? I confess that I don't know. My last Intel was a 486DX-100
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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