Linux – Refresh devices – reconnect CF card drive by script (unplug-plug equivalent)

bashlinuxusb-flash-drive

I plug a completely clean CF-card into my USB card-writer. Then I dd a mbr block of 512 bytes size to the device, which contains the partition table and the definition of one partition.

Problem: While "fdisk -l /dev/sdx" correctly displays the partition, it happens that there is no device like "/dev/sdx1" after these operations (as it was not present before). Unplugging and plugging the card-writer solves the problem and makes the device(s) appear. Since I use this procedure in a script, manually unplugging and re-plugging is no option whatsoever.

Is there a way to "refresh" the devices or to "unplug and re-plug" the drive by script such that /dev/sdx1 appears?

Thanks for any help,

Chris

Best Answer

I think I found a solution:

hdparm -z /dev/sdx

seems to to the trick so far.

Related Topic