DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2011-03-10 23:06:11

thebatfink
New member
Registered: 2011-03-10
Posts: 4

Can't manipulate files after copying across volumes?

Hi,

I have recently got my NAS boxes. I have upgraded to 1.10 beta firmware and installed fonz fun plug 0.5.

I'm wanting to setup a rsync job between the two volumes in my NAS to backup one drive onto the other. For my first backup I decided it would be quicker to copy it across initially using cp via ssh.. Well I've done that but when I goto the backup volume in windows explorer it try for instance to delete a file it comes up saying I need permission from unix user root??

I'm assuming thats because I was logged in as root when I executed the cp command. I simply did a -

cp -r /mnt/HD_a2/* /mnt/HD_b2/

My question is, how do I now gain full access to these files via my windows PC accross the network, and then, in the future.. should I have done the cp command a different way to avoid this?

Thanks for any help!

Offline

 

#2 2011-03-10 23:25:19

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Can't manipulate files after copying across volumes?

Since you copied the files from the command-line using cp, it created the duplicates with the ownership of the user that ran the command, which is root. It, most probably, didn't maintain file permissions and other attributes such modification time.
You *should* use "cp -a" to maintain all those attributes, as in:

Code:

cp -ar /mnt/HD_a2/* /mnt/HD_b2/

And you can learn about the file security basics here:
[url=http://linux.die.net/Intro-Linux/sect_03_04.html[/url]to change files' (and directory') ownership use chown <user>:<group> <file-names>, like so:

Code:

chown -R nobody:501 /mnt/HD_b2/

to change permissions, use the chmod command.

Read more about these commands here:
http://linux.die.net/man/1/chown
http://linux.die.net/man/1/chmod

Edit: forgot to add, if it's not much trouble or time, I suggest you copy over the files again. Make a clean good start. Easier, imho.

Last edited by scaramanga (2011-03-10 23:27:13)


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

#3 2011-03-11 00:20:45

dhub
Member
Registered: 2011-01-01
Posts: 112

Re: Can't manipulate files after copying across volumes?

Careful, the -a flag on the busybox cp utility doesn't preserve permissions like the -a flag on gnu cp.  It only preserves links and works recursively.

If you want to copy between two volumes and maintain permissions, use tar (as root).
(cd sourcedir ; tar -cf - .)|(cd destdir ; tar -xpvf -)

Offline

 

#4 2011-03-11 01:27:26

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Can't manipulate files after copying across volumes?

dhub wrote:

Careful, the -a flag on the busybox cp utility doesn't preserve permissions like the -a flag on gnu cp.  It only preserves links and works recursively.

If you want to copy between two volumes and maintain permissions, use tar (as root).
(cd sourcedir ; tar -cf - .)|(cd destdir ; tar -xpvf -)

I just tried cp -a on a single file. Both /bin/cp and /ffp/bin/cp. They both behaved as expected. I'm using FW 1.08 and ffp 0.5.


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

#5 2011-03-11 02:09:46

dhub
Member
Registered: 2011-01-01
Posts: 112

Re: Can't manipulate files after copying across volumes?

I just used the busybox "cp -a" to copy a debian chroot from a directory to the root of the disk.  After that the ssh server in the chroot environment wouldn't start because the busybox "cp -a" command set read/write permissions on pretty much every file including files sshd checks for proper permissions prior to starting.  Notice if help is run on the busybox cp command it says right in the help text that -a is equivalent to using -dpR, none of those options preserve permissions.

$ cp --help
BusyBox v1.15.3 (2010-12-20 05:49:16 WET) multi-call binary

Usage: cp [OPTIONS] SOURCE DEST

Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY

Options:
    -a    Same as -dpR
    -d,-P    Preserve links
    -H,-L    Dereference all symlinks (default)
    -p    Preserve file attributes if possible
    -f    Force overwrite
    -i    Prompt before overwrite
    -R,-r    Recurse directories
    -l,-s    Create (sym)links

In contrast, the help for gnu cp shows the -a flag is handled differently (adds the --preserve=all flag that the busybox cp doesn't have):
# deb
root@nas01:/# cp --help
Usage: cp [OPTION]... [-T] SOURCE DEST
  or:  cp [OPTION]... SOURCE... DIRECTORY
  or:  cp [OPTION]... -t DIRECTORY SOURCE...
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.

Mandatory arguments to long options are mandatory for short options too.
  -a, --archive                same as -dR --preserve=all
(rest of the output is trimmed for space)

Offline

 

#6 2011-03-11 09:36:04

thebatfink
New member
Registered: 2011-03-10
Posts: 4

Re: Can't manipulate files after copying across volumes?

Hi, thanks for the replies.. I'm lost now! What command should I put in at my ssh prompt? Do I include the brackets etc?

(cd /mnt/HD_a2/ ; tar -cf - .)|(cd /mnt/HD_b2/ ; tar -xpvf -)

?? I'm reluctant to just jump in doing stuff I'm not sure off as this is my only copy of the data currently and I have 3TB to move across 2 DNS323s.. Losing any of it would be painful.

Thanks for the help!

----
EDIT
Or would I be wiser to just let rsync do the first backup? I'm planning on following the tutorial on the wiki for backing up nightly between volumes.

Last edited by thebatfink (2011-03-11 09:39:38)

Offline

 

#7 2011-03-11 19:41:17

dhub
Member
Registered: 2011-01-01
Posts: 112

Re: Can't manipulate files after copying across volumes?

Your command "(cd /mnt/HD_a2/ ; tar -cf - .)|(cd /mnt/HD_b2/ ; tar -xpvf -)" is correct if you are trying to copy everything from /mnt/HD_a2 into /mnt/HD_b2 preserving permissions.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB