LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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, 08: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 09:00 AM.
 
Old 09-16-2010, 09:05 AM   #2
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
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, 04:42 AM   #3
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
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, 05: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, 05:58 AM   #5
igadoter
Senior Member
 
Registered: Sep 2006
Location: wroclaw, poland
Distribution: many, primary Slackware
Posts: 2,717
Blog Entries: 1

Rep: Reputation: 625Reputation: 625Reputation: 625Reputation: 625Reputation: 625Reputation: 625
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, 01:00 AM   #6
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
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, 12:15 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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, 01: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, 05:07 AM   #9
harryhaller
Member
 
Registered: Sep 2004
Distribution: Slackware-14.2
Posts: 468

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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:25 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
Open Source Consulting | Domain Registration