:: Re: [DNG] moving to a new system
Top Pagina
Delete this message
Reply to this message
Auteur: Adrian Zaugg
Datum:  
Aan: dng
Onderwerp: Re: [DNG] moving to a new system
In der Nachricht vom Saturday, 25 June 2022 15:32:21 CEST schrieb Marjorie
Roome via Dng:

> (1) Replicate your existing system on the new hardware, maybe with a
> different disk/partition structure from what you have now. And then
> upgrade to Devuan.


This is the easiest method mentioned, because you keep all your installed
programs, special settings and all your modifications. More detailed, but
certainly not complete:

- Boot your old and your new system with a live cd, I use GRML (grml.org):
    - dd the grml iso to a USB stick, boot from it
    - old system, choose run from RAM, unplug the stick after booting
    - new system with same stick, choose graphical, edit the
    entry and add toram at the end, boot


- if your new system has bigger or disks of the same size: use dd over network 
(else use tar, see below)
    - on the old system
    dd if=/dev/sda bs=64K | nc -N -l -p 10000
    - on the new system
    nc <ip of old system> 10000 | dd of=/dev/nvme0n1

    
    * set the disks right: sda and nvme0n1 are just examples, for moving
    to md raids, create and start it on the new system
    * if you are not alone on your net, use encryption:
        - set a password for the user grml and root on old
        - start the ssh server: service ssh start
        - ssh from the new box into the old forwarding port 10000
        ssh -L10000:localhost:10000 <ip of old system>
        - then use localhost instead of <ip of old system> above
        - do not execute the commands in the shell where ssh is
        running, just use ssh for the port forward (might use -f
        instead, see man ssh) and use another shell for dd
    * if you need progress indication: use pv
        - apt install pv
            dd if=xy bs=64K | pv | nc ....
        resp.
            nc ... | pv | dd ...
    * if you are impatient, use compression with lzop
    (speeds over 1 Gb possible on GbE!)
        on the old system inject:
            dd ... | lzop | pv | nc ..
        into the piped commands, on the new system
            nc ... | lzop -d | pv | dd ...
        (before or after pv)
    * if you are even more impatient test values for bs, 1M is also a
    good value to try with (you can just stop with ctrl-c and restart,
    use jnettop and/or iotop)


=> dd clones your boot sector, partition table etc., so you do not need to 
make your new system bootable again after cloning, if
    - your disk are of the same size and type (hdd vs. SSD)
    - you do not need to change from MBR to UEFI
    - you do not need to change disk labels from msdos to GPT
    - you didn't use partitionable md raids (auto=mdp)
    and
    - you are happy with the old partitioning scheme you used
just boot and continue to crossgrade to Devuan.


- You may now repartition your disk using gparted, you basically can change 
everything (size, order, etc.), if you need to change booting from BIOS to 
UEFI, use gdisk first to migrate (search for a tutorial online)
    - don't forget the EFI system partition if you need it
    - make a separate /boot as your first partition (but after EFI
    system part.) for easy cloning and repartioning in the future


- mount your root under /mnt/mysys

- if you introduce new partitons:
    - format the new partition
    - mount the new partion under /mnt/xy
    - mv everthing what belongs there, e.g. from /var
    mv -v /mnt/mysys/var /mnt/xy
    - change /mnt/mysys/etc/fstab
    (use blkid to find UUID)
    - unmount /mnt/xy and mount under the right location
    under /mnt/mysys/...
    - repeat for all new partitons


- edit /mnt/mysys/etc/fstab to set the mount options you like (-> e.g.
discard, ...on ext4 journal_cheksum, journal_async_commit, remount-options,
...)

- check all mount points have the right permissions (e.g. t flag on /tmp)

- you may also use tar to get to this point, e.g. when your new system has 
smaller disks (partition the new system, format, mount (see above) and tar):
   old system:
    - create a file /root/x containing: ./proc ./sys ...each on a
    separate line
    - mount your old system under /mnt/oldsys including all partitions
    on the right mount point
    - copy:
    tar -X /root/x --show-omitted-dirs -clf - -C /mnt/oldsys . \
    2>/tmp/tar.err | pv | lzop | nc -N -l -p 10000
   new system:
    - check all partitons are mounted right as they belong together
    (see above under the dd method)
    - ssh into old system (see above) for port forwarding, use in
    another shell than ssh:
    nc localhost 10000 | lzop -d | \
    tar --totals --atime-preserve -xvpf - -C /mnt/mysys 2>/tmp/tar.err
    - check tar.err on each system to see if copying went well


- make your new system bootable (check, that all partitions are mounted under 
their right place in /mnt/mysys/... before continuing):
    - mount -o bind /dev /mnt/mysys/dev
    - mount -o bind /dev/pts /mnt/mysys/dev/pts
    - mount -t sysfs /sys /mnt/mysys/sys
    - mount -t proc /proc /mnt/mysys/proc
    - chroot /mnt/mysys /bin/bash


    - grub-install
    - update-grub


    * on systems with partionable md devices see: 
    https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1756517
    how to work around grub-probe bug
    * fix /etc/mdadm/mdadm.conf if needed
    * changeing to UEFI from BIOS, use efibootmgr to write your boot
    entries to your system, check the content of /boot/efi/EFI/debian


- exit the chroot, unmount all, reboot into your new system, if it doesn't
boot, fix your problem under the live environment in your chroot.

- crossgrade to Devuan, search for a tutorial online, basically it involves:
    - edit your /etc/apt/sources.list: remove the Debian entries and add
    a Devuan mirror close to you 
    (see https://pkgmaster.devuan.org/mirror_list.txt)
    - install the devuan keyring (use https not http when downloading!):
    wget https://pkgmaster.devuan.org/devuan/pool/main/d/devuan-keyring/
        devuan-keyring_2017.10.03_all.deb
    dpkg -i devuan-keyring_2017.10.03_all.deb
    - apt-update ; apt dist-upgrade
    - install sysv or another supported init 
    - remove systemd



I hope I did get it right here.
Good luck!

Regards, Adrian.