Showing posts with label usb. Show all posts
Showing posts with label usb. Show all posts

05 December 2014

604. Got a 'fake' USB stick from ebay

If it sounds too good to be true...

I bought two 128 Gb usb sticks from ebay for $12 each. Typical prices are $60 and over PER drive. Obviously, the drives were fake, which is a well-known phenomenon: http://www.ebay.com.au/gds/Fake-USB-DRIVES-From-China-HK-/10000000007355216/g.html

(why did I still buy them? Part greed, part curiosity)

Once I received the sticks I installed f3 on debian, and ran the f3write/f3read test.

Both drives failed:
SECTORS ok/corrupted/changed/overwritten Validating file 1.h2w ... 2097152/ 0/ 0/ 0 Validating file 2.h2w ... 2097152/ 0/ 0/ 0 Validating file 3.h2w ... 2097152/ 0/ 0/ 0 Validating file 4.h2w ... 2097152/ 0/ 0/ 0 Validating file 5.h2w ... 2097152/ 0/ 0/ 0 Validating file 6.h2w ... 2097152/ 0/ 0/ 0 Validating file 7.h2w ... 2097152/ 0/ 0/ 0 Validating file 8.h2w ... 2097152/ 0/ 0/ 0 Validating file 9.h2w ... 2097152/ 0/ 0/ 0 Validating file 10.h2w ... 2097152/ 0/ 0/ 0 Validating file 11.h2w ... 2097152/ 0/ 0/ 0 Validating file 12.h2w ... 2097152/ 0/ 0/ 0 Validating file 13.h2w ... 2097152/ 0/ 0/ 0 Validating file 14.h2w ... 2097152/ 0/ 0/ 0 Validating file 15.h2w ... 2097152/ 0/ 0/ 0 Validating file 16.h2w ... 588128/ 1509024/ 0/ 0 Validating file 17.h2w ... 0/ 2097152/ 0/ 0 Validating file 18.h2w ... 0/ 2097152/ 0/ 0 Validating file 19.h2w ... 0/ 2097152/ 0/ 0 [..] Validating file 115.h2w ... 0/ 2097152/ 0/ 0 Validating file 116.h2w ... 0/ 2097152/ 0/ 0 Validating file 117.h2w ... 0/ 2097152/ 0/ 0 Validating file 118.h2w ... 45696/ 314496/ 0/ 0 Data OK: 15.30 GB (32091104 sectors) Data LOST: 101.87 GB (213635872 sectors) Corrupted: 101.87 GB (213635872 sectors) Slightly changed: 0.00 Byte (0 sectors) Overwritten: 0.00 Byte (0 sectors) Average reading speed: 14.37 MB/s

At this point I figured I might as well pop the drive open as it wasn't glued (just remove the clip and insert a screw driver gently in the hole at the back).

IDE, 5019SN-GT, D5P590-000FZ, 1433T8H4
 I googled the stuff written on the chip, but didn't find any exact matches.

I then logged into my ebay account, and filed a return with the reason being fake/counterfeit. I was advised to wait five days for the seller to reply, which I did, after which I clicked on the button on the ebay website that asked ebay to step in to resolve the case. After a few minutes I received an email letting me know they'll initiate a refund, and after ca 30 minutes I received an email from paypal informing me of the same. No need to return the two 16 Gb sticks.

I've obviously posted a negative review of the seller which lets the reader know about the fake sized USBs.

Interesting experience.

I don't have any complaints about ebay -- things moved fast and the resolution was fair and in my favour. I reckon that the seller makes a profit from most buyers not realising that their drive isn't as big as the OS reports it to be, and don't discover it until the off-chance that they fill it with data. A that point they'll probably attribute it to the drive being broken, rather than the seller being outright fraudulent.

02 December 2013

532. TEMPer temperature monitoring USB stick on Debian Wheezy

Because the air conditioning in my office has a habit of turning itself off, and since I'm running my beowulf cluster in there, and since it's Australia, I've become interested in monitoring the temperature in my office.

The USB stick itself looks nothing special, so here's the card from the box it came in.


A colleague of mine got a TEMPer thermometer USB (0c45:7401 Microdia) back when he didn't have any air conditioning at all in his office and wanted to prove to the university that the temperature got so high that it was impossible for him to do any work on some days. He's now got air conditioning.

