How to make a floppy file image and mounting it in Linux

To make a file image of a floppy disk in Linux (like Ubuntu), you need (of course) a computer with a floppy drive (/dev/fd0). Insert the floppy you want to copy to an image file and issue the command:

$ sudo dd bs=512 count=2880 if=/dev/fd0 of=floppy.img 

Block size (bs) and count above is for a 1,44 MB 3.5" floppy disk.

The image file can be copied back to another floppy disk with the command: 

$ sudo dd bs=512 count=2880 if=floppy.img of=/dev/fd0

The image file can also be mounted directly from the image file without the need of a physical floppy disk: 

$ sudo mkdir /media/fd
$ sudo mount -o loop floppy.img /media/fd/

I use the above method to move the content from a number of floppy disks to my hard drives. Computers today are rarely seen with a floppy drive and I wanted to secure the content before it is too late 🙂 

 

HP Compaq 6910p builtin 3G modem driver for Ubuntu

From Ubuntu 11.04 and onward there is no need for a driver to use the builtin 3G (WWAN) modem in the HP Compaq 6910p laptop computer. But by default the modem is soft blocked even though the radio lamp is on. The rfkill utility can be used to enable it:

$ rfkill list
0: hci0: Bluetooth
Soft blocked: no
Hard blocked: no
1: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no
2: hp-wifi: Wireless LAN
Soft blocked: no
Hard blocked: no
3: hp-bluetooth: Bluetooth
Soft blocked: no
Hard blocked: no
4: hp-wwan: Wireless WAN
Soft blocked: yes
Hard blocked: no

Enable it with rfkill unblock 4

$ rfkill unblock 4
$ rfkill list
0: hci0: Bluetooth
Soft blocked: no
Hard blocked: no
1: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no
2: hp-wifi: Wireless LAN
Soft blocked: no
Hard blocked: no
3: hp-bluetooth: Bluetooth
Soft blocked: no
Hard blocked: no
4: hp-wwan: Wireless WAN
Soft blocked: no
Hard blocked: no

Now click on the network manager icon in the top right bar of the screen and Activate mobile broadband and off you go!

Improving Firefox performance on ASUS EeePC 900

I’ve noticed that a bottleneck in Firefox performance on the ASUS EeePC 900 is writing and reading to the disk cache. It is often I wait for something on a page and I notice that the hard disk light is on indicating read/write.

One way of drastically improving the performance is to move the cache to a ramdisk as the built in flash disk in the EeePC is not the quickest one on the block. This way you might also prolong the life of the flash disk as you decrease the number of read/writes to it. The only drawback with this is that you will loose the cache content between reboots, but I don’t think that is a problem. If you have extended your machine’s ram to 2 GB (se another post about that), you have memory to spend for this, but it will probably work on 1 GB machines too.

If you are running EasyPeasy (probably in other distros too) you already have a ramdisk. Check by starting a terminal and enter the df command. If you see "/dev/shm" you have a ramdisk. Otherwise, you first need to create one (Google might be your friend in this case).

  1. Start Firefox and in the URL-bar, type about:config and press enter. Click yes on the warning about this being very dangerous.
  2. Find the key browser.cache.disk.parent_directory and right click to select Modify. If the key is not present, you right click in the list, select New -> String and type browser.cache.disk.parent_directory
  3. As the value for the key, enter /dev/shm
  4. Pull down the Edit menu and click on Settings
  5. Click on Advanced and select the Network tab
  6. Select the Override automatic cache handling and limit the cache size to for example 100 MB (so the cache won’t eat all your ramdisk).
  7. Close all Firefox and restart it.

In my case, this drastically improved the Firefox performance. 

Copy large amounts of data between servers

There are several methods of moving data between servers in a UNIX/Linux/BSD environment, for example scp, ftp, SMB-shares, NFS-shares or rsync. My experience is that using netcat is one of the faster methods if you have large amount of data to copy.

On the receiving server:

cd /  (or the base directory under which you want to recieve the data)
nc -l 1234 | tar -zxvf -

This will make netcat listen on port 1234 (don’t forget to open the port in the firewall and/or iptables).

On the transmitting server:

tar -zcvf - /data/ | nc -q 1 targethostname 1234  (replace /data/ with the folder you want to copy and targethostname with the hostname or IP-address of the receiving server)

If you have more bandwidth than computing power (i.e. a slow machine) you might want to consider to leave out the "z" in the tar commands on both sides and transfer the data uncompressed.

