LinuxQuestions.org
Help answer threads with 0 replies.
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 09-16-2010, 09:57 AM   #1
bks2010
LQ Newbie
 
Registered: Sep 2010
Posts: 1

Rep: Reputation: 0
accidentally moved entire linux root "/ " file system to another directory


Hi,
I am running fedora core 6 and was logged in as root. I was in my test log directory /log/test_log when I accidentally issued the following command "mv /log/test_log/5.0.0 /* /log/test_log/6.0.0" Please note that I mistakenly had a space between 5.0.0 and forward slash. It moved the entire root file system / to /log/test_log/6.0.0 directory. Is there way I can restore this back. Please help!!!!

Last edited by bks2010; 09-16-2010 at 10:00 AM.
 
Old 09-16-2010, 10:05 AM   #2
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,063

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
Sure, move it back. However since now most of your OS will not work you will probably need to boot off a livecd, mount the relevant fs(s) to any arbitrary mount point and move the stuff from there.
 
Old 09-17-2010, 05:42 AM   #3
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 675

Rep: Reputation: 136Reputation: 136
Quote:
Originally Posted by i92guboj View Post
Sure, move it back. However since now most of your OS will not work you will probably need to boot off a livecd, mount the relevant fs(s) to any arbitrary mount point and move the stuff from there.
While booting from livecd is definitely an option there is another one:
Code:
/log/test_log/6.0.0/lib/ld-linux.so.2 --library-path /log/test_log/6.0.0/lib /log/test_log/6.0.0/bin/mv /log/test_log/6.0.0/bin /log/test_log/6.0.0/lib /
After this command you'll get your /lib and /bin directories back and will be able in the sane way move the rest to it's correct place.
 
1 members found this post helpful.
Old 09-17-2010, 06:49 AM   #4
Kenny_Strawn
Senior Member
 
Registered: Feb 2010
Location: /usa/ca/orange_county/lake_forest
Distribution: ArchBang, Google Android 2.1 + Motoblur (on Motortola Flipside), Google Chrome OS (on Cr-48)
Posts: 1,791
Blog Entries: 62

Rep: Reputation: 56
Yes, but unless you get /boot back, you will not be able to boot into your main OS. You will have to boot the Live CD, mount your root filesystem, and move the files back.
 
Old 09-17-2010, 06:58 AM   #5
igadoter
Member
 
Registered: Sep 2006
Location: wroclaw, poland
Distribution: slackware 12.2, scientific linux 6.4, knoppix 7.2, salix 14.1
Posts: 854

Rep: Reputation: 79
For me most confusing is a pair of commands 'mv' and 'rm' - the former is a shorthand of 'move' the latter 'remove'. This way I accidentally removed some files.
 
Old 09-18-2010, 02:00 AM   #6
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 675

Rep: Reputation: 136Reputation: 136
Quote:
Originally Posted by Kenny_Strawn View Post
Yes, but unless you get /boot back, you will not be able to boot into your main OS. You will have to boot the Live CD, mount your root filesystem, and move the files back.
After executing command I wrote, /lib and /bin directories will be in place, i.e commands like mv, cp, rm, etc will work in the sane way. From this point one obviously have to move back all the parts of the system where they belongs, and in case Lilo used run /sbin/lilo too
 
Old 09-19-2010, 01:15 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
It might also be a good time to point out that FC6 has not been updated in yrs (current is F12 or 13?), so it's probably wide open to exploits etc.
Why not take this opportunity to get a current OS?
 
0 members found this post helpful.
Old 09-19-2010, 02:54 AM   #8
tommyttt
Member
 
Registered: Oct 2009
Location: Federal Way, WA
Distribution: openSUSE 11.4 x86_64, openSuSE 12.1, Fedora 15
Posts: 207

Rep: Reputation: 34
Quote:
Originally Posted by bks2010 View Post
Hi,
I am running fedora core 6 and was logged in as root. I was in my test log directory /log/test_log when I accidentally issued the following command "mv /log/test_log/5.0.0 /* /log/test_log/6.0.0" Please note that I mistakenly had a space between 5.0.0 and forward slash. It moved the entire root file system / to /log/test_log/6.0.0 directory. Is there way I can restore this back. Please help!!!!
And you've now learned a lesson. Always be extremely careful what you do as root, the rm and mv commands cam make your system completely unusable.

Tom
 
Old 09-19-2010, 06:07 AM   #9
harryhaller
Member
 
Registered: Sep 2004
Distribution: Slackware-14.0
Posts: 452

Rep: Reputation: Disabled
Quote:
Originally Posted by Valery Reznic View Post
While booting from livecd is definitely an option there is another one:

Code:
/log/test_log/6.0.0/lib/ld-linux.so.2 --library-path /log/test_log/6.0.0/lib /log/test_log/6.0.0/bin/mv /log/test_log/6.0.0/bin /log/test_log/6.0.0/lib /
After this command you'll get your /lib and /bin directories back and will be able in the sane way move the rest to it's correct place.
An excellent idea!

I've had the same problem, but I was not signed in as root, so the files got copied, but the subsequent delete couldn't take place because I didn't have the authority.

mv is copy-then-delete. It is really best to copy, then check, and only then do deletes. But mv is so much easier, isn't it?

For the job that the OP was doing, I would have used a file manager such as mc (midnight commander). The risks are much less!

Valery's solution is super!
 
  


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
HELP!!!! I moved my entire root directory somewhere else!!!! a_cheung Linux - Newbie 11 12-06-2009 07:52 PM
"mount: not a directory" pmount error when file system is out kaz2100 Linux - General 0 12-18-2007 03:10 PM
System hangs on boot - "Mounting root file system" fails with Via VT6410 enabled Eagleorn Linux - Hardware 3 09-21-2006 01:58 PM
How do I put my entire system into "root", not just the konsole? GameGuru Linux - Newbie 11 07-04-2005 02:21 PM
accidentally renamed my root " / " directory rioguia Linux - Newbie 24 10-28-2004 03:47 PM


All times are GMT -5. The time now is 11:12 AM.

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