View your current network settings with nm-tool

A short post to tell you about a tool named nm-tool. Use nm-tool to display your current network settings. nm-tool is installed as part of the NetworkManager package.

Ubuntu: network-manager package
Fedora: NetworkManager package

As you can see it returns a lot of useful information.

$ nm-tool
NetworkManager Tool
State: connected
- Device: eth0  [Auto eth0] ----------------------------------------------------
 Type:              Wired
 Driver:            r8169
 State:             connected
 Default:           yes
 HW Address:        00:24:8C:95:28:BF
 Capabilities:
 Carrier Detect:  yes
 Speed:           100 Mb/s
 Wired Properties
 Carrier:         on
 IPv4 Settings:
 Address:         192.168.140.11
 Prefix:          24 (255.255.255.0)
 Gateway:         192.168.140.1
 DNS:             192.168.140.19
 DNS:             192.168.140.9
- Device: wlan0  [Auto stargate] -----------------------------------------------
 Type:              802.11 WiFi
 Driver:            ath5k
 State:             connected
 Default:           no
 HW Address:        00:11:6B:62:22:4C
 Capabilities:
 Speed:           54 Mb/s
 Wireless Properties
 WEP Encryption:  yes
 WPA Encryption:  yes
 WPA2 Encryption: yes
 Wireless Access Points (* = current AP)
 stargate:        Infra, 00:14:D1:4E:40:EE, Freq 2437 MHz, Rate 54 Mb/s, Strength 48 WPA2
 *stargate:       Infra, 00:1C:F0:5F:78:A5, Freq 2412 MHz, Rate 54 Mb/s, Strength 90 WPA2
 stargate:        Infra, 00:14:D1:4E:40:EE, Freq 2462 MHz, Rate 54 Mb/s, Strength 45 WPA2
 IPv4 Settings:
 Address:         192.168.142.106
 Prefix:          24 (255.255.255.0)
 Gateway:         192.168.142.1
 DNS:             192.168.140.19
 DNS:             192.168.140.9

Wacom Bamboo CTL460 diagnostics using xidump

I’m going to show you a program called xidump that comes with the Wacom driver.  I use it to view raw data from my Wacom tablet.

Some of the data you can see are:

  • Pen coordinates
  • Amount of pressure
  • Pen Proximity events
  • Button events

I must assume that you already have a working Wacom tablet and that you are using the Wacom driver from Sourceforge.  If not, see my previous post on the subject.  The current driver as of this writing is linuxwacom-0.8.7.tar.bz2

Go to the folder where you downloaded the Wacom driver source.  If you don’t have the driver source anymore, then download it again from the link above.

Extract the driver source.  The xidump program is already prebuilt, therefore you won’t be compiling anything.  It is ready to use.


$ tar jxvf linuxwacom-0.8.7.tar.bz2

$ cd linuxwacom-0.8.7/

If your system is 32-bit, then use the 32-bit xidump.


$ cd prebuilt/32

If your system is 64-bit, then use the 64-bit xidump


$ cd prebuilt/64

If your Wacom table it not connected, please connect it now.  List the available input devices.  If you have the CTL460, like I do, you will be using the device named “Wacom Bamboo 4×5 Pen”


$ ./xidump -l
Virtual core pointer           disabled
Virtual core keyboard          keyboard
Virtual core XTEST pointer     extension
Virtual core XTEST keyboard    extension
Power Button                   extension
Power Button                   extension
Microsoft Comfort Curve Keyboard 2000 extension
Microsoft Comfort Curve Keyboard 2000 extension
Microsoft Basic Optical Mouse  extension
Macintosh mouse button emulation extension
Wacom Bamboo 4x5 Finger pad    extension
Wacom Bamboo 4x5 Finger        extension
Wacom Bamboo 4x5 Pen eraser    extension
Wacom Bamboo 4x5 Pen           extension

Let’s run xidump and view some raw data.  If you have a different tablet than the CTL460, then you will see a different list of device names.  Determine which device name applies to your model using trial and error, if it’s not obvious to you.


$ ./xidump "Wacom Bamboo 4x5 Pen"

After running xidump, pick up the pen and begin using it with your tablet.  You should see a screen like the following in your terminal.

Viewing raw data with xidump

The picture above shows the current coordinates of my pen.  It shows the maximum values.  You can see that I was applying a pressure of 491, which almost half of the maximum pressure value of 1023.  The 01-DOWN event  means that the pen was touching the tablet surface rather than hovering above.  You can use this tool to test various pen and tablet features, while you are using your tablet with other applications such as Gimp.  When you are done, use ctrl-c in the terminal window to terminate program.

