0

I'm trying to copy the files on my mounted boot partition to another device whilst preserving ownership and attributes. I'm doing this on a Raspberry Pi running RaspBMC. I've mounted the destination:

sudo mount -t vfat /dev/sda1 /temp/

Then I'm attempting this:

sudo cp -a /boot/* /temp/

But this results in errors like this:

cp: failed to preserve ownership for `/temp/bootcode.bin': Operation not permitted

So the files are being copied, but the owner is the currently logged on user (pi) rather than root. In addition, none of the files are marked as executable like they are in /boot/.

What I've tried:

  • copying the files without preserving ownership and then executing chown after the fact. This results in the same error
  • using rsync instead. This doesn't output errors, but fails to preserve ownership and attributes just like cp
  • executing sudo su and trying everything as root. Same problem
  • executing sudo dd if=/dev/mmcblk0p1 of=/backups/backup_of_boot and then sudo dd if=/backups/backup_of_boot of=/dev/sda1. Unbelievably, this still does not copy ownership and attributes (but does copy all files).

Can anyone tell me what I'm doing wrong?

  • why do you need to give/change ownership of files in /boot folder? – gurcanozturk Feb 21 '14 at 7:48
  • @gurcanozturk: I'm trying to preserve ownership whilst copying to another partition, not change it. – me-- Feb 21 '14 at 8:01
2

vfat does not preserve ownership.

You need an Ext4 formatted partition.

In fact if you are trying to copy the /boot partition the files have no ownership, except the user which mounted them

  • When I ls -al on /boot (which is vfat) it lists ownership as root. So the question remains: how do I ensure ownership is root when I copy them to another vfat partition? Without this, I can't boot from the partition. – me-- Feb 21 '14 at 8:02
  • You can't. The files DO NOT have ownership attributes. This is inherited from the directory into which they are mounted. This has nothing to do with whether it can be used to boot. FAT has no attributes and nowhere to store them. – Milliways Feb 21 '14 at 8:44
  • I see, so the fact that it's mounted as /boot/ means they are inherently owned by root and are executable. Makes sense. Something else must have gone wrong with my original attempt at copying because it failed to boot afterwards. I just mistakenly assumed it was due to ownership and attributes. Thanks. – me-- Feb 21 '14 at 10:35

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.