@[toc]

Back up Arch Linux

The installationpigz

Pigz multithreaded compression is significantly faster than tar single-threaded compression

sudo pacman -S pigz
Copy the code

The installationzstd

ZSTD multithreaded compression is significantly faster than tar single-threaded compression. Arch Linux Mailing list: ZSTD compression decompression speed compared to other compression decompression tools

sudo pacman -S zstd
Copy the code

pigzPackaging Arch Linux

–exclude Exclude paths or files. Select the paths or files to be excluded based on the mounting condition of the system.

Note: The current execution is under /

sudo tar --use-compress-program=pigz -cvpf arch-backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/arch-backup.tgz --exclude=/mnt --exclude=/sys --exclude=/run/media  --exclude=/media  /
Copy the code

zstdPackaging Arch Linux

–exclude Exclude paths or files. Select the paths or files to be excluded based on the mounting condition of the system.

Note: The current execution is under /

sudo tar -z -c -T0 -18 -v -p -f - arch-backup.zstd --exclude=/proc --exclude=/lost+found --exclude=/arch-backup.zstd --exclude=/mnt --exclude=/sys --exclude=/run/media  --exclude=/media  /
Copy the code

Partition or mount a new disk

usefdiskSuch as the disk tool partition

Refer to fdisk or your favorite disk tool for help. Don’t look for help. Or read someone else’s manual.

Mount a new hard disk partition to/mnt/arch

Create a disk mount directory

sudo mkdir -pv /mnt/arch sudo mkdir -pv /mnt/arch/boot/efi sudo mkdir -pv /mnt/arch/home .... // Create a mount directory for other partitionsCopy the code

Mount the disk partition to the corresponding mount point

sudo mount /dev/sdb3 /mnt/arch sudo mount /dev/sdb4 /mnt/arch/home sudo mount /dev/sdb1 /mnt/arch/boot/efi ... // Create a mount directory for other partitionsCopy the code

pigzRestore the ArchLinux system

The Linux everything file approach is very convenient for backup and recovery by restoring the current system backup to the new mount point.

sudo tar --use-compress-program=pigz -cvpf arch-backup.tgz -C /mnt/arch
Copy the code

zstdRestore the ArchLinux system

The Linux everything file approach is very convenient for backup and recovery by restoring the current system backup to the new mount point.

sudo tar -z -c -T0 -18 -v -p -f - arch-backup.zstd -C /mnt/arch
Copy the code

Create the folder you just excluded

sudo mkdir -pv /mnt/arch/proc
sudo mkdir -pv /mnt/arch/sys
sudo mkdir -pv /mnt/arch/run
sudo mkdir -pv /mnt/arch/dev
Copy the code

Get UUID

sudo lsblk 
Copy the code

Modify the/etc/fstabMount the file

You can use Genfatab to automatically generate/MNT /arch/etc/fstab files

sudo genfstab -U /mnt/arch >> /mnt/arch/etc/fstab
cat /mnt/arch/etc/fstab
Copy the code

You are advised to use a text editor such as vim to modify the /etc/fstab mount file

Note: *-chroot is the chroot used for arch. *-chroot is the chroot used for arch. You can also try copying to the Ventoy boot disk using the corresponding Linux*.iso (see Ventoy boot disk)

sudo arch-chroot /mnt/arch/

vim etc/fstab
Copy the code

Change the UUID. Change the mount point

Update Grub boot

In the ARCH-chroot mode, UEFI boot is used as an example. For DETAILS about MBR or other methods, see arch WiKi.

grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader=ArchLinux --recheck

update-grub
Copy the code

The editor/etc/mkinitcpio.confTo speed uplinux.imgspeed

Vim /etc/mkinitcpio.conf // Modify the last two lines of the configuration file // ZSTD support needs to be installed // pacman-syu ZSTD support needs to be enabled // Otherwise, use other compression algorithms COMPRESSION="zstd"
COMPRESSION_OPTIONS=(-c -T0 -18 -)
Copy the code

updatemkinitcpio

Mkinitcpio -p Linux/linux-lTS/Other kernel mkinitcpio -p linux-lts ==> Building image from preset: /etc/mkinitcpio.d/linux-lts.preset:'default'
  -> -k /boot/vmlinuz-linux-lts -c /etc/mkinitcpio.conf -g /boot/initramfs-linux-lts.img
==> Starting build: 5.4.84-1-lts
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [autodetect]
  -> Running build hook: [modconf]
  -> Running build hook: [block]
  -> Running build hook: [filesystems]
  -> Running build hook: [keyboard]
  -> Running build hook: [fsck]
==> Generating module dependencies
==> Creating zstd-compressed initcpio image: /boot/initramfs-linux-lts.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux-lts.preset: 'fallback'
  -> -k /boot/vmlinuz-linux-lts -c /etc/mkinitcpio.conf -g /boot/initramfs-linux-lts-fallback.img -S autodetect
==> Starting build: 5.4.84-1-lts
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [modconf]
  -> Running build hook: [block]
  -> Running build hook: [filesystems]
  -> Running build hook: [keyboard]
  -> Running build hook: [fsck]
==> Generating module dependencies
==> Creating zstd-compressed initcpio image: /boot/initramfs-linux-lts-fallback.img
==> Image generation successful
Copy the code

No need to acceleratelinux.imgspeed

Update mkinitcPIO directly

Mkinitcpio -p Linux /linux-lts/ other kernel mkinitcpio -p linux-ltsCopy the code

exitarch-chrootMention right model

exit
Copy the code

Unmount partitions

sudo umount /mnt/arch/home sudo umount /mnt/arch/boot/efi ... Sudo umount/MNT /arch/sudo umount/MNT /arch/sudo umount/MNT /archCopy the code

The migration completed

After the host is restarted, the newly added ArchLinux boot is displayed on the BIOS interface. Indicates that the migration is complete.