Saturday, August 29, 2015

Rescuing my ExFAT formatted Thunderbolt drive on OS X... or was it FAT32?

I got myself an external Thunderbolt drive. Put some Parallels Virtual Machines on a ExFAT (or FAT32?) partition... Worked great for ± two weeks.

I wanted to reboot my Mac, after shutting a Windows VM down the spinner showed for 10+ minutes without any (noticeable) activity... Forced Parallels to quit and that f*cked up the something-FAT partition. After the reboot it didn't mount (the HFS+ partition on the same disk did however).

Wasn't so sure because Disk Utility showed it was "MS-DOS" (FAT32) and it didn't want to mount anymore. "Verify Disk" showed something like this:

Verifying volume “disk6s4”
Verifying file system.** /dev/rdisk6s4
Invalid sector size: 0
File system check exit code is 8.
Error: This disk needs to be repaired. Click Repair Disk.

"Repair Disk" didn't work, so I tried to mount it in Parallels so I could run Ultimate Boot CD and run testdisk or something, also didn't work...
After some googling I learned about the existence of fsck_exfat. So I tried it:
sudo fsck_exfat /dev/disk6s4
** Checking volume.
** Checking main boot region.
   Main boot region is invalid.  Trying alternate boot region.
** Checking alternate boot region.
** Checking system files.
** Volume name is Storage.
** Checking upper case translation table.
** Checking file system hierarchy.
** Checking active bitmap.
** Rechecking main boot region.
   Main boot region needs to be updated.
Update? y
** Rechecking alternate boot region.

I like the way that looked! Unfortunately, it still didn't want to mount...

Accidentally pressed the "Repair Disk" button... And guess what:
Verify and Repair volume “Storage”
Repairing file system.
Checking volume.
Checking main boot region.
Checking system files.
Volume name is Storage.
Checking upper case translation table.
Checking file system hierarchy.
Checking active bitmap.
Rechecking main boot region.
Rechecking alternate boot region.
The volume Storage appears to be OK.
File system check exit code is 0.
Updating boot support partitions for the volume as required.
Now it mounts again! \o/

Going back to the search results I found Repairing a Corrupted Mac OSX ExFAT Partition like 4 results lower which describes above method exactly.
He found out first so if this helped to save your partition too, he deserves all the credit!

Tuesday, July 8, 2014

Getting rid of p3p0 p3p1 p3p* ethernet naming in (Ubuntu) Linux

UPDATE 15-04-2016:With 16.04 you need biosdevname=0 net.ifnames=0 

Since I switched to a new mainboard, I constantly got annoyed by the "new ethernet naming convention". Apparently that is the mechanism causing my ethernet cards suddenly being named p3p*. It is not a big issue that it happens, but something is preventing consitent naming of my networking devices.

After minor kernel updates, suddenly p3p0 is named p3p1. Thanks to this blog post's comments I finally have the eth* names back.

Short summary of the post

Just make sure you add biosdevname=0 to your boot options, e.g. by modifying /etc/default/grub and running $ sudo update-grub.

As a side remark, it should already name consistent by adding a rule to /etc/udev/rules.d/70-persistent-net.rules but this only happened automatically after setting the boot option. 

I experienced this myself on Ubuntu 12.04 and 14.04, but apparently RedHat based distro's are also affected. 

Monday, May 27, 2013

My progress on installing Ubuntu/Linux on Asus Vivotab Smart ME400C

Update 21/03/2014: I sold the it, so unfortunately there will be no further updates here.

I wanted to share my progress on the XDA-Developers forum, but since I don't have ten posts I can't reply there. Bummer, since I think not many people got this far and could help other people complete this.

I bought this tablet because it was Atom-based, so I could use Ubuntu if I didn't like W8.
Too my surprise I liked it pretty much. But... I do like to hack stuff more, so tried installing Linux anyway.

A lot of people say that it has "Secure Boot" and hence it is impossible to try and install anything else than Windows 8. Luckily, you can turn this off.

By turning this off, it enabled me to install the rEFInd Boot Manager which allowed me to boot an Debian EFI test CD. Since this tablet contains an Intel Atom Z2760 that does not have an 64-bit instruction set, you will need 32-bit (IA32) EFI binaries (which are very rare).

Only the Debian EFI test CD and an Fedora (experimental) image which I can't find anymore are the  ones having those.

