0

I need to backup / copy the files of my Linux installation to an external drive, so that I can restore them onto the new, larger disk.

The destination disk for the restoration is twice as large, and will have larger partitions, ext4 and linux-swap. Imaging the entire disk or its first partition is not really a good option, because both require later re-partitioning I'd like to avoid.

I am backing up to an exFAT-formatted drive, there are some issues with copying an ext4 Linux installation to exFAT though

  • may destroy important hard links and fast* symbolic links from the ext4 file system (will break Linux)

  • won't preserve file ownership / permissions and setuid bits (will break Linux)

  • won't preserve capabilities (will break Linux)

  • won't preserve files extended attributes (xattrs) as well, as I believe many files have important information there (I don't care about Unix ACLs as I don't think I have any files using them)

If I copied the files directly to NTFS, FAT32, exFAT, etc, much of this metadata would be destroyed.

I don't care about compression since the original disk is smaller than my backup drive, but (GNU) tar seems to preserve only permissions/ownership (with -p and extract with --same-owner), links and xattrs, but file capability support is needed to backup modern Linux.

It seems the other main options are a CloneZilla Live system, and cpio which seems to create tar archives.

So the main options are

  1. CloneZilla or just imaging the parition
  2. tar itself, which may break things
  3. cpio, which may be limited by the tar archive format?

*80,000 of the 83,000 symlinks are fast symlinks, and I'd like to preserve their fast-ness if possible

  • this would be easier to read if you cited at least one example why you think tar is shaky! current versions support xattrs, but it looks like as of 2016 it did not support "file capabilities". bugzilla.redhat.com/show_bug.cgi?id=771927 – sourcejedi Oct 17 '18 at 19:03
  • You say you cannot mount an external ext4 if you are not root. I don't understand. Why do you want to mount an external ext4, without being root? You need to be root to copy the files and set their ownership etc. correctly. – sourcejedi Oct 17 '18 at 19:08
  • If you want a nice GUI to be able to mount ext4, which will prompt for sudo password as needed, GNOME Disks is pretty awesome. The package name should be gnome-disk-utility, in case you do not already have it installed. – sourcejedi Oct 17 '18 at 19:10
  • @sourcejedi comment #1: i found a post yesterday (can't find it now, maybe on AU) mentioning how GNU tar "may or may not" properly archive permissions / ownership but i can't find it now, but i guess the -p and --same-owner options do the standard Unix permissions alright – cat Oct 17 '18 at 20:25
  • @sourcejedi comment #2: the point is to have my "external USB disk for backup" formatted as ext4, so that I can directly copy my Linux system to it, and copy from it (those as root), and then also use it as a general purpose USB for other non-backup files as a regular user – cat Oct 17 '18 at 20:26
1

Per @cat's comment, posting my comment as an answer -

Have you considered making a sparse file the size of your old installation, formatting it as a ext4 file system, and mounting on loopback, then copying to that? Would solve all the permissions loss, etc. issues. exFAT's filesize limit is 16EiB, surely large enough.

And per @cat's comment back to me, apparently a single file big enough won't be an issue ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.