Originally Posted by moraxu
I've archived my home directory accidentally by the following command on Ubuntu 12.10:
sudo tar -zcf /dev/sda1/home
All of a sudden, my desktop environment disappeared and I was unable to type on the terminal.
That command should have just resulted in an error message, "/dev/sda1/home: Cannot open: Not a directory", and done no damage. If what you really
tar -zcf /dev/sda1 /home
(with a space preceding "/home") then you have thoroughly destroyed whatever filesystem was on sda1 and overwritten it with a gzipped archive of /home. If that command ran to completion without error, then you probably do have a complete archive of /home.
What to do next depends on what was previously on the partition /dev/sda1. From the name and the GRUB error you get when booting, I suspect that was your root partition. If so, you will need to reinstall the system. Fortunately, you have the previous contents of /home, but you will need to save that on separate media (perhaps a USB flash drive) and restore it after the reinstall. If, from the LiveCD, you have the flash drive mounted on /mnt/tmp, then you can save that archive like this:
gunzip -c /dev/sda1 >/mnt/tmp/oldhome.tar
I suggest doing it that way because there is no easy way to find the size of that gzipped archive, and there is almost certainly no need to copy the entire /dev/sda1 partition. That gunzip command should terminate with the message, "gzip: /dev/sda1: decompression OK, trailing garbage ignored". If it happens that your flash drive is too small to hold the uncompressed image, then you could try recompressing it again:
gunzip -c /dev/sda1 | gzip >/mnt/tmp/oldhome.tar.gz
Either way, you will now have the previous content of /home, which you can restore after the reinstall.