Howto: Install Sun Java on Ubuntu 10.04 Lucid Lynx

Sun Java and the Sun Java browser are not installed by default on Ubuntu 10.04 lucid lynx.  Instead, Ubuntu uses the OpenJDK and the Icedtea web browser plugin.  Typical users may never notice a difference as OpenJDK works well in most cases.

However, you may find that you need the real Sun Java instead of the open substitutes.  I will show how to completely remove the OpenJDK packages and how to install the real Sun Java packages.

To completely remove the OpenJDK and Icedtea packages

I removed OpenJDK and IcedTea6 packages with the following command.  On my server, this removed a total of 8 packages.   Before answering “Y” to the following command, look at the full list of packages that it will be removing .   It will attempt to remove other packages which have a dependence on Java.  If you are uncomfortable with some of them, then you should  skip the removal step and move on to the next step and install SUN Java alongside OpenJDK.  The final step will allow you to select Sun Java as the default.

$ sudo apt-get purge openjdk-6-jre openjdk-6-jre-headless
Reading package lists... Done

The following packages will be REMOVED:
ca-certificates-java* icedtea-6-jre-cacao* icedtest6-plugin*
libaccess-bridge-java* libaccess-bridge-java-jni* openjdk-6-jre*
openjdk-6-jre-headless* openjdk-6-jre-lib*

0 upgraded, 0 newly installed, 8 to remove and 48 not upgraded.
After this operation, 87.5MB disk space will be freed.
Do you want to continue [Y/n]? Y

Enable the Canonical partner repository

The Sun Java packages are found in the Canonical partner repository.  Add the partner repository to your repository sources.


$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid  partner"
$ sudo apt-get update

Install the Sun Java packages

Now install the Sun Java packages.  Most people will need only the following packages:

  • sun-java6-jre
  • sun-java6-plugin
  • sun-java6-fonts


$ sudo apt-get install sun-java6-jre sun-java6-plugin
$ sudo apt-get install sun-java6-fonts

If you think that you will need the Java development kit, then add sun-java6-jdk to the list.

  • sun-java6-jre
  • sun-java6-plugin
  • sun-java6-fonts
  • sun-java6-jdk


$ sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-jdk
$ sudo apt-get install sun-java6-fonts

Now set your system to use the Sun Java JRE and Dev packages as the default


$ sudo update-java-alternatives --set java-6-sun

Be sure to restart your web browser so that it will be able to use the sun-java6-plugin.  If you want to verify your version of java then you can do:

$ java -version

If you would like to verify that your web browser java plugin is working, then open your web browser  here

Click on the “Verify Java version” button.

Verifying that the java browser plugin is working

That is all.

Change the login screen background in Ubuntu 10.04

I used to have a custom background setup on my Ubuntu 9.10 system.  My login screen background was reset to the default purple background after upgrading to Ubuntu 10.04.  If you want to setup a custom login screen background there are (at least) two methods.

Method 1

Install Ubuntu Tweak.  Ubuntu Tweak will let you tweak many things including the login screen background.

Ubuntu Tweak

To install Ubuntu Tweak add the third party repository to your list of repositories.

Go to System-Administration-Software Sources, Third-Party Software tab, Add:

 deb  http://archive.getdeb.net/ubuntu lucid-getdeb apps

Add the repository GPG key, open a terminal window and type:

 $ wget -q -O-  http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add -

Install ubuntu-tweak from the command line.

$ sudo apt-get update
$ sudo apt-get install ubuntu-tweak

Method 2

Copy your favorite background .jpg file to /usr/share/backgrounds


$ sudo cp  my_cool_bg.jpg /usr/share/backgrounds

$ sudo cp /usr/share/applications/gnome-appearance-properties.desktop /usr/share/gdm/autostart/LoginWindow

Logout

You should see an “Appearance Preferences” window, select the Add button and select the .jpg file that you want for your login screen background.  Close the window.

Appearance Preferences

Login again and remove the gnome-appearance-properties.desktop file that you copied in the previous step.  This will prevent you from getting the appearance-properties windows at every gdm login.


$ sudo rm /usr/share/gdm/autostart/LoginWindow/gnome-appearance-properties.desktop

Which method should you use?  If you really enjoy customizing your GUI and changing its behavior, then use Method 1 and install Ubuntu Tweak and enjoy having the control over many settings within easy reach.

Make You Own QR Codes

