postfix only listens on localhost (127.0.0.1)

On a newly installed VPS (Parallells Virtuozzo) running Ubuntu 12.04 LTS I also installed postfix as my MTA. However, it turned out that it only listened on localhost. I checked that "inet_interfaces = all" in main.cf and that my /etc/hosts was up to date with my server’s hostname. The reason was that the machine had sendmail preinstalled and running.

A netstat -an gives: 

tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN

To the solution to this is: 

sudo /etc/init.d/sendmail stop
sudo update-rc.d -f sendmail remove
sudo /etc/init.d/postfix restart

Now netstat -anp show that postfix listens to all interfaces: 

tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 691/master

 

Avoiding a SSH client connection to timeout

If you’re behind a firewall you sometimes run into a problem where the SSH client connection times out after a period of time (typically when going out for lunch leaving your SSH sessions logged in). The easiest way to solve this is by changing the configuration of the SSH client (it can also be fixed through the server config but since the problem often relates to the firewall protecting the client it is a better solution to fix this in the client). 

Just edit the file ./ssh/config and add the lines: 

Host *
ServerAliveInterval 30

The above assumes the firewall drops inactive connections at an interval > 30 seconds. 

 

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. 

ASUS EeePC 900 2 GB memory upgrade

The ASUS EeePC 900 is a dear friend of mine and has served me truly for a number of years. It is not my primary work horse, but on trips it is excellent with it’s small size and low weight (even on a 14 day trip I always travel with hand luggage only). It is also a comfort when travelling to know that I am not carrying an expensive piece of equipement. This little fellow has been my travel companion to many different countries – near and far away. So I really don’t want to retire it and recently I decided to "pimp it" a little. When running a couple of applications it quickly consumes the 1 GB of RAM, so a little bit more wouldn’t hurt.

It ships with 1 GB of RAM installed and it is possible to upgrade it to 2 GB. It is actually a question of replacement rather than expansion due to the fact that there are no free memory slots. The upgrade is performed by replacing the 1 GB SODIMM with a 2 GB SODIMM.  

For specifications of the ASUS Eee PC 900, see this wikipedia page.

The memory module needed is a DDR2-400 SODIMM but 533 and 667 MHz will also work. I used a Crucial 2GB DDR2 PC-5300 667 MHz CL5 SODIMM. Note that memory modules are sensitive to static discharge. Preferrably you should at least have a grounding wrist wrap or even better if you have access to an ESD secure work place. In reality most of us will just rely on the kitchen table and being careful not to touch any connectors or metal parts of the memory module. That will also work in most cases 🙂 

  1. Unplug the power cord and remove the battery. 
  2. The memory module is hidden behind a hatch on the bottom of the PC. The hatch is secured with two screws, one hidden behind a EeePC label (possibly acting as a warranty void seal). Remove the two screws and the hatch. 
  3. Remove the preinstalled 1 GB SODIMM by pulling locking plates on the sides a bit apart until they release the module.
  4. Insert the new 2 GB SODIMM and make sure it locks by pushing it gently down until the locking plates clicks into position.

  5. Reinstall the latch and the two screws.
  6. Install battery and connect power cord.
  7. Say your prayers, press the power button and hopefully your EeePC boots up so you can enjoy your brand new 2 GB of RAM!

 

Mobile internet broadband in Latvia

When I travel abroad I need to stay connected to the Internet, not just for fun but I have to be connected for my work. Relying only on Wifi is not a solution as I recently discovered the hard way on a trip to France. The Hotel advertised "WiFi internet" but this however, turned out to be a connection limited to only web and mail (all traffic forced through a proxy). I needed VPN to work.

The most convenient and cost effective solution is to purchase a prepaid mobile broadband from a local provider. That way I will have 3G Internet connection during my stay.

To not be forced to buy a USB modem with every prepaid mobile Internet, I purchased a Huawei E585 3G/WiFi pocket router which is not SIM locked (works with any provider). This little thing has a battery that last for a couple of hours and I only need to buy prepaid SIM-cards in the countries I visit.

I went on a trip to Latvia and my choice fell on Okarte Internet via computer. They are covering 92% of Latvia for the moment.

There are two choises – a SIM card bundled with a USB modem for Ls 9 or just the SIM card for Ls 4. It includes one week of surf (up to 50 GB) and can then be refilled. According to Okarte’s website it could be purchased on many sales points, for example Narvesen or Plus Punkt kiosks.

The first store I stopped by could only sell refills. The second store didn’t have the SIM card only so I actually bought the package with a USB modem for Ls 9, figuring Ls 5 was a cheap price for not having to run around more stores. The modem was never used, instead I put the SIM card in my pocket router.

Even though Okarte’s website is in Latvian, Russian and English nothing in the package speaks any English, only Latvian and Russian which is of little help for me.

The major problem I encountered was that there was no technical information in the package, especially regarding APN which is crucial. I looked at my network manager in Ubuntu which actually has preconfigured choises for Okarte and found out that the APN is open.lmt.lv.

With this APN set I could surf away from my resort location in Jurmala enjoying download speed at around 4-7 Mbps and upload 0,45-1 Mbps.

 

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