Note: I am doing this to learn more about linux. I understand there are other tools that can be used with simple interfaces.
Note: I am using Fedora 23. I have it installed physically on an SSD and my goal is to move it into a virtual machine.
Before using tar, I have successfully used
rsync. I would
rsync my entire file system directly onto a partition formatted with
ext4. I would then set up a virtual machine and boot with a liveCD, mount the partition, and rsync the files back. After that, I update my
fstab, re-install grub and generate the grub configuration file, and finally generate a new
I would like to use tar now so I can store backups of my system in a single archive file and have it compressed.
I use this command to create the tar:
tar -czpf /path/to/backup.tar.gz /path/to/fs/
Note that the path to the FS I am archiving is the same files that I rsynced to a temp directory. It does not include folders such as
proc, dev, sys, etc.
And then I boot up the VM using a livecd, mount the partitions, and then use this command to extract the tar as
tar -xzpf /path/to/backup/file -C /path/to/new/partition
When I update the same files as I did with rsync, I reboot and get to the login screen. However, logging in as root (using tty) or as my user does not work. It simply sends me back to the login screen -- I am stuck in a login loop.
I found out that when tar extracts files owned by
amoghrabi, it will replace the user as
liveuser. This is because tar uses the file system's
passwd file to match users. If it cannot find the user name, it will match by
As a possible solution, I have tried updating the live system's
passwd file and
group file with the ones from my original filesystem. This does not work.
I have read about using the flag
--same-owner, but this does not work in my case because the
passwd file of the livecd filesystem does not contain the original users of the system I am restoring.
What are my options here to successfully restore my system as I did with rsync?
To avoid confusion, I am booting from a liveCD and mounting
/dev/sda1, the partition I want to restore my backup to. I am un-taring the backup to this partition and then chrooting (while still in the liveCD environment) to modify
grub, and re-generate the
initramfs file. After the process of un-taring my backup to
/dev/sda1 is complete, it appears that
amoghrabi, my user in my backup, no longer owns its files (e.g.
/home/amoghrabi/ and instead, the files are owned by
liveuser. I believe this is because the
/etc/passwd file on the liveCD has UID of
1000, which is the same UID for
What can I do in this case? I have already tried restoring my
/etc/group file to the liveCD environment before un-taring my backup. This fixed the issue where the user
amoghrabi home directory is owned by
amoghrabi, but I still get stuck in a login loop which I believe is the cause of something not having the correct permissions from the un-taring process.
My end goal here is to be able to boot into
/dev/sda1 and have a working copy of my system, with the use of
tar to store my backups.