Corrupt SD Card Recovery

A friend of mine came back from vacation where he had taken a lot of pictures. When he got back home a large part of his Micro SD card (exFAT partition) was no longer accessible so he missed a couple of weeks of his photos and videos. His Windows Operating System froze completely when it hit a rotten cluster during a file copy action. So we had to find another solution to get his files back.

The first step I tried was to get the data from the SD card via Linux with ddrescue. With ddrecue, you create and complete dump of the SD card (or the sdb1 partition only). So you can do the data recovery on the image file (backup1.img) and not on the already corrupted SD Card.

The command you can use is:

ddrescue -d /dev/sdb1 /media/thomas/backup1.img /media/thomas/backup1.mapfile

But Linux also had also trouble reading when I hit a bad cluster. The only thing I could do during the read issues was a physical disconnect of the USB adapter, reconnect the adapter and restart the ddrescue process. The reason of was that a dual SD card adapter was used:

Micro SD > SD > SD > USB

(spoiler ALERT!: Never use multiple adapters for data recovery!!!)

Because ddrescue has a mapfile it goes further where he was stopped the last time.

While debugging I wrote a simple loop that forced a “physical” disconnection of the USB adapter wait one sec and reconnect the devices without touching anything.

Source of the USBReset (fork)

This works but is a very very slow process. This will takes months to recover so I had to find another way.

#!/bin/bash
## Steps to Prepare:
# lsusb check card reader and change the /dev/bus
# Start script in usbreset folder 
# Run as sudo
# mount disk (media / thomas)
while true
do
	echo "Let's try Again!"
	ddrescue -d /dev/sdb1 /media/thomas/4905eb31-1df4-49bb-bb75-ec4889641d20/backup1.img /media/thomas/4905eb31-1df4-49bb-bb75-ec4889641d20/backup1.mapfile
	sleep 1
	./usbreset /dev/bus/usb/001/004
	sleep 1
done

The funny thing is that it was Sinterklaas time and that my daughter had just received a vtech kiddy photo camera with a Micro SD to USB adapter included 😀

So I try new new adapter: Micro SD > USB and with success.

And after almost 15 hours the result 99.98% rescued rate 🙂

During my search for a solution I found some interesting articles:

Happy recovering!

Install Pihole on Synology with docker

Unfortunately, there isn’t a pihole addon in the Synology package center. But you can build your pihole in a docker container instead 🙂

The reason you must use docker-compose instead of the Synology docker package itself is that you want to bridge net NIC of your Synology and place the pihole direct in your network. You cannot do this with the GUI.

The steps:

  • Install docker with the package center
  • Activate SSH
  • Download de image pihole/pihole:latest
  • Login with ssh
  • type vi docker-compose.yaml
  • Paste the content from the docker-compose.yaml example into the vi
  • Change the IP adressen to your own network
  • Type :wr to save the file
  • Type :q to quit vi
  • Type “sudo docker-compose up”
  • Have fun!

Docker-compose.yaml Example

# Note: 192.168.123.xxx is an example network, you must update all these to match your own.

version: '2'

services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    hostname: pihole
    domainname: localhost             # <-- Update
    mac_address: d0:ca:ab:cd:ef:01
    cap_add:
      - NET_ADMIN
    networks:
      pihole_network:
        ipv4_address: 192.168.123.199   # <-- Update
    dns:
      - 127.0.0.1
      - 1.1.1.1
    ports:
      - 443/tcp
      - 53/tcp
      - 53/udp
      - 67/udp
      - 80/tcp
    environment:
      ServerIP: 192.168.123.199                 # <-- Update (match ipv4_address)
      VIRTUAL_HOST: pihole.localhost            # <-- Update (match hostname + domainname)
      WEBPASSWORD: "justarondompassword"        # <-- Add password (if required)
    restart: unless-stopped

networks:
  pihole_network:
    driver: macvlan
    driver_opts:
      parent: ovs_eth0
    ipam:
      config:
        - subnet: 192.168.123.0/24            # <-- Update
          gateway: 192.168.123.1              # <-- Update
          ip_range: 192.168.123.192/28        # <-- Update

When you want to update the docker container, all you have to do is:

sudo docker-compose down

and

sudo docker-compose up

A good article I used to figure everything out is: http://tonylawrence.com/posts/unix/synology/free-your-synology-ports/

Windows IOPS and MB/s benchmarking

You have bought een new system and the first thing what you want to do is check the disk performance (ehhh that’s always the first thing I want to know 😛 )

There  is one tool I always use: ATTO Disk Benchmark

disk-benchmark

This is a very nice tool to quickly see how fast your troughput is of your new system.

But sometimes you want to check your IOPS. Then you can use another nice microsoft commandline benchmark tool DiskSpd

You can use this parameter to benchmark:

diskspd -b8K -d30 -o4 -t8 -h -r -w25 -L -Z1G -c20G testfile.dat

This example command line will run a 30 second random I/O test using a 20GB test file located on the T: drive, with a 25% write and 75% read ratio, with an 8K block size. It will use eight worker threads, each with four outstanding I/Os and a write entropy value seed of 1GB. It will save the results of the test to a text file called DiskSpeedResults.txt. This is a pretty good set of parameters for a SQL Server OLTP workload.

Example:

diskspd
Orginal article

If you get errors like:

Results for timespan 1:
*******************************************************************************
The test was interrupted before the measurements began. No results are displayed.
Error generating I/O requests

Or file creation errors like “Error opening file: testfile.dat” please try to replace the minus “-” characters with your keyboard. Sometimes your browser copy the wrong character.

