Skip to content

Instantly share code, notes, and snippets.

@b-Tomas
Last active September 21, 2024 17:19
Show Gist options
  • Save b-Tomas/834078c2b0ec8bbae5053e1cffc7d21b to your computer and use it in GitHub Desktop.
Save b-Tomas/834078c2b0ec8bbae5053e1cffc7d21b to your computer and use it in GitHub Desktop.
RSync a whole Linux filesystem (sorta) - Pop-OS!
# Move an installation of Pop-OS! from one disk to another.
# Useful guide if transferring data from a non encrypted install to an encrypted install.
# Create a fresh install of Pop-OS! in the new drive, and operatating from the live env do:
# unlock encrypted partitions
sudo udisksctl unlock -b /dev/<part>
# mount partitions
sudo udisksctl mount -b /dev/mapper/data-root # Or some other alias returned earlier
# REPEAT ABOVE FOR SOURCE AND DESTINATION
# Copy /etc/fstab from both systems to be able to merge them later
sudo cp /media/<src>/etc/fstab Desktop/fstab_src
sudo cp /media/<dst>/etc/fstab Desktop/fstab_dst
# Copy over files. Important: Do not foget the trailing slashes
# Note that /boot/ is ignored. The kernel will be "fresh"
sudo rsync -aAXv /media/<src>/ \
--exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/media/*","/lost+found","/boot/*"} \
/media/<dst>/
# Merge both /etc/fstab files copied earlier to make sure the system will pick up the right partitions from the right disks
# Use fstab_dst (the one that was in the destination filesystem) as a base, and add the custom stuff you did (like external drive mounts) on the old installation.
sudo gedit Desktop/fstab_src Desktop/fstab_dst Desktop/fstab_new
sudo cp Desktop/fstab_new /media/<dst>/etc/fstab
# Broken? Maybe chroot can help https://support.system76.com/articles/login-from-live-disk/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment