-1

I have an odroid (raspberry-like) machine with an arch linux system installed. Now I want to move the system from one microsd (A) to another microsd (B). When I tried this, the system became corrupted, information about files attributes were lost:

  1. Copy files from A to osx-host cp -R /Volume/microsd_a/* ~/Desktop/backup
  2. Copy files from osx-host to B cp -R ~/Desktop/backup/* /Volume/microsd_b

Is it real to copy linux-system using osx-host with preserving integrity?

Update:

  1. dd. I tried this way, but there is a problem. My sd cards have different sizes, 64 Gb and 16 Gb, but system installed on 64 Gb disk has no more than 8 Gb. So when I launched the copying process, output image file exceed 16 Gb and I killed the process. By the way, the MBR contains information about partition table which should be different (one partition 64Gb / one partition 16 gb). And notice, I do not need to copy bootloader from MBR, I have an ability to flash disk bootloader by other ways.

  2. cp. What I wanted to listen as the answer is the list of flags I need to make this operation. Reading man cp didn't help me. cp -a does not copy all files because of Cannot allocate memory error. Tried cp -aX, no attributes were restored after copying data to second sdcard.

  3. tar. I tried multiple times with flags, last one was tar -cvpf; tar --same-owner -xpf. But file attributes were still corrupted.

Again: - Are you sure, it is possible to preserve file attributes through copying ext4 -> APFS -> ext4? - If this is possisble, how does it work and which command with which flags should I use?

1 Answers1

1

cp -R results in change of permissions, time stamps and missing of hidden files, you can't use that command to create a disk image.

what you need is a disk copy/clone. The command to use is dd.

Check out this webpage:

https://pbxbook.com/other/dd_clone.html

FangQ
  • 1,444
  • 10
  • 18
  • `man cp` It may preserve a lot of stuff, and `dd` has its own disadvantages. `tar` OTOH is more generic, but also has pros and cons. – 0andriy Apr 05 '20 at 18:22
  • commands like `cp -a` or `rsync -tav` keep file properties, but they don't preserve byte order, partition tables or MBR. The only way to get those cloned is to use a byte-copy utility, such as `dd`. – FangQ Apr 05 '20 at 18:43
  • Byte order?! What do you mean? – 0andriy Apr 06 '20 at 07:25
  • what I meant was raw sector-by-sector information. Some files are not stored on contiguous sectors. `dd` maps sector-level data but `cp/rsync` won't. – FangQ Apr 06 '20 at 15:00