Happy benchmarking 😀

Fix Intel SSD 320 problem on a Macbook

From one day to another my Intel 320 SSD was not visible anymore. So I download Ubuntu 14.04 boot it and start gparted.  Then I saw no SSD disk in my disk selection 🙁

ubuntu-disk-missing

So I download the Intel firmware tool and boot it and then I get a BAD_CTX and a disk with 0GB 🙁

bad_ctx

After some google’ing on the BAD_CTX I saw this was an known issue. The only way to fix this was completely secure erase your disk and so all your data on the disk is gone ARRRRGGGGG!!!!!!!!!!!!!!!!!!!!!!!!!!

I found a lot information how to secure erase the disk but finding some mac / apple specific articles was a lot more painful.

So I tried a lot of things and fixing the problem is quite easy if you know the steps. So I explain this for you so it cost you only one evening to fix this 😛

First go to https://partedmagic.com/ and buy and download parted magic ISO ($9). Now burn the parted magic ISO to a CD.

Then boot the parted magic. If you don’t know how to boot from a CD or USB with mac you must press the “option (alt) key” immediately after you press the power button and select the disk.

If parted magic is started, start secure erase and follow the wizard to accomplish this step. If you disk is frozen use the sleep key in the wizard to change the state to “not frozen”.

After the disk is completely erased shutdown the computer.

Now download the Intel SSD drive firmware update tool and burn it to a CD. Then boot the tool and update your disk firmware.

Then reinstall your OSX. For the people who use time machine is very easy to get the latest status back to your pc.

I know one thing for sure. This was my latest Intel SSD…

If I helped you please help me to supporting this blog without any advertising.

Some extra info:
CNET outdated article
Secure erase article from Parted Magic
Nice blog about this issue and fix it with a standard PC

Howto: Build the cheapest XBMC High Definition media center ever a.k.a. XBOX1 Softmod

What do you need?

  1. This ISO (Custom XBOX HD Maker)
  2. Auto installer deluxe (4.5 or higher) (Download: http://aideluxe.com)
  3. Computer with an IDE connection
  4. CD Burner
  5. Screwdriver with a couple of tork plugs
  6. Second-hand XBOX1 with remote (http://marktplaats.nl max €40)
  7. XBOX1 component cable (http://bol.com €6, free shipping coupon @ http://retailmenot.com)

First download and burn the XBOX HD Maker and Auto installer Deluxe to a CD or DVD.

Then disconnect al the  IDE cables except the IDE CD player. Put the XBOX HD Maker CD in the computer. Start the pc and before the BIOS recognize the harddisk press the pause key. Now the boot process is on pause 🙂

Now remove the rubber feeds under the xbox. Then remove all the six tork screws (2 screws are under a sticker). Remove the disk bay (screw are under the IDE cable) and remove the 4 disk screws.

Pull out the IDE cable from your XBOX DVD player. When you start the XBOX now you see a red light is blinking. This is gooood 😉

Now you must connect a video/scart cable (a tv is not necessary but without the cable the xbox cannot start) and power on the XBOX, let the red light blink 3 times and then put the IDE cable from the XBOX hard disk as fast as possible. Now the disk is unlocked so we can flash that XBOX FATX DISK.

Connect the IDE cable from the computer to the disk (primary master is the best, otherwise you can use the secondary master). Then press on the spacebar to continue the boot process and the BIOS must recognize the XBOX disk.

The pc must boot from CD and start the XBOX HD Maker Linux Distribution. Follow the steps on the screen. You must wipe the disk completely and rebuild it and create a new key (option 6 or 7)

Now you can connect the newly build disk to the XBOX and connect the CD player again. Connect the scart to your tv and boot the XBOX from the auto installed deluxe (AID) CD.

Follow the steps on screen, first make a MS Backup, so AID can copy all the necessary files to the XBOX, then choose the softmod option with virtual C drive. Choose XBMC as the default dashboard.

After the installation you can put out the AID CD and boot the XBOX. Now XBMC is started directly.

To make the XBOX 720P compatible (1080 is also possible but the poorly 733Mhz processor  doesn’t like that kind of high resolutions 😛 ) connect the component cable to the XBOX. Then run the “Enigmah Video Mode Switcher”. You can launch this from the XBMC > Programs (if you don’t have programs you can enable this in the option screen). Set the video mode from PAL60 to NSTC. Then reboot the XBOX and start the MS dashboard (easiest way is from file explorer default.xbe on the C:\). Now go to video and enable the 420 and 720 HD resolutions.

That’s it 🙂

Ps. The embedded AID XBOX media center is a little bit old. You can download a new build from: http://www.sshcs.com/xbmc/ or http://t3ch.yi.se/.
Ps2. The next time I i’ll softmod a XBOX1 i will create a youtube video.



[HP] Notebook Enable Bluetooth

I have an Compaq nx7400 notebook. This notebook only have Windows XP/Vista drivers on the HP site. But when you want to activate bleutooth it isn’t working because you need the HP Wireless Assistant to enable the bluetooth radio.

You can find the a Windows 7 compatible HP Wireless Assistant over here: http://h10025.www1.hp.com/ewfrf/wc/softwareDownloadIndex?softwareitem=ob-76368-1&lc=en&dlc=en&cc=us&product=3999409&os=4062&lang=en

You can find the windows 7 compatible Bleutooth drivers over here: http://h20000.www2.hp.com/bizsupport/TechSupport/SoftwareDescription.jsp?swItem=ob-76382-1&lang=en&cc=us&idx=3&mode=4