LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-25-2020, 01:30 PM   #1
halfpower
Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 241

Rep: Reputation: 31
Rsync as root to the file system root


I want to merge the contents of a directory with the base of the file system with rsync. I ran the command
Code:
sudo rsync -lrtva my_dir/ /
This bricked the server. I retried the same task on another server by running the command
Code:
sudo cp -d my_dir/path_N/file_N /path_N/file_N
on every file. This server did not brick.

What did I do wrong? Do the two methods not produce the same result? Note that "my_dir" contains arbitrary system critical files.
 
Old 01-25-2020, 01:41 PM   #2
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by halfpower View Post
Note that "my_dir" contains arbitrary system critical files.
If you overwrite /sbin, /bin, /lib or /etc "critical" files, you will brick the system. /usr is a bit less critical as its mostly the multi-user and/or networking part of the O/S.

Last edited by ehartman; 01-25-2020 at 01:42 PM.
 
Old 01-25-2020, 05:35 PM   #3
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by ehartman View Post
/usr is a bit less critical as its mostly the multi-user and/or networking part of the O/S.
Shudder. On Debian (and elsewhere):
Code:
# ls -l /
...
lrwxrwxrwx  1 root root     7 Jan 20 09:49 lib -> usr/lib
lrwxrwxrwx  1 root root     9 Jan 20 09:49 lib32 -> usr/lib32
lrwxrwxrwx  1 root root     9 Jan 20 09:49 lib64 -> usr/lib64
lrwxrwxrwx  1 root root    10 Jan 20 09:49 libx32 -> usr/libx32
...
A brick recipe.
 
Old 01-26-2020, 10:06 AM   #4
halfpower
Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 241

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by ehartman View Post
If you overwrite /sbin, /bin, /lib or /etc "critical" files, you will brick the system.
The command sudo rsync -lrtva my_dir/ / appears to be deleting something in the destination directory. My understanding had been that rsync would merge directories and not delete unless the option --delete was included.

edit: I suspect this is actually an issue with permissions and ownership due to the -a option.

Last edited by halfpower; 01-26-2020 at 11:24 AM.
 
Old 01-26-2020, 12:13 PM   #5
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by berndbausch View Post
Shudder. On Debian (and elsewhere):
The OP was using Slackware, which doesn't have that problem.
But yes, in Debian (etc.) it can be even more fatal to rsync user files to /
 
Old 01-26-2020, 12:20 PM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,841

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
It just depends on what was overwritten (copied into /). As root you can easily destroy anything.
When you copy into /path/to/some/where [obviously] you won't destroy your root filesystem.

Try --dry-run if you wish.
During boot you may see a message about what was missing or corrupted...
 
  


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
rsync solaris + ld.so.1: rsync: fatal: libiconv.so.2: open failed: xxx_anuj_xxx Solaris / OpenSolaris 25 02-23-2012 03:23 AM
[SOLVED] Starting File System .. Starting File System .. Starting File System .. Starting File rmknox Linux - Newbie 3 08-15-2010 11:30 PM
Could I run rsync to download files from a server without rsync daemon? Richard.Yang Linux - Software 1 09-18-2009 04:08 AM
Rsync server vs rsync over ssh humbletech99 Linux - Networking 1 10-18-2006 12:10 PM
Windows Rsync Upload to Linux Rsync - permissions inspleak Linux - Software 0 10-12-2004 02:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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