I’ve spent considerable time configuring my Linux system (1) and I would like to have the exact same system on another PC (2).
What would be the best way to do that?
Hardware on (2) is different, but tested compatible with the kernel.
(2) has a smaller drive size, so simply dd’ing the entire drive from a live USB won’t work.

Here’s what I’m planning:

  • install same distro on (2), using the same username as on (1)
  • create a list of installed packages on (1)
  • install same packages on (2) using the package manager
  • copy /home and /etc from (1) to an external EXT4 drive
  • boot (2) from a live USB and mount the external drive
  • delete /home and /etc on (2), then copy them over from (1)

Will this cause permission issues? Is there a quicker way?

  • nibbler@discuss.tchncs.de
    link
    fedilink
    English
    arrow-up
    3
    ·
    3 days ago

    fdisk/mkfs/mount (to /mnt) new drive in old system. copy all over. for i in proc dev sys; do mount -obind /$i /mnt/$i; done; chroot /mnt

    now you are in a chroot envrionment of your new drive.

    fix /etc/fstab, install grub to the new device, done.

    i think. if you have seperate /boot, care for that, too :D

  • shrugs@lemmy.world
    link
    fedilink
    English
    arrow-up
    4
    ·
    4 days ago

    In short, you can just copy your whole system, you can use rsync, cp or dd. Two things need to be taken care of:

    • uefi boot needs to be working (copy uefi partition from old drive or reinstall with grub from live iso)

    • partitions in /etc/fstab need to be configured correctly

    Everything else ist just the files and configs. Prefer using rsync -A over cp. In Linux everything is a file, except /dev and /procfs

    Don’t forget to fix hostname and network config if not using network manager.

    Your idea should work no problem btw. though, since uefi and fstab is taken care of by the previous clean install. You should probably not overwrite fstab in that case IMHO.

  • a14o@feddit.org
    link
    fedilink
    English
    arrow-up
    1
    ·
    3 days ago

    What you’re planning seems plausible.

    You could also resize the partition on (1) to fit on (2), then dd if=(1) of=(2)

    If you’re interested in structural changes that make this sort of thing easier in the future, look into

    • ZFS or Btrfs for flexible handling of subvolumes
    • NixOS or GUIX for applying system configuration across machines
  • isgleas@lemmy.ml
    link
    fedilink
    English
    arrow-up
    1
    ·
    4 days ago

    ReaR (RElax And Recover) can help you create a bootable “recover” installation on target system, once installed rsync your data

      • nesc@lemmy.cafe
        link
        fedilink
        English
        arrow-up
        1
        ·
        2 days ago

        Yes, it’s magic, I know. Smaller one needs to be large enough to fit data and partitions mustn’t be bigger then target and there might be some issues with gpt. Anyway it works fine with a similar sized or larger target without any additional configuration.

  • aarch0x40@piefed.social
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    4 days ago

    You could just use dd to copy the old drive over the new one then resize the partitions.  Or you could partition the new drive and dd copy the slices you want to cut over then resize the filesystems.

    • mech@feddit.orgOP
      link
      fedilink
      English
      arrow-up
      0
      ·
      4 days ago

      Can I dd from a bigger drive to a smaller one and expect all the data to come with it?
      (Assuming of course there’s not more data on the bigger drive than will fit on the smaller)

      • y0din@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        edit-2
        4 days ago

        No, dd won’t work reliably when copying from a larger drive to a smaller one. To do this, you would need to resize and align the partitions first, handling each partition individually, or use a different cloning method.

        A better approach is to use something like Clonezilla. In advanced mode, it allows you to clone from a bigger disk to a smaller one, provided that the used space on the source drive does not exceed the capacity of the target drive. Without this, it won’t be possible with any tool, not just dd.

        Here’s a tutorial for Clonezilla advanced mode:

        https://clonezilla.org/clonezilla-live/doc/11_lite_server/advanced/09-advanced-param.php

        (edit added link, and saw the second post just before me with the same answer, not trying to steal from it @[email protected], sorry!, you posted while I wrote mine, so please feel free to ignore this, feels so dumb to just delete posts)