If you need to move data between physical locations – never underestimate the bandwith of a car loaded with harddisks (quote from a former collegue :)).

 

Ubuntu boot hangs with black screen and blinking cursor

If this happens, check your BIOS setup device boot order. It is possible that some device has been listed before your real boot device.

In my case, my boot SSD drives had been moved below ALL PCI SCSI and there are other drives in the machine which are not bootable causing this problem for me.

 

BIOS setup device boot order

BIOS setup device boot order

Ubuntu boot hangs with black screen after GRUB

It might actually not be hanged, but instead but you might have been kicked into an initramfs shell but it is not displaying on the screen. 

Try to boot in recovery mode or boot on a install CD or USB stick in rescue mode. Edit /etc/default/grub: 

vi /etc/default/grub

Set the following: 

GRUB_TERMINAL=console
GRUB_GFXPAYLOAD_LINUX=text 

If the GRUB timeout is very short it might be a good idea to set it a bit higher so you have a chance to make a selection: 

GRUB_TIMEOUT=10

Save and then execute: 

update-grub

Then reboot the machine and now you may see the emergency shell you are kicked into. Now you can investigate your boot problems further.

Asterisk streaming music-on-hold

In Asterisk it is possible to upload .wav or .mp3 files to be used as music-on-hold (MOH). Another option is to use streaming audio but using a stream from a Shoutcast server requires some hands on.

This is how I did the setup for AsteriskNow 1.7 with FreePBX 2.9.

First of all you will need mpg123 from www.mpg123.de to get the Shoutcast stream from the Shoutcast server.
If you already have gcc on your system you can skip the first step.

yum install gcc
wget http://downloads.sourceforge.net/project/mpg123/mpg123/1.13.4/mpg123-1.13.4.tar.bz2
bunzip2 mpg123-1.13.4.tar.bz2
tar xvf mpg123-1.13.4.tar
cd mpg123-1.13.4
./configure
make
make install

Login to admin of your AsteriskNow / FreePBX server and go to Setup -> Music On Hold. Click on Add Streaming Category. Enter the following: 

Category Name:   radio
Application:     /usr/local/bin/mpg123 -q -s -r 8000 -f 8192 -b 2048 --mono http://192.168.1.2:8000
Optional Format: 
mp3

Most Shoutcast streams are sampled at 44.100 kHz or 22.050 kHz in stereo. In order to use a stream for MOH in Asterisk it must be converted to 8 kHz mono, hence the parameters -r 8000 -f 8192 and –mono.

The IP-address 192.168.1.2 and port 8000 in the example should be replaced by the real ip-adress (or hostname) and the port number of the Shoutcast server you want to stream from.

In order to test the streaming music-on-hold, the easiest way is to set up a dummy extension (extension 446 in this example).
Edit extensions_custom.conf and add the lines below: 

nano -w /etc/asterisk/extensions_custom.conf

exten => 466,1,Answer
exten => 466,2,SetMusicOnHold(radio)
exten => 466,3,MusicOnHold()
exten => 466,4,Hangup

Save it by pressing CTRL-X and respond Y.

Now login to admin of your AsteriskNow / FreePBX server and go to Tools -> Custom Extensions. Click on Add Custom Extension. Enter the following: 

Custom Extension: 466
Description:      radio
Notes

And then click Submit Changes.

Don’t forget to click the orange Submit Configuration Changes in the top of the screen.

If all works as planned you will hear the streaming Shoutcast station when you dial extension 466.
 

Ubuntu 9.10 package mysql-server-5.1 5.1.37-1ubuntu5.1 failed to install/upgrade: subprocess new pre-removal script returned error exit status 1

When trying to do an apt-get upgrade the MySQL package failed with the error message:

package mysql-server-5.1 5.1.37-1ubuntu5.1 failed to install/upgrade: subprocess new pre-removal script returned error exit status 1

The problem is that the start / stop script for MySQL fails to stop the running MySQL server before upgrade.

Solution:

apt-get update
ps ax | grep mysql

Now kill each process that has to do with MySQL.

apt-get upgrade

Voila – now it works and MySQL gets upgraded.

VMware vSphere client 4.0 crashes when trying to upload a file to datastore

 Suddenly my VMware vSphere client version 4.0.0 started to crash when I try to upload a file to the datastore. This happens on both my Windows Vista and XP boxes running the VMware vSphere client.

The problem is similar to the one described in this KB article concering Windows 7 clients. However, the solution is the same. The VMware vSphere client does not crash if it is started by right clicking and runing it as administrator.