Copying files as root without changing permissions
About a week ago I transfered all files from one hard drive to the other to move my distro to a newer hard drive. I booted my computer up with a live cd and entered the shell as root. I mounted my new hard drive as /mnt/new and mounted my old hard drive as /mnt/old. I then proceeded to copy the files the only way I knew how.
# cp -Rv /mnt/old /mnt/new
I did it verbosely so I could see when it was done from across the room as I watched television.
Anyways. The copy was successful. Every file was copied to the new drive. So I shut down the pc, took out the old hard drive and set the new one as the main. I then proceeded to boot up.
First problem... no grub. So I used a floppy to install grub to the MBR. No problem.
I continued on a booted up my debian. I got all the way to the KDM login screen. I tried to login but the screen flickered and then went back to the KDM screen to login again. I swear I must have logged in 20 times before i stopped...
I then went to command line and i was able to login as user and root... Hmm... so I viewed my hard drive to make sure all the files were there:
# ls -al /
This is when I noticed... Every folder and every file is now owned by user root and group root. I supposed this was the problem and i decided i didnt want to fool with it again, so I just did a clean installation from scratch.
Now I am at a point again where I need to copy over more files from one hard drive to another (different machine). How can I copy all the files over to a new hard drive yet leave the permissions untouched?
|