If I made a backup of /usr with:
# cp -r /usr /usrRESERVE1
how can i switch it back after some time:
1# mv usr usrRESERVE2
2# mv usrRESERVE1 usr
second command will not work because mv
is inside /usr/bin/mv
and it does not exist after first line execution.
//answering to my self...
Solution 1: Using 'mount --bind' as dummy-var
(pointed by comment of user MarkPlotnick):
# mount --bind /usrRESERVE1 /usr #usr points --to--> usrRES1 from now
# mkdir /dummy
# mount --bind / /dummy #contains original root folders
# cd /dummy ; mv usr usrRESERVE2
# mv usrRESERVE1 usr
# cd / ; umount dummy ; umount usr ; rmdir dummy
Solution 2: using single process - moving tool
# package manager install mmv
# mmv /usr /usrRESERVE1 -- /usrRESERVE2 /usr
/usrRES/bin/mv
? Error message please. (I would guess you've also lost your shared libraries.) – Chris Davies Mar 16 '15 at 14:04ldd mv
also. You might need to edit LD_LIBRARY_PATH var as well. – Archemar Mar 16 '15 at 14:06/usr/bin/mv usrRES usr
) – Archemar Mar 16 '15 at 14:38/home
or/usr/local
or/opt
or/data
but not/usr
! – Archemar Mar 16 '15 at 14:51/bin/busybox
to move or copy without needing any shared libraries. I'd still do all this from a rescue CD or single-user mode, because any time you remove stuff from/usr
, even for a moment, programs may fail. If this is just an academic exercise, then the procedure would roughly be to copy (not mv) /usr to the new filesystem, unmount the new filesystem, mount it on top of /usr, restart all processes with open /usr files, use mount --bind to mount the old /usr somewhere, then clean it out. – Mark Plotnick Mar 16 '15 at 16:31