Friday, December 28, 2012

NSLU2: How to change the hard drive

To migrate the hard drive of your NSLU2 to a new one perform the two follwing steps:
Step 1: Copy the content of the hard disk to a new hard disk.
Step 2: Expand the partition to fill all the available space on the the new hard disk.


Step 1: Copy the content of the hard disk to a new hard disk.

 (in part from http://linuxcommando.blogspot.com/2008/06/show-progress-during-dd-copy.html )

Copy the content of disk 1 (mounted on /dev/sdb) to disk 2 (mounted on /dev/sdc ) (if adjust sdb, sdc, sdd, etc acording to your own configuration, you might use gparted to check the names). Block size below is 1M (1 mb):
$ dd if=/dev/sdb of=/dev/sdc bs=1M  

Follow the progress forof the process by executing the following command in an other command window:
$ kill -USR1  8789
Find the process ID by running the command (and replace 8789 acordingly):
$ pgrep -l '^dd$'
8789 dd
$

Step 2: Expand the partition to fill all the available space on the the new hard disk.

Install gparted, launch it. Expand the large partition on the disk to fill to take advantage of all the available space.Move the other partitions acordingly. Do not delete og shrink any othe the other partitions.

Tuesday, December 25, 2012

Suspend Ubuntu 12.04 LTS on Asus U32U

Do the following
(all instructions from: http://thecodecentral.com/2011/01/18/fix-ubuntu-10-10-suspendhibernate-not-working-bug):

Step 1

Create a script under /etc/pm/sleep.d/. It can be any name, but to ensure the load order, use the prefix 20_.
gksudo gedit /etc/pm/sleep.d/20_custom-ehci_hcd 

#or the way you would normally do when creating a file as superuser  
 

Step 2

Note that if you use the code from "Step 2 Old" below, please skip this step. This script is contributed by commenter Danne.
Insert the following code into the file you have just created:

#!/bin/sh
#inspired by http://art.ubuntuforums.org/showpost.php?p=9744970&postcount=19
#...and http://thecodecentral.com/2011/01/18/fix-ubuntu-10-10-suspendhibernate-not-working-bug    
# tidied by tqzzaa :)

VERSION=1.1
DEV_LIST=/tmp/usb-dev-list
DRIVERS_DIR=/sys/bus/pci/drivers
DRIVERS="ehci xhci" # ehci_hcd, xhci_hcd
HEX="[[:xdigit:]]"
MAX_BIND_ATTEMPTS=2
BIND_WAIT=0.1

unbindDev() {
  echo -n > $DEV_LIST 2>/dev/null
  for driver in $DRIVERS; do
    DDIR=$DRIVERS_DIR/${driver}_hcd
    for dev in `ls $DDIR 2>/dev/null | egrep "^$HEX+:$HEX+:$HEX"`; do
      echo -n "$dev" > $DDIR/unbind
      echo "$driver $dev" >> $DEV_LIST
    done
  done
}

bindDev() {
  if [ -s $DEV_LIST ]; then
    while read driver dev; do
      DDIR=$DRIVERS_DIR/${driver}_hcd
      while [ $((MAX_BIND_ATTEMPTS)) -gt 0 ]; do
          echo -n "$dev" > $DDIR/bind
          if [ ! -L "$DDIR/$dev" ]; then
            sleep $BIND_WAIT
          else
            break
          fi
          MAX_BIND_ATTEMPTS=$((MAX_BIND_ATTEMPTS-1))
      done  
    done < $DEV_LIST
  fi
  rm $DEV_LIST 2>/dev/null
}

case "$1" in
  hibernate|suspend) unbindDev;;
  resume|thaw)       bindDev;;
esac

Step 3

Add executable permission:
sudo chmod 755 /etc/pm/sleep.d/20_custom-ehci_hcd

Result

Your suspend should be now working as expected. Suggestions on improving this script are welcome.