Having an Micro-USB to USB Female OTG adapter allowed me to connect a (powered) USB-hub and connect an USB keyboard, mouse and Ethernet-adapter. Selecting an boot-item in rEFInd is possible with the physical buttons, but for editing boot-line options you really want to use at least an keyboard.

I will post some photo's and detailed instructions later.

UPDATE 23/06/2013: 

If you found this page to find out if this is at all possible. As of 23/06/2013 not yet. I
like Windows 8 a lot better on a tablet, but it still hangs a lot and sometimes even completely reboots for no reason at all. Also battery drains very quickly.
My advice is to not buy this tablet if you are in doubt and get an Android-based tablet or if you are using Mac OS X, an iPad instead. A lot cheaper and x86 instead of ARM will not gain you anything. Using regular desktop applications which are available for Windows x86, are mostly really not made for touch-usage or tablets in general and will frustrate you.

Things that went wrong:
The Ubuntu WUBI installer, this gets you an extra boot entry but won't boot. I think because it is loaded by an Microsoft EFI bootloader. Don't panic if you tried this and are afraid you can never boot to Windows again since it does not respond to button-presses, just do a hard reboot by holding them for like 10 seconds and select Windows instead of Ubuntu. It will automatically boot the last option after a timeout.

How to get rEFInd running and run ISO :

The instruction on the rEFInd website for Windows are very clear, but might be a little hard if you don't work with a command prompt very often.

Note that you will need the 32-bit version of rEFInd, so do not remove refind_ia32.efi. as described in step 7. To help you getting it done on the VivoTab, these are the (modified and supplemented) instructies I copied on 23/06/2013.

  1. Locate Command Prompt in the Start menu, right-click it, and select Run as Administrator. This action opens a Command Prompt window with administrative privileges. If you do not have a mouse, by default touch-and-holding does the same as right-clicking.
  2. Type mountvol S: /S in the Administrator Command Prompt window. This makes the ESP accessible as drive S:from that window. (You can use a drive identifier other than S: if you like.)
  3. Change into the main rEFInd package directory, so that the refind subdirectory is visible when you type dir.
  4. Type xcopy /E refind S:\EFI\refind\ to copy the refind directory tree to the ESP's EFI directory. If you omit the trailing backslash from this command, xcopy will ask if you want to create the refind directory. Tell it to do so.
  5. Type S: to change to the ESP.
  6. Type cd EFI\refind to change into the refind subdirectory
  7. Type del refind_ia32.efi to delete the unused 32-bit version of rEFInd. (Windows only supports EFI boots on 64-bit EFI implementations and in 64-bit versions of Windows.)  Don't do this, since this tablet has an x86 Intel Atom processor, you need the 32-bit binary
  8. Optionally type rd /s drivers_ia32 to delete the drivers_ia32 directory and its contents. You may also want to selectively delete some of the drivers in the drivers_x64 directory, depending on your needs. Unnecessary drivers may slow the rEFInd start process. See the page on drivers for more on this topic. Same story as above, you can delete the 64-bit drivers. I kept them because they don't use a lot of space.
  9. Type rename refind.conf-sample refind.conf to rename rEFInd's configuration file.
  10. Type bcdedit /set {bootmgr} path \EFI\refind\refind_ia32.efi to set rEFInd as the default EFI boot program. Note that {bootmgr} is entered as such; that's not a notation for a variable. I changed the 64-bit to 32-bit for your convenience. 
  11. If you like, type bcdedit /set {bootmgr} description "rEFInd description" to set a description (change rEFInd description as you see fit).
(I would like to emphasize that I do not claim copyright on this text, the original instructions are written by Roderick W. Smith, the writer of rEFInd. Please consider donating him, because he did a great job :) )

The following you need to do is configure rEFInd. There are drivers which let you boot an ISO-image. I haven't got that to work yet. I managed to resize the Windows 8 partition and create some smaller 700 MB partitions where I copied several installation CD's. Especially the "scanfor" option in rEFInd helps in that. Unfortunately, I didn't get any further than getting GRUB 2 and selecting one of Debians installation modes, both graphic and text gave me a black screen.

Good Google Web Font alternatives to commercial font faces

Helvetica/Arial, see:

Century Gothic: Questrial

Bradley Hand ITC: not found yet..

Saturday, November 10, 2012

Raspberry Pi with 16-bit I2C IO-expander MCP23017