Anyway, plugging in the USB stick got me the following:
* /dev/hidraw5 and /dev/hidraw6 get created

* DMESG shows
[441126.932728] usb 2-4.2: new low-speed USB device number 11 using ehci-pci [441127.025790] usb 2-4.2: New USB device found, idVendor=0c45, idProduct=7401 [441127.025803] usb 2-4.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [441127.025811] usb 2-4.2: Product: TEMPerV1.2 [441127.025818] usb 2-4.2: Manufacturer: RDing [441127.030229] input: RDing TEMPerV1.2 as /devices/pci0000:00/0000:00:02.1/usb2/2-4/2-4.2/2-4.2:1.0/input/input24 [441127.030516] hid-generic 0003:0C45:7401.000F: input,hidraw5: USB HID v1.10 Keyboard [RDing TEMPerV1.2] on usb-0000:00:02.1-4.2/input0 [441127.033234] hid-generic 0003:0C45:7401.0010: hiddev0,hidraw6: USB HID v1.10 Device [RDing TEMPerV1.2] on usb-0000:00:02.1-4.2/input1
* lsusb shows
Bus 002 Device 011: ID 0c45:7401 Microdia

Searching online for 0c45:7401 brought up this cheesily title post: http://www.linuxjournal.com/content/temper-pi

From that post:
 If instead dmesg says this:
[snip]
and lsusb says:
$ lsusb
Bus 001 Device 005: ID 0c45:7401 Microdia
then congratulations, you have the new TEMPer probe and will have to use completely different software. 
While that sounds as if you'll have continue searching for a new how-to, in fact the entire post is about that particular version. So, I followed the instructions at Linux Journal -- I'll just offer my step by step version of it here with some added detail:

sudo apt-get install python-usb python-setuptools snmpd git
sudo easy_install snmp-passpersist
mkdir ~/tmp
cd ~/tmp
git clone git://github.com/padelt/temper-python.git
cd temper-python/
sudo python setup.py install

At this point I could get a temperature reading by doing:
$ sudo temper-poll 
Found 1 devices Device #0: 24.4°C 75.9°F
But running stuff as root is unsatisfying, so I created a UDEV rule:
$ sudo vim /etc/udev/rules.d/80-temper.rules
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7401", GROUP="users", MODE="0666"
I then unplugged the USB stick, did
sudo service udev restart

and plugged it back in.
$ temper-poll 
Found 1 devices
Device #0: 25.8°C 78.3°F

Sweet.
Finally, I set up a cronjob that would check the temperature, update a plot and put it in my Dropbox:
$ crontab -e
*/2 * * * * sh /home/me/temper.sh
where temper.sh looks like this:
temp=`/usr/local/bin/temper-poll |grep Device|gawk '{print $3}'|sed 's/°C//'` when=`date +%s` thetime=`date +%D' '%T` if [ -n "$temp" ]; then echo $when $temp $thetime>> /home/me/temper.dat fi gnuplot /home/andy/temper.gplt cp /home/me/temper.eps /home/me/Dropbox
The temper.gplt script looks like this:
set term postscript eps enhanced colour set output 'temper.eps' unset key set ylabel 'Temperature (Celsius)' set border 3 set xtics nomirror set ytics nomirror unset xlabel set xdata time set multiplot set size 0.5,0.45 set origin 0,0.05 set timefmt "%H:%M:%S" set title 'Daily' set xtics 30000 plot 'temper.dat' u 4:2 w points pt 1 ps 0.15 set origin 0.5,0.05 set title 'By Day' set timefmt "%m/%d/%y" set xtics 100000#0 plot 'temper.dat' u 3:2 w points pt 2 ps 0.5 set size 1.0,0.5 set origin 0.0,0.5 set timefmt "%m/%d/%y %H:%M:%S" set xtics 30000 set title 'Log' plot 'temper.dat' u 3:2 w lines
and the plot looks like this:
Temperature in a lab at a leading Australian research institute. In five years they have not been able to fix the air conditioning.  On 01/04 someone pushed a cardboard box against the sensor which lead to a slower change in temperature.

07 March 2012

96. Optimising, trimming and making your solid state drive last longer on linux

There's an excellent and informative guide here:
http://apcmag.com/how-to-maximise-ssd-performance-with-linux.htm

