[SOLVED] Archived /dev/sda1/home by accident - system unable to boot
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
You specified '/dev/sda1/home' as the output file for tar. (The -f option.)
Since you didn't specify any input, tar would've (I think) defaulted to 'stdin', which in this case would have been whatever you kept typing.
The command line didn't return to a prompt, I'm assuming; it just let you keep typing?
Unfortunately, in this case, everything that was on your /dev/sda1 partition is probably gone for good. The entirety of the data on it would've been overwritten from the first bit by a gzipped tar "file" named 'home', hence the "unknown file system" errors.
It sounds like you have filesystem corruption, a tar is not going to remove your existing content. At this point I would run an fsck and see if it resolves your issues, this could have been caused with tar trying to archive file locks and corrupting file meta data. A quick fsck will probably correct this.
---------- Post added 12-26-12 at 10:06 AM ----------
I've archived my home directory accidentally by the following command on Ubuntu 12.10:
Code:
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 did was
Code:
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:
Code:
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:
By writing to the /dev/sda1 you have overwritten the file system. There is no undoing your mistake. Your only choices are to restore from a known good backup if that exists or to reinstall.
How was the drive partitioned? I assume that /sda1 is your / partition due to the description of events. What is /sda2? Is it /home or a data drive etc. If necessary there are tools that can help you recover data like photorec and testdisk.
Should not have done any damage, unless there is more to the command that the OP left out I don't think the sda1 partition is blown. I just ran the command on a centos vm for giggles and it did not do any damage. There is some info being left out here or its just a simple file system corruption and an fsck should fix it.
Also, remember that you cant hit folders directly from the drive path... /dev/sda1/etc/ is not a valid path just like /dev/sda1/home is not a valid path. Linux sees /dev/sda1 as a special block file. Linux reads and treats everything as a file including hardware and drives.
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.
Correct, it was my root partition. I've reinstalled the system and restored my /home folder. Now everything's fine. Thanks for your explanations guys.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.