• Transfer Arch installation to new hard drive


    This is more of a general Arch question and I tried asking on the Arch forums but any mention of the Arch installers (Antergos, Manjaro, etc) gets your post closed and you get warned not to do it.

    I currently have an Antergos Arch install on a laptop and the HD is failing.
    Currently my system has a few servers running, custom configs, etc. A Teamspeak server, nginx w/ nodejs backend Lolisafe, MySQL, php-fpm, custom sshd, a custom Google Auth libpam setup, tons of things installed, a whole bunch of stuff. Things in /etc, /opt, /srv, /var.

    I was told on the Arch forums I can use rsync:

    rsync -aAXH --info=progress2 --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/home/*/.thumbnails/*","/home/*/.cache/mozilla/*","/home/*/.cache/chromium/*","/home/*/.local/share/Trash/*","/lost+found"} / /mnt
    

    and afterwards I update /etc/fstab and the bootloader configuration.
    Alright so I run rsync then what? Boot a live Antergos USB, run blkid or lsblk -f and get the UUID to update /etc/fstab? Would I even need to update the bootloader at that point? Really not sure what needs to be done after rsync.

  • @samstarnes
    Moving a system to another drive is quite straightforward. Just as they said, you need to:

    1. copy the whole system
    2. adjust /etc/fstab in the new system
    3. update the bootloader (wherever it is)

    So, phase 1 could mean booting with the USB installer stick (or another linux on the same machine if you have any). Then a normal copy like should work:

    # root permissions needed
    mkdir /d-from /d-to
    mount /dev/sdXN /d-from
    mount /dev/sdYM /d-to
    cp -a /d-from/* /d-to/
    sync
    umount /d-from
    umount /d-to
    rmdir /d-from /d-to
    

    where XN refers to the old disk partition, and YM refers to the new disk partition, adjust them as is fit. X and Y are single letters, and N and M are small numbers. Note that partitions to the new disk can be created by e.g. gparted.

    Then phase 2 is needed to set the partitions on the new disk properly, since UUIDs have changed (if using them). You can use e.g. the nano editor.

    Phase 3 depends on where your bootloader is and who (i.e. which OS) controls it. I assume you have grub as bootloader. If you have several Linux installations on a disk, you need to know which of them is in control of booting. But you said that the disk is failing, so I guess you have only Antergos on that old disk, and it also controls booting.

    Next step depends on whether you have UEFI or legacy BIOS boot. See more at
    https://wiki.archlinux.org/index.php/GRUB.

    Again you need to boot with the USB installer stick. You need to chroot to the new disk root partition, something like

    mount /dev/sdYM /mnt   # Y and M as before
    arch-chroot /mnt
    

    Now you are on the new system, and the following commands should be run in that state.
    On BIOS boot, run commands

    grub-install /dev/sdY      # Y as before
    grub-mkconfig -o /boot/grub/grub.cfg
    

    and you’re done.

    But on UEFI system, you need to find the ESP (a small partition with vfat or fat32 filesystem) e.g. with command

    lsblk -fm
    

    and then (assuming ESP is in /dev/sdZP, adjust Z and P again!)

    mkdir -p /boot/efi
    mount /dev/sdZP /boot/efi
    grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=antergos_grub
    

    Last but not least, run command

    grub-mkconfig -o /boot/grub/grub.cfg
    

    and you should be good to go.

  • @samstarnes

    It’s antergos the operating system installed on this disk only?

    Can read the HD?

    If the anwser is yes

    Clone disk is easy.

    Did i miss something?

  • Ideally I don’t want any downtime for the current (old hard drive) since I am running a few servers. I’ve seen some videos and people do run rsync while the system is running. So I run the rsync command but it seems like it’s hanging indefinitely.

    I’ve found a post on linuxquestions that’s sort of related to my issue. Old drive dying and it seems to get stuck on journal files in /var/log/journal and he thinks it’s related to ACLs, the same place my rsync is currently stuck on.

    In more simpler terms…
    Do rsync from old HD to new HD
    run the live installer
    mount the new HD
    arch-chroot the mounted HD
    grub-install /dev/newHD
    grub-mkconfig -o /boot/grub/grub.cfg

    yes?

  • Ah nevermind, I figured it out. Took me some time but I finally realized I was making it harder than necessary.

    For people that need to do this I’ll explain it in simpler terms.
    On the new HD, I used gparted (I used gparted through the live USB for ease of use) to make 3 partitions:
    1st partition, swap, 4gb (or half your ram), turn swap on, label it “swap”
    2nd partition, ext4, 10gb, /boot, set it to “boot”, and label it “boot”
    3rd partition, ext4, the rest of your HD space, /, label it “root”
    Set a random UUID for each partition

    Now for my method of rsync, I had the old HD running Arch and mounted the new HD through a USB dock. Doesn’t matter if you do it this way or have them both connected to a PC & run a live USB. I wanted minimal downtime so I kept my old version of Arch/Antergos running.

    sudo mount /dev/sdYr /mnt
    (where Y is the new HD and r stands for the root partition number)
    run blkid or 'lsblk -f' to figure out what the /dev/sdYr root partition name is'
    

    my example was “sudo mount /dev/sdc1 /mnt” where /dev/sdc1 pointed to the “root” partition
    /dev/sdc = new HD
    /dev/sdc1 = root partion on the new HD

    Running rsync

    rsync -aAXHvvu --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/home/*/.thumbnails/*","/home/*/.cache/mozilla/*","/home/*/.cache/chromium/*","/home/*/.local/share/Trash/*","/lost+found","swapfile","/var/log/journal/*"} / /mnt
    

    Set anything else you want to exclude in the “exclude” list. I did the “vv” option to see a more verbose list of files updated or not updated and “u” for ‘skip files that are newer on the receiver’. Not sure if “swapfile” is necessary but it didn’t break anything & I’ve seen someone do that before.
    After everything has synced to the new HD, you need to modify the /etc/fstab on the new HD to match the new UUID’s
    You can either run

    blkid 
    lsblk -f
    

    It doesn’t matter which one. Both will show UUID’s of the partitions. Keep note of these.
    Make sure you have the new HD mounted still and do

    sudo nano /mnt/etc/fstab
    

    Update the UUID’s of the previous boot, root, and swap to the new ones. For Antergos it should be “AntergosRoot” and “AntergosBoot”.

    After that’s finished, unmount the HD with

    umount /mnt
    

    Boot up a live Arch USB/CD and mount the new HD root partition again and run arch-chroot /mnt

    mount /dev/sdXN /mnt
    arch-chroot /mnt
    

    You’ll be reinstalling/configuring Grub for the drive, not the partition so do

    grub-install /dev/sdX
    grub-mkconfig -o /boot/grub/grub.config
    

    That’s it, you’re done.

  • 10GB for /boot partition is way to much, needs 250MB min as it only carry grub files and Kernelimages.
    And for cloning old hd to new one I would take same sizes as old one carry.

  • @joekamprad Ah, you’re right. I did a typo with the 10g :P I meant 1g which is still much more than necessary but it was an old habit when I used to really be into Linux.
    For root and swap though, I wanted to redo how much I used since for some reason when I first setup Antergos it set swap as 6gigs? Which is the exact amount of ram in my laptop. Not sure why it did that. Giving a little extra back to root was nice and I also didn’t need a /home partition like I had done on the first install.

  • depending on what the system is used for, /home is not needed that much if you run as a server, server stuff mostly under /srv/ (for archlinux) and swap is default set to the same amount as real ram installed…

installation326 arch52 transfer6 Posts 8Views 948
Log in to reply
Bloom Email Optin Plugin

Looks like your connection to Antergos Community Forum was lost, please wait while we try to reconnect.