QR codes are also known as “Quick Response” codes.  It is  a 2D matrix type of bar code.  The QR code was originally  invented by a subsidiary of Toyota to manage automobile parts.  The QR code is now public domain and you have probably seen them a number of places, on product packaging, bill boards, in magazine ads, and on-line.  The most common use for them now days is to encode URLs, and addresses.  They are meant to be quickly scanned and read by the camera in your cell phone.  If you have an Android, or an Iphone you have a built-in bar-code scanner that can process the URL stored in these QR codes.

The image below is a QR code that encodes the URL of this website.  If you scan it with the camera in your smart-phone, it should recognize the encoded URL http://nfolamp.wordpress.com and offer you the option of opening your browser to take you there.

QR code for this website

My QR code was created using the following URL:

http://chart.apis.google.com/chart?chs=100×100&cht=qr&chl=http://nfolamp.wordpress.com

You can create your own QR code using the  Google charts tool.   Google charts are an API which allow you dynamically generate charts using a URL and embed them into your web pages.  Use the Google chart URL shown above.  The parameter cht=qr, indicates that this is to be a QR code.  The parameter chs=100×100 is the size.  Change it if you want to change the size.  Use the chl= parameter to indicate the URL that you want to encode.

Google charts is a very powerful tool.  Although  my example demonstrated only  how to create a QR code chart, the number of different types of charts you can create using the Google API is very impressive.   I encourage you to check out the Google charts playground tool and experiment with creating different types of charts.

Growing your RAID array

This is part 3 of a series of posts regarding setting up a linux RAID 5 disk array.  Let’s say you started your disk array with three drives and now you have more funds and you purchased an additional drive to increase the size of your disk array.  Adding a fourth drive to a three drive RAID 5 array will increase your storage space by 50%.  So you get a lot of bang for your buck.

Let’s continue with my example.  I started with three 1 TB SATA drives and now I’m adding a fourth 1 TB drive.  Before I had approximately 2 TB of storage, and after adding this fourth drive, I will end up with approximately 3TB of storage space.

Here are the basic steps that I will cover:

  • Partition the bare drive
  • Add the drive to your array as a spare
  • Grow your array to include this spare
  • Extend your file-system to recognize this additional space
  • Save your new configuration

First lets create an “auto-detect” partition on the bare drive.  You have seen this step before, I’ll include it again to refresh your memory.  This step is essential.

$ sudo fdisk /dev/sde
Command (m for help): n
Command action
    e   extended
    p   primary partition  (1-4)
p
Partition number (1-4): 1
First cylinder (1-133674, default 1);
Using default value 1
Last cylinder, +cylinder or +size{K,M,G} (1-133674,  default 133674):
Using  default value 133674

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid  autodetect)

Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

$ sudo fdisk -l
Disk /dev/sde: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xbe84c178

Device Boot       Start         End      Blocks   Id  System
/dev/sde1               1      133674  1073736373+   fd  Linux raid autodetect

Now we will add this disk, to the our array as a spare drive.  If you merely want to add a hot spare drive to your array, you can stop after this next step.  A hot spare is a drive that is automatically used, whenever you have a failure of one of your active drives.


$ sudo mdadm --add /dev/md0 /dev/sde1

Now in this next step we will initiate the process of growing the existing array to include this new drive.  I say initiate, because this is a very lengthy process.  The data on your existing array is rewritten so that it is spread across four drives instead of three.  This will take several hours.  The good news is that your array remains online during this process.  You don’t have to endure any downtime.


$ sudo mdadm --grow /dev/md0 --raid-devices=4

You can monitor the progress with the file /proc/mdstat.  Periodically “cat” the contents of /proc/mdstat and you can see the percentage of progess.  When it has finished, you will have a four disk array, but your mounted file-system will still show its old size.  It will not automatically recognize the additional space.  You to resize your file-system so that it recognizes the additional free space.  Fortunately this step is very fast and takes only a few minutes.


$ sudo resize2fs /dev/md0

When this is done, you can do df -h and see that your file-system now has the additional free space.  What’s cool is you added lots of free space without downing your box all afternoon.

Please don’t forget to update your array configuration file.  Since you now have a four disk array instead of three, you need to let the system know to expect to see four drives instead of three. 

If you forget this step, you array will not mount after you reboot.


$ sudo mdadm --detail --scan | sudo tee  /etc/mdadm.conf
ARRAY  /dev/md0 metadata=0.90 UUID=622146c2:61b0872d:6bbacb7a:b6d31587

That is all.  Enjoy.

