How can I copy Fedora instance to different machine with SELinux enforcing
I have a fully operational and somewhat customized instance of Fedora 27 on a partition of a Lenovo laptop (two other partitions run Windows and another Linux distro), and my goal is to copy that instance to another computer.
My Fedora 27 instance on that partition includes all files in /
, with only /boot/efi/
on a separate partition (i.e., the EFI partition). I use rEFInd as my boot manager rather than GRBU2. I want to copy the entire partition from my Lenovo and install it on a partition of another machine. But doing so with SELinux set to enforcing leads to a "failed to start user manager for uid 42" error on startup.
I can do this using tar if I set SELinux to permissive before making the copy. Then I just do a variant of this command to tar the partition and copy it to a USB drive: sudo tar -cvpzf /media/USB/Lenovo.tar.gz /
. The resulting file can be extracted to a formatted partition on a separate computer using: sudo tar -xvpzf /path/to/backup.tar.gz -C /mnt/path/to/destination/partition --numeric-owner
. This works only if (1) SELinux was set to permissive whenacreating the initial tar file and (2) I copy the hex(?) directory (e.g., dd4c76acf7654c97A07a024c5b8946222) in the source computer's /boot/efi/
to the destination machine's /boot/efi
directory. [Note: you also have to change the UUID on the destination machine's /etc/fstab
and /boot/refind-linux.conf
files to match that partition's UUID].
The problem with this approach is that I cannot then set SELinux to enforcing on the new machine. It will get the same error as if I had copied the source machine with SELinux set to enforcing. I am new to SELinux, so perhaps there is a way to essentially reset the SELinux labels for the new machine. If so, that would be close enough to a solution.
I was coming at it from the other direction, however, by trying to tar the files on the source machine in a manner that maintains the SELinux settings. I tried sudo tar --selinux --acls --xattrs -cvpzf /media/USB/Lenovo.tar.gz /
to achieve that end, but it did not work.
I am hoping someone out there in the Fedora world has multiple computers and likes to move instances of there favorite, fully-functioning distro across machines. If so, please help?