1

I sort-of-cloned an existing Debian 7.x distro by copying the contents of the root filesystem (not the special dirs of course) to another HDD. I booted, things seem to run, but - I get some weird errors. One of them - sudo and su wouldn't run, complaining about lack of a setuid permission for the binaries. Well, I fixed that, and now they don't complain, but - maybe there are other files whose permission has been screwed up during the copy? Is there someway to verify and fix all relevant file permissions?

  • What command did you use to do the copy? – Mark Plotnick Jan 30 '15 at 19:04
  • Just cp, unfortunately... – einpoklum Jan 31 '15 at 0:18
  • What options? Just -r or -R? – Mark Plotnick Jan 31 '15 at 0:41
  • It was just cp -r ... – einpoklum Jan 31 '15 at 7:01
3

Original host (or another similar freshly installed distro):

getfacl -R / > permissions.acl

your host:

setfacl --restore=permissions.acl

from here

1

That's what God made rsync for.

I clone my installs using rsync -avxt --delete-before, then I run lilo on them to make them independently bootable. Yeah, have to make sure your fstab doesn't use UUIDs though, or everything goes to hell. I use labels so that it doesn't matter what the disk order (sda, sdb, etc.) is.

  • Why is the --delete-before switch important? – einpoklum Jan 31 '15 at 7:22
  • When you are cloning, you want (usually!) to not only add new files, but remove old ones as well. '--delete-before' cleverly does that before adding any new files, so that if you have limited space, you are sure not to run out (which might happen if it added all the new files before removing any of the old ones). Oh, you might want to add the '-t' switch as well to preserve your files' modification times. – Ray Andrews Jan 31 '15 at 16:15
0

There is no easy way I can think of. One way would be to reinstall each and every package you have in /var/cache/apt/archives as root (sudo su).

cd /var/cache/apt/archives
for i in *.deb
do
sudo dpkg -Gi $i
done

Next time, use the -p option of rsync/cp or equivalent of whatever you were using to copy the files.

  • How about "copying" the permissions and owners from the original partition, without the files? or "syncing" the permissions? – einpoklum Jan 30 '15 at 14:59
0

Use tar to archive the files and then extract them. You p key when extract to keep original partitions

  • I'm talking about a copy which already happened. – einpoklum Jan 30 '15 at 14:58
  • So create two lists, based on permissions and filename/directory name and compare them. Here is how to create such list: ls -l|awk '{print $1" "$NF}' – Romeo Ninov Jan 30 '15 at 15:00
0

Use rsync to re-copy the files. I think it will notice that only the permissions need to be copied, so it will fix them up while leaving the contents alone, so it should be relatively quick.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.