Part II: VirtualBox is giving me friction about my AMD-V

This is an update to an earlier post.  In a previous post, I talked about an issue where after upgrading VirtualBox it was no longer able to run 64bit guests, on some motherboards with AMD-V capable cpus.

After digging a little more,  It seems that having the kernel modules kvm and kvm_amd loaded while running VirtualBox was causing the issue.  The presence of those two modules is causing VirtualBox to wrongly see svm as not enabled.

If you are not using kvm and kvm_amd for other things, you can blacklist those two modules to prevent them from loading.  Here is how you do that.  Create a new blacklist .conf file in the /etc/modprobe.d folder.  Then add a line to blacklist those two modules.

$ echo -e  "blacklist kvm\nblacklist kvm_amd" | sudo tee /etc/modprobe.d/blacklist-kvm.conf

Then reboot.

Before starting your guests after the reboot, first you’ll have to recompile your VirtualBox drivers.  You must do that as root.

$ sudo /etc/init.d/vboxdrv  setup
 * Stopping VirtualBox kernel module
 *  done.
 * Removing old VirtualBox netadp kernel module
 *  done.
 * Removing old VirtualBox netflt kernel module
 *  done.
 * Removing old VirtualBox kernel module
 *  done.
 * Recompiling VirtualBox kernel module
 *  done.
 * Starting VirtualBox kernel module
 *  done.

Your 64bit guests should start and run without issue as they were meant to do.   If not then make sure that you didn’t make a typo along the way.  Then verify that the two kvm modules are not loaded.  If you still can’t get it work, remember that the workaround from the previous post still works wells.

Creating a software RAID5 array

This is Part 2 of a series of posts where I describe building a DIY external RAID5 array.  In Part 1 I talked about the hardware components that I used.   In this post  I will show you how to configure the software RAID5.

To implement RAID5 you need a minimum of three drives.  I begin with three 1TB drives.  Each drive is 1TB in size.  When we are finished we will have a device that is 2TB in size and is fault tolerant.   If one drive should fail, we will be able to replace the failed drive and rebuild our array without losing data and continue on.

  • /dev/sdb
  • /dev/sdc
  • /dev/sdd

The first step is to partition your drives.  Linux software raid uses a special type of partition called a “Linux raid autodetect” partition (type 0xfd).  More about the “autodetect” partition later, but for now lets begin partitioning the drives.  I’ll show you how to the first drive /dev/sdb.  Repeat the same steps for drives /dev/sdc and /dev/sdd.

$ sudo fdisk /dev/sdb
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-133674, default 1);
Using default value 1
Last cylinder, +cylinder or +size{K,M,G} (1-133674, default 133674):
Using default value 133674

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Repeat for drives /dev/sdc and /dev/sdd.  When you are done you should have three drives which look like the following.

$ sudo fdisk -l
Disk /dev/sdb: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xbe84c178

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      133674  1073736373+  fd  Linux raid autodetect
Disk /dev/sdc: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xf70d7ba7

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1      133674  1073736373+  fd  Linux raid autodetect
Disk /dev/sdd: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x681afb7b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1      133674  1073736373+  fd  Linux raid autodetect

I can now combine these three partitions to create the RAID5 device /dev/md0.


$ sudo mdadm --create --verbose /dev/md0  --level=5 --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1

mdadm: layout defaults to left-symmetric
mdadm: chunk size defaults to 64K
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: size set to 1073736256K
mdadm: array /dev/md0 started.

The previous command merely started the process of combining the three drives into a single RAID5 device.  This process will take a while to complete.  You can check it’s progress by displaying the special file /proc/mdstat.

$ cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sdd1[3] sdc1[1] sdb1[0]
21474725512 blocks level 5, 64k chunk, algorithm 2 [3/2] [UU_]
[========>.............]  recovery = 35.0% (376037544/1073736256) finish=128.6min speed=90402K/sec

usused devices: <none>

From the information above, you can see that the process can take a long time depending on the size and speed of your drives.  It is 35% complete, and the ETA is 128.6 minutes.  You can continue to “cat” the /proc/mdstat file to check the progress.  When it is finished, you should see something like the following.

$ cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sdd1[2] sdc1[1] sdb1[0]
      2147472512 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU]

unused devices: <none>

The raid device /dev/md0 is now ready for use.  I can now format it with a filesystem.  I choose to format it as an ext4 filesystem.  For this example I will mount it as /srv/d1.  You can mount it however you wish (i.e. /usr/local, /opt).