I want to add some physical buttons to my Raspberry Pi. The most easy (and cheap) way is by just adding some push-buttons.

Since the GPIO ports are quite limited I purchased a MCP23017. This is a so-called 16-bits I/O expander which can be used over I2C. This gives me 16 extra inputs/outputs by using only two wires (four if you count VCC and GND), they are adressable so you can chain a lot of them and have even more ports.

I don't have any prior experience wiring and using those. Luckily there are a lot of people already using it, also with their Pi:

Having the datasheet open also helps a lot, some articles had the wiring a little wrong (SCL/SDA mixed up). There are a lot of other I/O expanders, but most of them are 8-bit. Also, that I saw other people using this on 3.3V was one of the reasons I bought this one.

My goal is to get this working with the linux gpio-keys module, so the pushbuttons act like real keys and work directly with all programs (e.g. XBMC). Unfortunately I can't seem to find a lot of information to make this work. Since I also want to make sure I understand what's happing I'm first trying to get the I/O-expander to do what I want using Python.

Really helpful Python-libraries I found are: (For the RPi GPIO's in general)

Also, this website which explains using the MCP23017 with a microcontroller helped me understand how to use this:

The expander also has built in pull-up resistors, so you don't need "real" ones between your buttons and the ports, saving some space.

I hope to get this working soon with the python-uinput mode to realize what I want.

Other related and helpful resources:

Sunday, August 12, 2012

Linux SSD optimalization

Since the SSD prices are dropping and it's still summer vacation so I have a more spare time than usual, I decided to upgrade one of my servers with an SSD. Since the server I upgraded is very multifunctional it could benefit a lot from optimization, it functions mainly as NAS (CrashPlan for Windows, Time Machine for OS X) but is also used as Home Theatre PC (XBMC).

Luckily there are a lot of resources about optimizing your SSD in Linux.

Very helpful resources were:

I ended up doing the following:

  • Partitioning the hard disk with gdisk, which helps me align the partitions
  • Use Logical Volume Management (lvm) 
    • Using the --dataalignment option (see also link) for the physical volume
    • Creating an ext4 partition on the logical volume with adjusted block size and stripe/stride-parameters
  • Mounting the ext4 partition with noatime and discard options
  • Using noop scheduler for the ssd's only (see script below)
  • Mounting /var/tmp and /var/log in ramdisk
  • Enable writeback (see script below)
  • Make the "swappiness" as low as possible
  • Use ionice to give XBMC priority over netatalk/crashplan when watching movies
    This is not because of the SSD, but I moved one of my RAID-0 harddisks from S-ATA600 to S-ATA300 because I expect the SSD will use the higher throughput better but apparently this caused problems (stuttering in movies) when a computer was backing up and watching a movie at the same time..
To set the scheduler and writeback to the right disks I modified the rc.local-script I found on the ArchLinux wiki:

declare -ar SSDS=(

for SSD in "${SSDS[@]}" ; do

  if [[ -e $BY_ID ]] ; then
    DEV_NAME=`ls -l $BY_ID | awk '{ print $NF }' | sed -e 's/[/\.]//g'`

    if [[ -w $SCHED ]] ; then
      echo noop > $SCHED
   hdparm -W1 /dev/$DEV_NAME

I also used this opportunity to switch to UEFI and LVM. Especially the UEFI took a whole lot more than I expected. I will write an article about that later.

Friday, August 10, 2012

LCDproc on Mac OS X

I had the opportunity to order some small LCD's (HD44780) at a very fair price, since I already got one in my backup-server i tried to get it working on my docked MacBook running Mac OS X (10.8). Took some time, but in the end I got it working with not too much effort.

Steps I took were:

  1. Download LCDproc source from the official website
  2. Install libusb from homebrew (brew install libusb)
  3. Install libftdi from homebrew (brew install libftdi) <-- this was needed because I used a FT245RL brekout board to connect it.
  4. Configure with "./configure --prefix=/usr/local/ --enable-drivers=all --includedir=/usr/local/include/ --enable-libftdi=yes"
  5. make -j6
  6. sudo make install
Then changed /usr/local/etc/LCDd.conf like this: (only changed/added values shown).




Of course, you need to have the XCode Command Line tools installed. Also I had the FTDI D2XX driver already installed, the VCP drivers will most likely conflict with libftdi.

I also got it showing my Growl notifications thanks to