LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 12-26-2012, 10:17 AM   #1
moraxu
LQ Newbie
 
Registered: Dec 2012
Distribution: Ubuntu
Posts: 15

Rep: Reputation: Disabled
Unhappy Archived /dev/sda1/home by accident - system unable to boot


Hi there,

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.

After restart, I'm getting the error:

Code:
error: unknown filesystem
grub rescue >
Here's my paste from Boot-Repair tool executed by means of LiveCD:

http://paste.ubuntu.com/1467300/

My question is - where should I type the opposite command for extracting?

Code:
sudo tar -zxf /dev/sda1/home
Assuming it'll fix my problem...
 
Old 12-26-2012, 12:04 PM   #2
foodown
Member
 
Registered: Jun 2009
Location: Texas
Distribution: Slackware
Posts: 611

Rep: Reputation: 219Reputation: 219Reputation: 219
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.
 
Old 12-26-2012, 12:05 PM   #3
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 414Reputation: 414Reputation: 414Reputation: 414Reputation: 414
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 ----------

Check out http://www.cyberciti.biz/faq/howto-b...x-rescue-mode/
 
Old 12-26-2012, 12:14 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 2,959

Rep: Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268
Quote:
Originally Posted by moraxu View Post
Hi there,

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:
Code:
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.
 
1 members found this post helpful.
Old 12-26-2012, 12:19 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,930

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
Welcome to LinuxQuestions.

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.

Was that the exact command used?

Last edited by michaelk; 12-26-2012 at 12:23 PM.
 
Old 12-26-2012, 12:24 PM   #6
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 414Reputation: 414Reputation: 414Reputation: 414Reputation: 414
The command:

Code:
tar -zcf /dev/sda1/home
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.
 
Old 12-26-2012, 12:27 PM   #7
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 414Reputation: 414Reputation: 414Reputation: 414Reputation: 414
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.
 
Old 12-26-2012, 01:02 PM   #8
moraxu
LQ Newbie
 
Registered: Dec 2012
Distribution: Ubuntu
Posts: 15

Original Poster
Rep: Reputation: Disabled
You're right of course rknichols, I've typed:

Code:
tar -zcf /dev/sda1 /home
Quote:
Originally Posted by rknichols View Post
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.

Regards.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does system always prompts that /dev/sda1 is already mounted or mount point busy chinabenjamin66 Linux - Newbie 5 09-30-2012 11:19 PM
[SOLVED] installing Slackware 13.37 as a virtual machine. unable to mount /dev/sda1 kevinamygrayson Slackware - Installation 4 08-22-2012 04:35 PM
/dev/sda1 Warning: Unable to find mountpoint MooseMagnet Linux - Newbie 6 08-13-2008 12:55 AM
Grub Dual Boot /dev/sda1 /dev/hda1 jono268 Debian 4 01-14-2005 05:54 AM


All times are GMT -5. The time now is 02:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration