View previous topic :: View next topic |
Author |
Message |
yenwc n00b
Joined: 27 Dec 2003 Posts: 9
|
Posted: Fri Jan 14, 2005 7:32 pm Post subject: moved /bin, /lib, /usr, and more to /root. need suggestions |
|
|
I had a stage tarball and its md5 chekc file under / and I decided to move them to /root.
As I logged in as root, I accidentally gave this command with a typo:
Code: |
mv stage1-blahblah-tar.gz * ~]
|
Note there is a SPACE between the file name and the star !!
So directories except /dev, /proc, /sys, /root were moved to /root !!
Now I can't execute anything, such as cp, ls, cat, mount ... in order to restore everything back to normal. For the binaries and its libraries are now in a wrong place. What works, are those cached in memory, such as cd, [, echo..., nothing else.
I also dare not to reboot. Because an XFS file system is on this hard drive, which in nature caches lots of transactions in memory. Due to the above mentioned problem, the hard disk will not be correctly umounted, I am not even sure if it will properly shutdown. If I am lucky, I can reboot the machine using a livecd or something alike to remount and fix the harddisk. But the risk is there. Therefore I would like to ask for your suggestions or any remedy to this. Thank you.
Last edited by yenwc on Fri Jan 14, 2005 8:52 pm; edited 1 time in total |
|
Back to top |
|
|
orionrobots Apprentice
Joined: 07 Oct 2003 Posts: 289 Location: London, Uk
|
Posted: Fri Jan 14, 2005 7:38 pm Post subject: |
|
|
If you have not rebooted yet - you may be able to do mv by giving the full path - ie:
/root/usr/bin/mv
and moving it all back.. Have a go - that may be the best way out...
You may need to add /root/usr/bin to your path, and /root/usr/lib in your lib paths if that didnt work. _________________ Danny Staple, curator of http://orionrobots.co.uk
Adopt an unanswered post initiative https://forums.gentoo.org/search.php?search_id=unanswered |
|
Back to top |
|
|
jonnevers Veteran
Joined: 02 Jan 2003 Posts: 1594 Location: Gentoo64 land
|
Posted: Fri Jan 14, 2005 7:41 pm Post subject: |
|
|
orionrobots wrote: | If you have not rebooted yet - you may be able to do mv by giving the full path - ie:
/root/usr/bin/mv
and moving it all back.. Have a go - that may be the best way out...
You may need to add /root/usr/bin to your path, and /root/usr/lib in your lib paths if that didnt work. |
okay
this is what I would do. reboot into a gentoo livecd, mount the root dir at /mnt/gentoo
and manually 'mv -R' the incorrectly moved directories back to where they should be
hopefully all permissions and ownership were perserved.
something like
Code: |
mv -R /mnt/gentoo/root/dev /mnt/gentoo/dev
|
|
|
Back to top |
|
|
orionrobots Apprentice
Joined: 07 Oct 2003 Posts: 289 Location: London, Uk
|
Posted: Fri Jan 14, 2005 7:44 pm Post subject: |
|
|
Like he suggested - rebooting at this stage might be a really bad idea.
Can you run sync first? to sync drives and caches? If you can, then you may be able to safely reboot. But I really stress - try and use mv first. _________________ Danny Staple, curator of http://orionrobots.co.uk
Adopt an unanswered post initiative https://forums.gentoo.org/search.php?search_id=unanswered |
|
Back to top |
|
|
kiksen Guru
Joined: 24 Jun 2002 Posts: 401 Location: Denmark
|
Posted: Fri Jan 14, 2005 8:00 pm Post subject: serious mistake... |
|
|
Hi.
One of the more unpleasent typos!
Can you execute commands like e.g. /root/bin/mv
/kiksen |
|
Back to top |
|
|
yenwc n00b
Joined: 27 Dec 2003 Posts: 9
|
Posted: Fri Jan 14, 2005 8:33 pm Post subject: |
|
|
thanks to your replies
no, mv does not work, even i cd into /root/bin. in fact, almost no exexcutables are working (as said, libraries are now in /root/lib). I can use echo (that still works) and some redirections to save some text files... but not binaries ones (since cat is dead).
cp/dd is dead too. so that compiling a hardcoded coreutils on another machine and COPY it over is not feasible.
i cannot imagine that i would lose all my work and data (15G) in the last 6 months...
still welcoming more suggestions other than the reboot/livecd/mount solution...
yes... it is the one of the most unpleasant typos. I once met a guy who would like to copy some hidden files to somewhere else gave this quite disasterous command
|
|
Back to top |
|
|
jonnevers Veteran
Joined: 02 Jan 2003 Posts: 1594 Location: Gentoo64 land
|
Posted: Fri Jan 14, 2005 9:16 pm Post subject: |
|
|
okay, rebooting cannot be a problem.... if you moved all your / dirs into /root...
you know where they all went and how to move them back...
but I mean, you could try something like finding a static build version of 'mv'... that would solve the library problems... |
|
Back to top |
|
|
titan100 n00b
Joined: 06 Sep 2004 Posts: 61
|
Posted: Fri Jan 14, 2005 9:34 pm Post subject: |
|
|
Well, these are the dangers of being logged in as root, personally I refrain from using the *, but why won't you just mount it and move them back from there ? Or at least get access to the network and save the stuff you where talking about ?
That other than getting a static linked mv is the only solution. _________________ http://www.thoron.org |
|
Back to top |
|
|
Gentree Watchman
Joined: 01 Jul 2003 Posts: 5350 Location: France, Old Europe
|
Posted: Fri Jan 14, 2005 11:27 pm Post subject: |
|
|
I see no prob in using a suitable liveCD.
Either a gentoo or a knoppix (the latter is much better equipt but either will do to move back your files)
If you have an R4 partition you will need the R4 liveCD that you can find a link to in this forum.
Next time ls before you leap:
Code: | ls blah-blah*
mv !$ ~
|
hth _________________ Linux, because I'd rather own a free OS than steal one that's not worth paying for.
Gentoo because I'm a masochist
AthlonXP-M on A7N8X. Portage ~x86 |
|
Back to top |
|
|
orionrobots Apprentice
Joined: 07 Oct 2003 Posts: 289 Location: London, Uk
|
Posted: Sat Jan 15, 2005 12:32 am Post subject: |
|
|
Offtopic - but gentree- I really like your sig!
I also didnt know the !$ (I knew colon p and other stuff though).
Good luck yenwc _________________ Danny Staple, curator of http://orionrobots.co.uk
Adopt an unanswered post initiative https://forums.gentoo.org/search.php?search_id=unanswered
Last edited by orionrobots on Sat Jan 15, 2005 2:50 pm; edited 1 time in total |
|
Back to top |
|
|
Gentree Watchman
Joined: 01 Jul 2003 Posts: 5350 Location: France, Old Europe
|
Posted: Sat Jan 15, 2005 9:23 am Post subject: |
|
|
Oh yes, I couldnot live without bang-dollar!
you should checkout the whole bash history capability. Prob in man bash
eg.
!cat:p
print last command starting with "cat" but dont execute.
ls !cat:1
ls the first arguement of the last cat command.....etc
very powerful tool.
HTH
_________________ Linux, because I'd rather own a free OS than steal one that's not worth paying for.
Gentoo because I'm a masochist
AthlonXP-M on A7N8X. Portage ~x86 |
|
Back to top |
|
|
orionrobots Apprentice
Joined: 07 Oct 2003 Posts: 289 Location: London, Uk
|
Posted: Sat Jan 15, 2005 2:53 pm Post subject: |
|
|
Its funny- I know colon p, and just bang for the last command - I use those regularly. Hmm - I just noticed the forum markup is case sensitive - :p works as long as its lower case, otherwise you get .
Anyway - thanks again gentree.. _________________ Danny Staple, curator of http://orionrobots.co.uk
Adopt an unanswered post initiative https://forums.gentoo.org/search.php?search_id=unanswered |
|
Back to top |
|
|
yenwc n00b
Joined: 27 Dec 2003 Posts: 9
|
Posted: Sun Jan 16, 2005 2:09 pm Post subject: |
|
|
thank for all your suggestions.
i let the computer do nothing for one day, hoped that the kernel would gradually instruct a cache write-back and reboot it using a livecd. everything's back and i am relieved.
and special thanks to Gentree. your bang-dollar stuff (man history) gave me a good starting point to write a small script in order to prevent such a shit happens again. |
|
Back to top |
|
|
|