Please read it. I've tried it on my SSD and it didn't crash my system. In fact, it even seems snappier, but that might be subjective.

While the guide above talks about making Solid State Drives (SSD) last longer and work faster, it equally applies to other solid state media such as USB sticks.

Here we'll apply that guide to a USB stick with debian we installed as shown in this guide: http://verahill.blogspot.com.au/2012/02/installing-debian-on-usb-stick-live-usb.html

--START HERE --
Mount your USB stick as you would any other -- the wonderful things about *NIX is that all configuration options are set in files which you can easily edit.

/etc/fstab
Before editing, it looks like this

proc            /proc           proc    defaults        0       0
UUID=8c0c9c98-e73f-4f5a-b7d7-f91f95c9d8ca /               ext4    errors=remount-ro 0       1
UUID=e3305fbe-8e4e-4d0e-9975-0db692f87d32 none            swap    sw              0       0
/dev/scd0       /media/cdrom0   udf,iso9660 user,noauto     0       0
We'll edit to

  • enable TRIM by adding discard.
    From the manual: "discard/nodiscard - Controls  whether  ext4  should issue discard/TRIM commands to the underlying block device when blocks are freed.  This is useful for SSD devices and sparse/thinly-provisioned LUNs, but it is off by default until sufficient testing has been done."
  • noatime.
    From the man: "Do not update inode access times on this filesystem (e.g., for faster access on the news spool to speed up news servers)."
  • nodiratime
    Same as noatime, for directories
  • move some temporary /var files to the RAM instead of disk
  • the last line puts all log files (/var/log/) in RAM as well. If you do want logs to persist between boots, comment it out
  • 1777 = chmod +trwx, 0755= u+rwx g+rw o+rw
  • I've kept the swap since I might want to use my stick on underpowered machines, but you really probably shouldn't
  • A good source of information on mount options is here: http://www.tuxfiles.org/linuxhelp/fstab.html


proc            /proc           proc    defaults        0       0
UUID=8c0c9c98-e73f-4f5a-b7d7-f91f95c9d8ca /               ext4 noatime,nodiratime,discard,errors=remount-ro 0       1
UUID=e3305fbe-8e4e-4d0e-9975-0db692f87d32 none            swap    sw              0       0
/dev/scd0       /media/cdrom0   udf,iso9660 user,noauto     0       0
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/spool tmpfs defaults,noatme,mode=1777 0 0
tmpfs /var/tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/log tmpfs defaults,noatime,mode=0755 0 0

/etc/default/grub 
To set a system-wide scheduler policy for disk I/O we can edit grub and define elevator as noop, deadline or anticipatory.

Change e.g.
GRUB_CMDLINE_LINUX_DEFAULT="text splash"
to
GRUB_CMDLINE_LINUX_DEFAULT="text splash elevator=deadline"
If you want to know more about schedulers, you can look here: http://www.cyberciti.biz/faq/linux-change-io-scheduler-for-harddisk/


We need to do update grub, and that's a bit trickier, but still not too difficult.
My USB stick is mount at /media/8c0c9c98-e73f-4f5a-b7d7-f91f95c9d8ca/


sudo mount -o bind /dev 8c0c9c98-e73f-4f5a-b7d7-f91f95c9d8ca/dev/
sudo mount -o bind /sys 8c0c9c98-e73f-4f5a-b7d7-f91f95c9d8ca/sys/
sudo mount -o bind /proc 8c0c9c98-e73f-4f5a-b7d7-f91f95c9d8ca/proc/
sudo chroot 8c0c9c98-e73f-4f5a-b7d7-f91f95c9d8ca/
root@beryllium:/# update-grub
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.2.0-1-686-pae
Found initrd image: /boot/initrd.img-3.2.0-1-686-pae
Found linux image: /boot/vmlinuz-2.6.32-5-686
Found initrd image: /boot/initrd.img-2.6.32-5-686
grep: input file `/boot/grub/grub.cfg.new' is also the output
done

And exit the chroot jail (type exit)


/etc/rc.local
Add a line to the end
echo 0>/proc/sys/vm/swappiness
to prevent use of swap until the RAM is full.

You're now done.


For an SSD drive you can just boot into your system and make the changes as above, but without fiddling with mounting /dev, /sys, /proc and doing chroot.