I have a Samsung XE303C12 and I have been running Arch Linux ARM on it from an SD card. The partition table of the SD card is as such:
- A Chrome OS kernel partition to which the vboot-wrapped ALARM kernel occupies.
- An ext2 partition that I'd use for configuring U-Boot whenever it is installed to partition 1 instead of the Arch Linux kernel.
- The root filesystem that I installed Arch Linux to.
A recent attempt to update all packages at once ended up corrupting the root filesystem. I saw some message about the flashing the kernel to some partition on the SD card and filesystem failing to be mounted read-only or read-write or something. I was tried fixing it with fsck
, which prompted me several times for what to do with inodes, but once I realized that it was probably going to ask me this for every single inode on the partition, I ran fsck -y /dev/mmcblk1p3
. This ran through maybe several hundred inodes until stopped. I can't remember the error message.
In the hopes of preserving the data for future recovery, I am backing up /dev/mmcblk1p3
to a FAT32 filesystem on a USB drive using dd
. Since FAT32 cannot hold files larger than 4 GiB, I decided to break it into segments using some shell code and loops.
Skipping ahead of a few things, I've realized that dd
is faster in the beginning of the process (I used bs
set to larger multiples of 512 to make it faster), so the first 64 MiB segment would be written to the USB filesystem in 3 seconds and it would get progressively slower with each iteration. I found out that this is because the disk cache fills up.
I looked for a way to flush the cache for dd
and I stumbled upon this post on the Unix Stack Exchange website. The top answer says to do sync; echo 3 > /proc/sys/vm/drop_caches
. A comment on that answer notes that that setting is not sticky and the link in that comment gave me the idea to do echo 3 > /proc/sys/vm/drop_caches
before every iteration of dd
. I tried that and dd
still dropped off in copying speed.
The second solution mentioned in the first post's answer was to run dd
with iflag=direct
as a way to bypass the cache. I did that but I also used oflag=direct
since I figured the cache would apply to both the copying from the SD card and the writing to the USB. This comment said that nocache
should be used instead of direct
, so I tried that as well. Both methods experienced the same drop from ~17 MB/s to ~1-3 MB/s.
I'm guessing that I might not be using those methods correctly, so is there anyway to reliably flush the cache every iteration to make dd
faster or some way to just not use the cache at all?
2^x
bytes wherex
is an integer from 12 to 25. I'm copying the SD card partition to a USB drive.