Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
moved /bin, /lib, /usr, and more to /root. need suggestions
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
yenwc
n00b
n00b


Joined: 27 Dec 2003
Posts: 9

PostPosted: Fri Jan 14, 2005 7:32 pm    Post subject: moved /bin, /lib, /usr, and more to /root. need suggestions Reply with quote

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
View user's profile Send private message
orionrobots
Apprentice
Apprentice


Joined: 07 Oct 2003
Posts: 289
Location: London, Uk

PostPosted: Fri Jan 14, 2005 7:38 pm    Post subject: Reply with quote

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
View user's profile Send private message
jonnevers
Veteran
Veteran


Joined: 02 Jan 2003
Posts: 1594
Location: Gentoo64 land

PostPosted: Fri Jan 14, 2005 7:41 pm    Post subject: Reply with quote

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
View user's profile Send private message
orionrobots
Apprentice
Apprentice


Joined: 07 Oct 2003
Posts: 289
Location: London, Uk

PostPosted: Fri Jan 14, 2005 7:44 pm    Post subject: Reply with quote

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
View user's profile Send private message
kiksen
Guru
Guru


Joined: 24 Jun 2002
Posts: 401
Location: Denmark

PostPosted: Fri Jan 14, 2005 8:00 pm    Post subject: serious mistake... Reply with quote

Hi.

One of the more unpleasent typos!

Can you execute commands like e.g. /root/bin/mv

/kiksen
Back to top
View user's profile Send private message
yenwc
n00b
n00b


Joined: 27 Dec 2003
Posts: 9

PostPosted: Fri Jan 14, 2005 8:33 pm    Post subject: Reply with quote

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
Code:

cp .* somewhere
Back to top
View user's profile Send private message
jonnevers
Veteran
Veteran


Joined: 02 Jan 2003
Posts: 1594
Location: Gentoo64 land

PostPosted: Fri Jan 14, 2005 9:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
titan100
n00b
n00b


Joined: 06 Sep 2004
Posts: 61

PostPosted: Fri Jan 14, 2005 9:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
Gentree
Watchman
Watchman


Joined: 01 Jul 2003
Posts: 5350
Location: France, Old Europe

PostPosted: Fri Jan 14, 2005 11:27 pm    Post subject: Reply with quote

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 8)
_________________
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
View user's profile Send private message
orionrobots
Apprentice
Apprentice


Joined: 07 Oct 2003
Posts: 289
Location: London, Uk

PostPosted: Sat Jan 15, 2005 12:32 am    Post subject: Reply with quote

Offtopic - but gentree- I really like your sig! :D
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
View user's profile Send private message
Gentree
Watchman
Watchman


Joined: 01 Jul 2003
Posts: 5350
Location: France, Old Europe

PostPosted: Sat Jan 15, 2005 9:23 am    Post subject: Reply with quote

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

8)
_________________
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
View user's profile Send private message
orionrobots
Apprentice
Apprentice


Joined: 07 Oct 2003
Posts: 289
Location: London, Uk

PostPosted: Sat Jan 15, 2005 2:53 pm    Post subject: Reply with quote

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 :P.

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
View user's profile Send private message
yenwc
n00b
n00b


Joined: 27 Dec 2003
Posts: 9

PostPosted: Sun Jan 16, 2005 2:09 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum