5

I copied some MySQL-DB stuff to my Class 6 SD card. It needed 45 min. for the transfer. Same machine with XP it does it in a few minutes, with Win7 on another machine transfer is also fine. Checked all the forums and sources but found nothing really related.

3
  • Is this a USB device (reader), or built-in? can you identify the reader brand/model? What is the brand/model of the SD-card itself?
    – david6
    Jul 3, 2012 at 8:24
  • It's built-in and worked fine with the last LTS version[ 116.160613] mmc0: new SDHC card at address b368 [ 116.162075] mmcblk0: mmc0:b368 00000 30.0 GiB [ 116.165139] mmcblk0: p1 [ 116.403621] EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Opts: (null) Jul 3, 2012 at 8:29
  • Is Ubuntu up to date?
    – Mitch
    Jul 3, 2012 at 10:56

1 Answer 1

3

Sometimes the default IO scheduler treats these flash drives poorly. One solution that I've found to be useful is to switch the ioscheduler to deadline or noop for just that device. So for example,

$ lsscsi 
[0:0:0:0]    disk    ATA      TOSHIBA THNS128G AGLA  /dev/sda
[1:0:0:0]    cd/dvd  HL-DT-ST DVDRAM GT30N     LT09  /dev/sr0
[7:0:0:0]    disk             Patriot Memory   PMAP  /dev/sdb
sudo tee /sys/block/sdb/queue/scheduler << EOF
deadline
EOF
$ cat /sys/block/sdb/queue/scheduler
noop [deadline] cfq 

and now try your data transfer again, you must do this before you load the device.

Should that work for you a udev rule can be created to automatically set this for all usb hotplug devices. Here's one I wrote a long time ago that's a little crufty, I believe it only scans for usb hotplug devices, not MMC cards, so you would have to examine udev output to determine what class your media is in and adjust accordingly.

PROCEED AT YOUR OWN RISK, IF THIS DOESN'T WORK FOR YOU ITS UP TO YOU TO DEBUG

sudo tee /lib/udev/rules.d/100-usb-scheduler.rules << EOF
# custom udev rule: 28.10.11

# adjust io scheduler for usb block devices: queue/scheduler
# scheme based on "persistent storage rules"

# forward scsi device event to corresponding block device
ACTION=="change", SUBSYSTEM=="scsi", ENV{DEVTYPE}=="scsi_device", TEST=="block", ATTR{block/*/uevent}="change"

ACTION!="add|change", GOTO="persistent_storage_end"
SUBSYSTEM!="block", GOTO="persistent_storage_end"

# skip rules for inappropriate block devices
KERNEL=="fd*|mtd*|nbd*|gnbd*|btibm*|dm-*|md*", GOTO="persistent_storage_end"

# ignore partitions that span the entire disk
TEST=="whole_disk", GOTO="persistent_storage_end"

# for partitions import parent information
ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_*"

# USB storage devices suffer from performance issues unless they use deadline io scehduler
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", \
        RUN="/bin/sh -c 'echo deadline > /sys/$env{DEVPATH}/queue/scheduler'"

LABEL="persistent_storage_end"
EOF
$ sudo chmod +x /lib/udev/rules.d/100-usb-scheduler.rules

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.