$ sudo mkfs.ext4 /dev/md0
$ sudo mkdir /srv/d1
$ sudo mount /dev/md0 /srv/d1

I’ll edit my /etc/fstab file and add the following line.

/dev/md0     /srv/d1   ext4      defaults      0 0

I am almost done.  However we must now save the configuration information of our array so that it can be discovered at boot time.  The following command can be used to examine your raid array and also to save its configuration to a file to be used at boot time.

$ sudo mdadm --detail --scan | sudo tee /etc/mdadm.conf
ARRAY /dev/md0 metadata=0.90 UUID=622146c2:61b0872d:6bbacb7a:b6d31587

We are now done.  The raid device has been created and mounted.  We saved its configuration so that it can be discovered and remounted after each boot.

$ df -h
Filesystem               Size  Used Avail Use% Mounted On
/dev/mapper/vg0-lv_root  9.7G  2.2G  7.5G  23% /
tmpfs                    501M  348K  501M   1% /dev/shm
/dev/sda1                194M   23M  162M  13% /boot
/dev/md0                 2.0T  199M  1.9T   1% /srv/d1

In Part 3, I will deal with growing the array by adding a disk to the array to make it a four disk array.

DIY external RAID5 array

Here is a home project I did almost a year ago and I’m very pleased with it.  I wanted to create an external drive array.  1TB drives was my choice.  Initially I built this as a 3 drive array, and within a few weeks I grew it to a 4 drive array.

First I purchased the enclosure for about $19.  The enclosure is basically just a metal frame meant to hold up to 5 drives.  It includes a fan, although the fan is not really needed, because the ambient air is enough to cool the drives.  It has a power switch and an ATX connector. It accepts an ATX power supply to power the drives and fan.

hddrack5_frontview

Drive enclosure front view

hddrack5_sideview

Drive enclosure side view

The cool thing about using SATA drives is that they use a SCSI protocol and you can use them with a SAS cable.  Rather than have four individual eSATA cables connect each drive, I found a single SAS cable that fans out to four SATA connectors.

SAS fan out cable

SAS to SATA "fanout" cable

The cable in the picture is a short version.  My cable is 1 meter in length.  I found the cable online for about $55.  The SAS cable connects to my SCSI controller card.  It’s an IBM LSI type PCI express controller.  You should be able to find them on Ebay.  The controller card is already supported by linux.


$ sudo lspci -nn

02:00.0 SCSI storage controller [0100]: LSI Logic / Symbios Logic SAS1068E PCI-Express Fusion-MPT SAS [1000:0058] (rev 08)

I’m using software raid5 built into the linux kernel, because I’m want maximum compatibility.  Also, my controller card doesn’t do RAID5.   I’m not overly concerned about speed.  This is intended to be a fault tolerant file server where I will keep music, photos, videos, backup images, and other important data.

Here are photos of the finished array.

Enclosure with power supply

Drive Enclosure with ATX power supply atop

I used thick double faced tape to mount the ATX power supply on top of the drive array.  The total height is 11 inches.  A black power supply would have been a better choice, but I already had this one laying around and ready for use.

Enclosure_other_side

A view from the other side showing drive fan

The picture above is a view from the other side.  The extra unused molex connectors are tucked away.  I debated, removing them by opening up the power supply and cutting them away, but ultimately I left them.  The drive fan is remarkably silent.  It could probably be removed without as there is enough ambient air to cool the drives.

Enclosure_in_use

A view of the drive array in normal use

And finally a night time shot of the drive array in use.  The led lighted power supply is glowing in the night.  The camera lens adds to that affect.  The actual glow is less dramatic.

Enclosure_nighttime

A view of the drive array at night

The four drive array gives me a total of 2.7TB of fault tolerant storage.  It is currently mounted on my Fedora 12 server.  Look for more details to come in a part 2 of this series where I show how to create the RAID array and how to grow it.

Ubuntu 10.04 and Broadcom BCM43xx wireless

After installing Lucid Lynx Ubuntu 10.04 on my laptop, I had no wireless.  The wireless worked find under the previous two versions of Ubuntu.  The solution is to install the Broadcom 802.11 Linux STA wireless driver source.


$ sudo apt-get install bcmwl-kernel-source

$ sudo reboot

After rebooting, wireless works.

Updated: BTW my laptop is an HP Compaq nx6325.

Here are the vendor and device codes for my wireless.


$ sudo lspci -nn

30:00.0 Network controller [0280]: Broadcom Corporation BCM4312 802.11a/b/g [14e4:4312] (rev 01)