Debain 4.0 Etch AMD 64 X2 Server from Hetzner
I bought a new server from Hetzner (German) on Sunday 4th November and on the evening of the 5th I received my sign in details by email in both German and English for the server, already installed with the 64bit version of Debian Etch. This post documents my progress setting it up.
Exploring the Control Panel
The first email you get gives you a sign in to the Hetzner control panel (they call it Robot). Everything is in German but here are some translations of the interface (thanks to Google Translate):
Verwaltung Administration
Sicherheit Security
E-Mail-Adressen Emails
Support-Anfragen Support requests
Status-Benachrichtigung Status Notification
Newsletter Newsletter
RIPE-Registration RIPE-Registration
Rechnungen Bills
Offene Posten Open Item
Traffic-Statistik Traffic Statistics
Traffic-Limit-Reporting Traffic limit Reporting
Tagesbericht Daily Report
Monatsbericht Monthly Report
Jahresbericht Annual Report
Leistungsübersicht Performance Overview
Resetaufträge Reset orders
Rescuesystem Rescue System
VNC-Installation VNC-Installation
neuen Server bestellen New server order
Separater Admin-Zugang Separate Admin Access
Reverse-DNS-Einträge Reverse-DNS
Eintrag anlegen Entry
Eintrag löschen Delete Entry
Dokumentation Documentation
Daten-Export-Schnittstelle Data Export interface
Perhaps the two most useful entries are Resetaufträge and Rescuesystem. The Resetaufträge page gives you three main options:
``Automatischen Hardware-Reset auslösen`` - Perform an automatic hardware reset.
STRG+ALT+ENTF an den Server senden - Send a CTRL+ALT+DEL signal to the server
Manuellen Hardware-Reset beauftragen - Request a member of the Hetzner staff manually reboot your server.
There is a warning with this last one which translates as:
Please note that manual Hardware-Resets only during our business hours, Monday through Friday 6:30-22:45 pm, Saturday 10-17 hours delay Edited. Outside of business hours, you can Robot menu under "support requests" our 24-h-Rufbereitschaft contact. Also available in the Guide for support operations valuable information.
I’m not sure if there is a charge for the manual reset.
The Rescuesystem sets up a config file for 5 minutes so that if you server reboots it will boot over the network using DHCP into a Hetzner-specific rescue system as long as you have a modern machine (mine was bought in November 2007 and works perfectly). The message translates as:
When activating the rescue system is a DHCP server on our configuration file. When rebooted your server will be booted from the network grabs this configuration file for the rescue system and loads a minimal base system from our TFTP. You can rescue the system will use as long as you need it. The order for the rescue system remains 5 minutes activated. If you then reboot your server will return your usual system of hard.
Caution:
Whether your server about the rescue system can boot depends on whether the network card on the server network is set to boot. This is only the latest in servers as a default by us so. If it is still not set, the server after activating the rescue system at the next reboot with the existing system from the hard disks. Should your server will be converted, then send an e-mail to support@hetzner.de or if you know where your server is equal to the appropriate data center. Indicate whether the change immediately, or at any time any of us can be carried out or by appointment only. The conversion is associated with down-time of about 5 minutes. We ask for your understanding if it in the handling of the changeover contracts to small delays can occur.
You have to choose whether to use the 32bit or 64bit system and then when you clcik the Aktivieren button the rescue system config is set up and you are given a password you’ll need to login then if you reboot your server within 5 mins you will be booted in to the rescue system. Very handy.
It is well worth reading the help files (in this case run through Google translate) for more information about the Hetzner setup.
Checking the Stats
Here are some stats showing what a fresh setup looks like:
Debian-40-etch-64-minimal:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 365G 520M 346G 1% /
tmpfs 2.0G 0 2.0G 0% /lib/init/rw
udev 10M 36K 10M 1% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
Debian-40-etch-64-minimal:~# cat /etc/issue
Debian GNU/Linux 4.0 \n \l
Debian-40-etch-64-minimal:~# uname -a
Linux Debian-40-etch-64-minimal 2.6.18-5-amd64 #1 SMP Tue Oct 2 20:37:02 UTC 2007 x86_64 GNU/Linux
Debian-40-etch-64-minimal:~# free -m
total used free shared buffers cached
Mem: 3926 73 3853 0 12 19
-/+ buffers/cache: 41 3885
Swap: 2055 0 2055
These commands show I’m using Debian 4.0 with a 364Gb hard disk on an AMD 64 machine and that I have 3853Mb of free RAM, using only 73Mb in total.
Re-Installing The Operating System
The first time I tried to setup the server with Xen it all went horribly wrong. This is because Xen expects Grub to be present but the default Hetzner Etch AMD64 image comes with Lilo. I tried removing lilo and setting up grub manually but to no avail although I did learn a lot about Grub as a result of my experiments and can recommend this excellent guide to grub.
Following the instructions in the previous section I initialed the rescue system, rebooted and then used SSH to connect. Since this isn’t the same install you get an error from your SSH client until you remove the existing host from the known hosts file on your local machine:
james@dirac:~$ ssh root@doppler.3aims.com @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that the RSA host key has just been changed. The fingerprint for the RSA key sent by the remote host is 50:10:6b:5f:dc:e7:45:17:73:00:d0:50:f0:0e:48:be. Please contact your system administrator. Add correct host key in /home/james/.ssh/known_hosts to get rid of this message. Offending key in /home/james/.ssh/known_hosts:1 RSA host key for doppler.3aims.com has changed and you have requested strict checking. Host key verification failed.
Sign in as root with the password you got after clicking Aktivieren. Once you are in you see this:
Linux rescue 2.6.22.2 #2 SMP Tue Aug 28 09:28:15 CEST 2007 x86_64 ------------------------------------------------------------------ Welcome to the Hetzner Rescue System. This Rescue System is based on Debian 4.0 (etch) with a newer kernel. You can install software like in a normal system. To install a new operating system from one of our prebuilt images, run 'installimage' and follow the instructions. For more information take a look at http://wiki.hetzner.de ------------------------------------------------------------------ root@rescue ~ #
I ran the install script installimage choosing 64bit Debian 4.0 Etch and then editing the following settings in the config file:
- FORMATDRIVE2 = 1
- This sets up the second hard drive so you can actually use it.
- BOOTLOADER = grub
- This sets up the bootloader to use grub so that you can install Xen.
When you’re done the install sets to work:
Hetzner Online AG - installimage
#~ server will be installed now. this will take a few minutes.
#~ you can abort at any time with CTRL+C ..
#~ ( init) ~ reading vars... [ OK ]
#~ ( 1/11) ~ deleting partitions... [ OK ]
#~ ( 2/11) ~ creating partitions and fstab... [ OK ]
#~ ( 3/11) ~ formatting partitions... [ OK ]
#~ ( 4/11) ~ mounting partitions... [ OK ]
#~ ( 5/11) ~ extracting imagefile from local... [ OK ]
#~ ( 6/11) ~ setting up network config for eth0... [ OK ]
#~ ( 7/11) ~ chrooting some commands... [ OK ]
#~ ( 8/11) ~ clearing logfiles... [ OK ]
#~ ( 9/11) ~ setting up some files... [ OK ]
#~ (10/11) ~ setting up rootpassword... [ OK ]
#~ (11/11) ~ setting up bootloader grub... [ OK ]
#~~~ INSTALLATION COMPLETE ~~~#
you may now reboot into your new system
you can login to your new system with the same
password as you logged in into the rescue system
root@rescue ~ #
When you type reboot the server reboots back into a new Debian Etch install, this time using Grub and with the second hard disk available.
Installing Xen
Now that we have grub set up, installing Xen is as simple as entering two commands:
apt-get install xen-linux-system-2.6.18-4-xen-amd64 reboot
The OS will then reboot into the Xen DomU. You’ll probably want the 5 free IP addresses Hetzner offer so that each Xen virtual machine can have its own IP address. You can request them from the Support-Anfragen section of the control panel. Choose the Subnetze für DS2000/DS3000/DS5000/DS7000/DS8000/DS9000 beantragen option.
According to this article about Xen on Hetzner you cannot use bridging on Hetzner. Instead you have to use routing via DomU.
Edit /etc/xen/xend-config.sxp so that it only contains these lines:
# -*- sh -*- (network-script network-route) (vif-script vif-route)
Restart xend:
/etc/init.d/xend restart
According to this page you will also need to run this command:
echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp
Xen is now setup ready for you to create some images.
Checking the Stats Again
Here are some stats showing what the new Xen setup looks like:
Debian-40-etch-64-minimal:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 365G 612M 346G 1% /
tmpfs 1.7G 0 1.7G 0% /lib/init/rw
udev 10M 36K 10M 1% /dev
tmpfs 1.7G 0 1.7G 0% /dev/shm
Debian-40-etch-64-minimal:~# cat /etc/issue
Debian GNU/Linux 4.0 \n \l
Debian-40-etch-64-minimal:~# uname -a
Linux Debian-40-etch-64-minimal 2.6.18-4-xen-amd64 #1 SMP Fri May 4 02:40:51 UTC 2007 x86_64 GNU/Linux
Debian-40-etch-64-minimal:~# free -m
total used free shared buffers cached
Mem: 3366 200 3165 0 1 15
-/+ buffers/cache: 182 3183
Swap: 2055 0 2055
Debian-40-etch-64-minimal:~# fdisk -l
Disk /dev/sda: 400.0 GB, 400088457216 bytes
255 heads, 63 sectors/track, 48641 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 262 2104514+ 82 Linux swap / Solaris
/dev/sda2 263 48641 388604317+ 83 Linux
Disk /dev/sdb: 400.0 GB, 400088457216 bytes
255 heads, 63 sectors/track, 48641 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
As you can see, using Xen takes a bit more memory but it doesn’t look like the second disk has any paritions or has been formatted by the Hetzner install after all.
Mounting the Other Hard Disk
Let’s create a partition:
Debian-40-etch-64-minimal:~# fdisk -u /dev/sdb The number of cylinders for this disk is set to 48641. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First sector (63-781422767, default 63): Using default value 63 Last sector or +size or +sizeM or +sizeK (63-781422767, default 781422767): Using default value 781422767 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
And then format it using an ext3 filesystem:
Debian-40-etch-64-minimal:~# /sbin/mkfs -t ext3 /dev/sdb1
mke2fs 1.40-WIP (14-Nov-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
48840704 inodes, 97677838 blocks
4883891 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
2981 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Add this line to /etc/fstab:
/dev/sdb1 /mount/sdb1 ext3 defaults 0 0
Then mount the partition:
mkdir /mount mkdir /mount/sdb1 mount /dev/sdb1
Checking the stats again we have:
Debian-40-etch-64-minimal:~# fdisk -l Disk /dev/sda: 400.0 GB, 400088457216 bytes 255 heads, 63 sectors/track, 48641 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 1 262 2104514+ 82 Linux swap / Solaris /dev/sda2 263 48641 388604317+ 83 Linux Disk /dev/sdb: 400.0 GB, 400088457216 bytes 255 heads, 63 sectors/track, 48641 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 48642 390711352+ 83 Linux Debian-40-etch-64-minimal:~# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 365G 612M 346G 1% / tmpfs 1.7G 0 1.7G 0% /lib/init/rw udev 10M 40K 10M 1% /dev tmpfs 1.7G 0 1.7G 0% /dev/shm /dev/sdb1 367G 195M 348G 1% /mount/sdb1 Much better, 674Gb free space.
Setting up Domain and Host Names
All my machines have hostnames named after famous Physicists so this one is doppler.3aims.com named after Christian Doppler. I set up its DNS entries through the DynDNS control panel as follows:
doppler.3aims.com. 1440 A 78.46.35.5
Then I SSH’d into the machine, set a new root password and changed /etc/hostname to doppler and replaced the line after localhost with this in /etc/hosts:
78.46.35.5 doppler doppler.3aims.com
You then run hostname doppler to save yourself a reboot. More info on etch hostnames here:
Debian-40-etch-64-minimal:~# vim /etc/hostname Debian-40-etch-64-minimal:~# vim /etc/hosts Debian-40-etch-64-minimal:~# hostname doppler
All good so far.
Basic Configuration
Rather than doing everything as root it is best to add a normal user account and grant sudo privileges:
Debian-40-etch-64-minimal:~# apt-get install sudo
Debian-40-etch-64-minimal:~# adduser james
Adding user `james' ...
Adding new group `james' (1000) ...
Adding new user `james' (1000) with group `james' ...
Creating home directory `/home/james' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for james
Enter the new value, or press ENTER for the default
Full Name []: James Gardner
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [y/N] y
You can then grant privileges with the visudo command and at the end of the file add james ALL=(ALL) ALL then become james with su james.
Now you can become james with su james. Notice that the Bash prompt will now pick up the hostname change:
Debian-40-etch-64-minimal:~# su james james@doppler:/root$
Locales
The first thing to set up are locales before you install any extra packages:
$ sudo dpkg-reconfigure locales
I chose en_GB.UTF-8 UTF-8 and also left en_US.ISO-8859-15 ISO-8859-15 selected too, choosing en_GB.UTF-8 UTF-8 as the default.
Timezones
The default setup has the German timezone. Lets change that to UTC:
james@doppler:/root$ sudo tzconfig
Your current time zone is set to Europe/Berlin
Do you want to change that? [n]: y
Please enter the number of the geographic area in which you live:
1) Africa 7) Australia
2) America <img src='http://jimmyg.org/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> Europe
3) US time zones 9) Indian Ocean
4) Canada time zones 10) Pacific Ocean
5) Asia 11) Use System V style time zones
6) Atlantic Ocean 12) None of the above
Then you will be shown a list of cities which represent the time zone
in which they are located. You should choose a city in your time zone.
Number: 8
Amsterdam Andorra Athens Belfast Belgrade Berlin Bratislava Brussels
Bucharest Budapest Chisinau Copenhagen Dublin Gibraltar Guernsey Helsinki
Isle_of_Man Istanbul Jersey Kaliningrad Kiev Lisbon Ljubljana London
Luxembourg Madrid Malta Mariehamn Minsk Monaco Moscow Nicosia Oslo Paris
Podgorica Prague Riga Rome Samara San_Marino Sarajevo Simferopol Skopje
Sofia Stockholm Tallinn Tirane Tiraspol Uzhgorod Vaduz Vatican Vienna
Vilnius Volgograd Warsaw Zagreb Zaporozhye Zurich
Please enter the name of one of these cities or zones
You just need to type enough letters to resolve ambiguities
Press Enter to view all of them again
Name: [] London
Your default time zone is set to 'Europe/London'.
Local time is now: Fri Nov 9 16:53:52 GMT 2007.
Universal Time is now: Fri Nov 9 16:53:52 UTC 2007.
SSH Config
Next we’ll change the default SSH configuration to make it more secure:
Make a backup of /etc/ssh/sshd_config and then check or change the following:
Port 30000 <-- change to a port other than 22 PermitRootLogin no AllowUsers james
These are self-explainatory. This will disable root logins, allow only the user james to login, only on port 30000. If you like you can also set:
PasswordAuthentication no
This will mean you will only be able to login via an SSH private/public key pair which you will have needed to set up in advance. I didn’t do this.
Note that if you get them wrong you might not be able to login to the machine so be careful. Once you happy with the settings restart:
doppler:~# /etc/init.d/ssh restart Restarting OpenBSD Secure Shell server: sshd.
Don’t exit that shell though before you’ve loaded up another terminal and checked you can connect again. This time you’ll need to use this:
ssh james@doppler.3aims.com -p 30000
If you do make a mistake and can’t reconnect, boot into the rescue system and mount the drive with this command:
mount /dev/sda2 /mnt -t ext3
You will then be able to edit the file as /mnt/etc/ssh/sshd_config and then reboot back into your normal setup.
Also, publishing the settings you’ve chosen on a blog like this defeats the purposes of setting them so choose something different if you are going to publish them!
Firewall
You set up the firewall walls using iptables. This can’t be done using sudo so you have to become the root user:
james@doppler:~$ sudo -i Password: doppler:~# whoami root
You can see the firwall rules like this:
doppler:~# iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination
If there were any rule you could save them like this:
iptables-save > /etc/iptables.current.rules
Here’s a simple firewall configuration from the Slicehost Blog which you can use to block all access apart from on SSH, HTTP and HTTPS. Save this as /etc/iptables.test.rules. Feel free to modify it for your own use and be aware that if you have didn’t change the SSH port to 30000 or you chose another port, you’ll need to update the firewall config before you apply it.
Now load the rules with:
iptables-restore < /etc/iptables.test.rules
Again, test that you can still sign in using SSH before you exit the shell.
If you list the rules again you will see this:
doppler:~# iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT 0 -- anywhere anywhere REJECT 0 -- anywhere loopback/8 reject-with icmp-port-unreachable ACCEPT 0 -- anywhere anywhere state RELATED,ESTABLISHED ACCEPT tcp -- anywhere anywhere tcp dpt:www ACCEPT tcp -- anywhere anywhere tcp dpt:https ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:30000 ACCEPT icmp -- anywhere anywhere icmp echo-request LOG 0 -- anywhere anywhere limit: avg 5/min burst 5 LOG level debug prefix `iptables denied: ' REJECT 0 -- anywhere anywhere reject-with icmp-port-unreachable Chain FORWARD (policy ACCEPT) target prot opt source destination REJECT 0 -- anywhere anywhere reject-with icmp-port-unreachable Chain OUTPUT (policy ACCEPT) target prot opt source destination ACCEPT 0 -- anywhere anywhere
Once you are happy with the rules, save them permanently:
iptables-save > /etc/iptables.up.rules
Now we need to ensure that the iptables rules are applied when we reboot the server. At the moment, the changes will be lost and it will go back to allowing everything from everywhere.
Edit /etc/network/interfaces and add a pre-up line (shown below) just after iface lo inet loopback:
... auto lo iface lo inet loopback pre-up iptables-restore < /etc/iptables.up.rules ...
This line will restore the iptables rules from the /etc/iptables.up.rules file.
Updating
Next I installed any updates from the repositories listed in /etc/apt/sources.list:
sudo apt-get update sudo apt-get upgrade
perl-base was the only package upgraded. After I’d made all these changes I rebooted to ensure they were all applied.
That’s as far as I can get until I recieve the new IP addresses. Might be some updates to the above if I run into any problems.
Note
Now you can create your virtual machines. See my previous article for how to do this. Start reading from the xen-create-image line.
HP LaserJet 1022 Printer Debian Etch
I bought the HP LaserJet 1022 for £139 from PC world today. Not exactly cheap I know but I wanted a decent reliable printer to replace my melted Samsung ML-1610 which always gave slightly grey prints. The HP 1022 does exactly what it says on the tin. It produces nice quality black and white prints very quickly.
The OpenPrinting page here suggests it works perfectly with Linux. It works perfectly now with Debian Etch but just following the Gnome CUPS wizard didn’t do it. In playing around I performed the following and but I’m not sure which step was the one that made it work.
- Used the standard Gnome add printer wizard (gnome-cups-add) which auto-detected the printer and suggested the foo2zjs driver.
- Installed sudo apt-get install foo2zjs. Not sure why it why it wasn’t already installed since I’d selected it in the wizzard.
- Plugged it into a USB 2.0 plug rather than 1.1
- Visited http://localhost:631/printers/ and clicked "Print Test Page"
It then printed the CUPS test page and still works fine even when connected to a USB 1.1 port. It still won’t print a test page from the Gnome CUPS manager though but prints from anywhere else so it is possible it was working straight away anyway before I started trying other things.
Anyway, bottom line is that it seems to work perfectly on Debian Etch so you can buy with confidence.
Orange GPRS via Samsung Bluetooth on Debian
I have a Samsung SHG-E250 mobile phone on Orange pay as you go in the UK. I’ve also got a Belkin USB bluetooth dongle model F8T013xx1 and I wanted to be able to access the internet from my Debian laptop over GPRS. This article is a working solution but there is a lot about the intricacies of what’s going on that I don’t understand so whilst I hope this is useful, I make no guarantees!
Paying a Provider
The first challenge is the cost. Standard tariffs is £4 per MB which is frankly outrageous. There is a handy trick you can use if you want to use GPRS on Orange. If you have Pay As You Go in the UK you get unlimited GPRS data until midnight that day for just £1. It is called an “Orange Extra” and you and rather than internet access it is called “Orange World”. From your phone dial 450 free. Then choose options 3111 followed by:
1 - Unlimited data until midnight for £1
2 - 4Mb total valid for 30 days for £4
3 - A week’s unlimited access for £5
The amount is taken off your Pay As You Go Balance immediately and you are asked to hold until the service has gone through and you are sent a txt after a few seconds confirming you can start using the service. You can check your remaining balance, including the Orange World access you just bought by dialing 453. You can use the unlimited data for £1 extra each day if you like.
Setting up Bluetooth on the Desktop
Once the financial side is sorted out you need to set up your connection. If you have installed the standard Gnome desktop then the “bluez” Bluetooth stack will already be set up. Just plug the dongle in and you can start pairing the devices. Right click the Bluetooth icon on the gnome panel which appears when you plug in the Bluetooth dongle. Choose preferences, give your computer a sensible name and choose “Visible and connectable for other devices”. My computer is called dirac-0 which you’ll see in some of the output later on.
On your phone turn on Bluetooth and select scan for devices to pair with the computer. You’ll be asked to enter a 4 digit pin. Choose something memorable. A message box will pop up on the desktop. Click it, enter the PIN and the devices will be bonded. That’s the easy bit, now time to test the connection.
Playing with Bluetooth
Scan for devices:
james@dirac:~$ sudo hcitool scan
Scanning …
00:1A:8A:86:6D:CE SGH-E250
Find out about a device:
james@dirac:~$ sudo hciconfig -a
hci0: Type: USB
BD Address: 00:0A:3A:7A:E6:53 ACL MTU: 1017:8 SCO MTU: 64:0
UP RUNNING PSCAN
RX bytes:10237 acl:210 sco:0 events:217 errors:0
TX bytes:4609 acl:210 sco:0 commands:71 errors:0
Features: 0xff 0xff 0×8d 0xfe 0×9b 0xf9 0×00 0×80
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH HOLD SNIFF PARK
Link mode: SLAVE ACCEPT
Name: ‘dirac-0′
Class: 0×3e0100
Service Classes: Networking, Rendering, Capturing, Object Transfer, Audio
Device Class: Computer, Uncategorized
HCI Ver: 2.0 (0×3) HCI Rev: 0×4102 LMP Ver: 2.0 (0×3) LMP Subver: 0×430e
Manufacturer: Broadcom Corporation (15)
Ping a device:
james@dirac:~$ sudo l2ping 00:1A:8A:86:6D:CE
Ping: 00:1A:8A:86:6D:CE from 00:0A:3A:7A:E6:53 (data size 44) …
44 bytes from 00:1A:8A:86:6D:CE id 0 time 37.50ms
44 bytes from 00:1A:8A:86:6D:CE id 1 time 75.61ms
44 bytes from 00:1A:8A:86:6D:CE id 2 time 66.62ms
3 sent, 3 received, 0% loss
Connecting for Dial Up Networking
Once all that is working nicely it is time to search for a device with Dial Up Networking:
james@dirac:~$ sdptool search DUN
Inquiring …
Searching for DUN on 00:1A:8A:86:6D:CE …
Service Name: Dial-up Networking
Service RecHandle: 0×10002
Service Class ID List:
”Dialup Networking” (0×1103)
Protocol Descriptor List:
”L2CAP” (0×0100)
”RFCOMM” (0×0003)
Channel: 3
Profile Descriptor List:
”Dialup Networking” (0×1103)
Version: 0×0100
As you can see the device 00:1A:8A:86:6D:CE (which you know is an SGH-E250 phone from the sudo hcitool scan command you ran above) supports RFCOMM and on channel 3. It is important to make a note of the channel because you’ll need it for the next command:
james@dirac:~$ sudo rfcomm bind 0 00:1A:8A:86:6D:CE 3
james@dirac:~$ sudo rfcomm show 0
rfcomm0: 00:1A:8A:86:6D:CE channel 3 clean
This tells you that you now have your Bluetooth phone connected on /dev/rfcomm0. If you leave it too long after binding before trying the show command you might see this:
james@dirac:~$ sudo rfcomm show 0
rfcomm0: 03:00:00:00:00:00 channel 1 closed
In which case release and then bind again:
james@dirac:~$ sudo rfcomm release 0
james@dirac:~$ sudo rfcomm bind 0 00:1A:8A:86:6D:CE 3
james@dirac:~$ sudo rfcomm show 0
rfcomm0: 00:1A:8A:86:6D:CE channel 3 clean
Now you have a Bluetooth connection you are ready to set up your GPRS connection.
Testing Your Connection Settings
If you already know all the settings you need to use you can skip this bit and go straight to setting up the GPRS connection via PPP. Installing and playing with minicom isn’t strictly necessary, it will just help you track down problems more quickly.
First you’ll need a tool such as minicom.
james@dirac:~$ sudo apt-get install minicom
You need to add your user to the dialout group to use minicom as a non-root user.
Then create a configuration file:
sudo minicom -s
You get shown an options screen. In the “Serial port setup“ screen choose “A“ to make the
A - Serial Device : /dev/rfcomm0
Then choose “E“ to change the “Bps/Par/Bits“ to “57600 8N1“. You do this by pressing “H“ and “Q“. You can try 115200 later if 57600 works. Press “
To use your new configuration type:
minicom bluetooth.dfl
If you have any problems it is worth running “sudo rfcomm show 0“ again to check you still have a clean connection. If not, release the connection and bind to the channel again first.
When you run this command for the first time the phone will ask you something like: “DUN connect with dirac-0″. Choose yes.
Once you are connected you’ll see a screen like the one below. Type the following to initialise GPRS:
at
ate1
at+cgdcont=1,”IP”,”orangeinternet”,”",0,0
atdt*99#
After each line you should see an OK message except after the last line when you should see a CONNECT as shown below.
If you were able to connect successfully, great. If not you might need to search on the internet for the correct settings for your provider and phone. In particular the atdt*99# line might need changing.
Setting up PPP
If you want your phone to bind automatically you can edit your /etc/bluetooth/rfcomm.conf so it looks like this:
#
# RFCOMM configuration file.
#
rfcomm0 {
bind yes;
device 00:1A:8A:86:6D:CE;
channel 3;
comment “Bluetooth PPP Connection”;
}
Obviously you’ll need to enter the correct channel and device for your phone based on the output you received earlier from running sdptool search DUN. You’ll then need to restart Bluetooth with:
/etc/init.d/bluetooth restart
I chose not to add the lines to rfcomm.conf because I want to always manually connect my phone to avoid the chance of running up any unwanted bills (of course just binding to the device doesn’t mean I am connected to the internet but I’m just being paranoid).
If you want to bind manually you should do so now:
james@dirac:~$ sudo rfcomm bind 0 00:1A:8A:86:6D:CE 3
james@dirac:~$ sudo rfcomm show 0
rfcomm0: 00:1A:8A:86:6D:CE channel 3 clean
Next create the file /etc/ppp/peers/bluetooth and add the following content. I had to play around with this for a long time so if it doesn’t work for you, take a look at other examples for your phone/provider and mix and match commands from different configurations until it does. This example is based on the one from here.
# File:
# gprs
#
# Description:
# Serial cable, IrDA, Bluetooth and USB pppd options for GPRS phones.
# Keep pppd attached to the terminal:
# Comment this to get daemon mode pppd
nodetach
# Debug info from pppd:
# Comment this off, if you don’t need more info
debug
# Show password in debug messages
show-password
# Connect script:
connect ‘/usr/sbin/chat -v -f /etc/chatscripts/bluetooth’
# Disconnect script:
# AT commands used to ‘hangup’ the GPRS connection.
disconnect /etc/ppp/peers/gprs-disconnect-chat
# Serial device to which the GPRS phone is connected:
# /dev/ttyS0 for serial port (COM1 in Windows),
# /dev/ircomm0 for IrDA,
# /dev/ttyUB0 for Bluetooth (Bluez with rfcomm running) and
# /dev/ttyUSB0 for USB
#/dev/ttyS0 # serial port one
#/dev/ttyS1 # serial port two
#/dev/ircomm0 # IrDA serial port one
/dev/rfcomm0 # Bluetooth serial port one
#/dev/ttyUSB0 # USB serial device, for example Orange SPV
# Serial port line speed
115200 # fast enough
#57600 # perhaps usefull with IrDA
# Hardware flow control:
# Use hardware flow control with cable, Bluetooth and USB but not with IrDA.
crtscts # serial cable, Bluetooth and USB
#nocrtscts # IrDA
# Ignore carrier detect signal from the modem:
local
# IP addresses:
# - accept peers idea of our local address and set address peer as 10.0.0.1
# (any address would do, since IPCP gives 0.0.0.0 to it)
# - if you use the 10. network at home or something and pppd rejects it,
# change the address to something else
:10.0.0.1
# pppd must not propose any IP address to the peer!
noipdefault
# Accept peers idea of our local address
ipcp-accept-local
# Add the ppp interface as default route to the IP routing table
defaultroute
# DNS servers from the phone:
# some phones support this, some don’t.
usepeerdns
# ppp compression:
# ppp compression may be used between the phone and the pppd, but the
# serial connection is usually not the bottleneck in GPRS, so the
# compression is useless (and with some phones need to disabled before
# the LCP negotiations succeed).
#novj
#nobsdcomp
#novjccomp
#nopcomp
#noaccomp
# The phone is not required to authenticate:
noauth
# Username and password:
# If username and password are required by the APN, put here the username
# and put the username-password combination to the secrets file:
# /etc/ppp/pap-secrets for PAP and /etc/ppp/chap-secrets for CHAP
# authentication. See pppd man pages for details.
# Example, Radiolinja operator pap-secrets:
# “rlnet” * “internet” *
#user “rlnet”
#user “Orange”
# Asyncmap:
# some phones may require this option.
#asyncmap 0xa0000
# No magic:
# some phones may require this option.
nomagic
# Require PAP authentication:
# some phones may require this option.
#require-pap
Now you’ll need to create the /etc/chatscripts/bluetooth referenced in the file above:
TIMEOUT 35
ECHO ON
ABORT ‘\nBUSY\r’
ABORT ‘\nERROR\r’
ABORT ‘\nNO ANSWER\r’
ABORT ‘\nNO CARRIER\r’
ABORT ‘\nNO DIALTONE\r’
ABORT ‘\nRINGING\r\n\r\nRINGING\r’
” \rAT
OK ‘AT+CGDCONT=1,”IP”,”orangeinternet”,”",0,0′
OK ‘ATD*99#’
CONNECT “”
and also the /etc/ppp/peers/gprs-disconnect-chat script:
#!/bin/sh
#
# File:
# gprs-disconnect-chat
#
# send break
exec /usr/sbin/chat -V -s -S \
ABORT “BUSY” \
ABORT “ERROR” \
ABORT “NO DIALTONE” \
SAY “\nSending break to the modem\n” \
“” “\K” \
“” “+++ATH” \
SAY “\nPDP context detached\n”
You’ll need to make this one executable otherwise it won’t be able to be executed when you disconnect (not that it seems to be a huge problem).
Finally, update /etc/resolve.conf to use the Orange nameservers:
nameserver 193.35.133.10
nameserver 193.35.134.10
That’s pretty much it. Now bring down any other interfaces you have connected such as wirless or LAN connections so that when you connect over GPRS your routing tables will be set up correctly:
sudo ifdown eth0
Now check you are bound, cross your fingers and connect:
james@dirac:~$ sudo rfcomm bind 0 00:1A:8A:86:6D:CE 3
james@dirac:~$ sudo rfcomm show 0
rfcomm0: 00:1A:8A:86:6D:CE channel 3 clean
james@dirac:~$ sudo pon bluetooth
The final line is what does the connecting. A message should pop up on your phone asking for permission to start DUN. Choose yes and a load of messages should fly by and you should find yourself connected!
james@dirac:~$ sudo pon bluetooth
AT
OK
AT+CGDCONT=1,”IP”,”orangeinternet”,”",0,0
OK
ATD*99#
CONNECT
Serial connection established.
using channel 3
Using interface ppp0
Connect: ppp0 <--> /dev/rfcomm0
sent [LCP ConfReq id=0×1
rcvd [LCP ConfReq id=0×1
sent [LCP ConfAck id=0×1
rcvd [LCP ConfRej id=0×1
sent [LCP ConfReq id=0×2
rcvd [LCP ConfAck id=0×2
sent [LCP EchoReq id=0×0 magic=0×0]
sent [PAP AuthReq id=0×1 user=”dirac” password=”"]
rcvd [LCP EchoRep id=0×0 magic=0×0]
rcvd [PAP AuthAck id=0×1 “Login OK”]
Remote message: Login OK
PAP authentication succeeded
sent [CCP ConfReq id=0×1
sent [IPCP ConfReq id=0×1
rcvd [LCP ProtRej id=0×2 80 fd 01 01 00 0f 1a 04 78 00 18 04 78 00 15 03 2f]
Protocol-Reject for ‘Compression Control Protocol’ (0×80fd) received
rcvd [IPCP ConfRej id=0×1
sent [IPCP ConfReq id=0×2
sent [IPCP ConfReq id=0×2
rcvd [IPCP ConfReq id=0×1
sent [IPCP ConfNak id=0×1
rcvd [IPCP ConfNak id=0×2
sent [IPCP ConfReq id=0×3
rcvd [IPCP ConfReq id=0×2
sent [IPCP ConfNak id=0×2
rcvd [IPCP ConfAck id=0×3
rcvd [IPCP ConfReq id=0×3
sent [IPCP ConfNak id=0×3
rcvd [IPCP ConfReq id=0×4
sent [IPCP ConfNak id=0×4
rcvd [IPCP ConfReq id=0×5
sent [IPCP ConfNak id=0×5
rcvd [IPCP ConfReq id=0×6
sent [IPCP ConfRej id=0×6
rcvd [IPCP ConfReq id=0×7
sent [IPCP ConfRej id=0×7
rcvd [IPCP ConfReq id=0×8]
sent [IPCP ConfAck id=0×8]
Cannot determine ethernet address for proxy ARP
local IP address 10.34.152.3
remote IP address 10.0.0.1
primary DNS address 193.35.133.10
secondary DNS address 193.35.134.10
Script /etc/ppp/ip-up started (pid 7253)
Script /etc/ppp/ip-up finished (pid 7253), status = 0×0
Disconnect by pressing Ctrl+C or as a last resort, turning off Bluetooth on your phone.
Terminating on signal 2
Connect time 2.2 minutes.
Sent 29700 bytes, received 2104 bytes.
Script /etc/ppp/ip-down started (pid 7324)
sent [LCP TermReq id=0×3 “User request”]
Script /etc/ppp/ip-down finished (pid 7324), status = 0×0
rcvd [LCP TermAck id=0×3]
Connection terminated.
Garbled time
Sending break to the modem
PDP context detached
Serial link disconnected.
james@dirac:~$
You can then connect again if you want to with:
james@dirac:~$ sudo pon bluetooth.
If things don’t work out first time my advice is to either try to work out properly what all the options mean in the PPP configuration or just use a bit of trial and error from other examples which have been written for your mobile provider, phone model or operating system. By the way, I’m using GPRS to write and save this blog entry now so it does work!
Update If you don’t set the nameservers in /etc/resolve.conf they get set for you automatically and if you comment out the :10.0.0.1 line in the /etc/ppp/peers/bluetooth line it still all works.
Seagate FreeAgent Go 120GB External Hard Drive
After playing with VMWare yesterday and successfully booting Windows XP under Debian (after re-activating it because it complained of hardware changes) I quickly realised that I was going to rapidly run out of disk space if I continued creating new disk images. Since I want my files to be available on lots of different machines it was time to bite the bullet and buy an external hard drive. I looked on dabs.com and decided on the Western Digital 160GB Passport for £69.99. Before I ordered it I thought I’d head down to PC World (something I only ever do if I can’t wait for delivery) and had a look at their range in case there was something comparable. After deciding none of the products they had were good value I gave up and came home only to read on CNET that the FreeAgent Go (one of the drives I had looked at) was actually a very fast hard drive beaten only by the Maxtor OneTouch III Mini Edition in their tests. What is more, the 120GB version is a 7200rpm drive as opposed to the 5400rpm they tested so there was a chance the version in PC World might be even faster. In the end I drove back to PC World and bought it for £69.99.
The box is very nicely styled and when you open it you are greeted with a very simple instruction manual which says “This won’t take long”. It’s right. All you do is take the drive and the cable out of their packaging and plug them in. That’s it. You are then good to go. The USB cable it comes with has two plugs, one is for power and the other is for power and data. The cable is split so that you can easily plug the drive into USB sockets which are at opposite sides of your computer. If you don’t have two USB slots free, not to worry. The drive works perfectly well without having the one with “Power” written on it plugged in because power is still supplied by the other one marked “Power+Data”. If you read the instruction leaflet (which I didn’t) you’ll also notice that the drive has a whopping 5 years warranty. Seagate must be confident of the quality of the product.
One thing that really strikes you is just how small this drive is. Physically it is only fractionally larger than my wallet and my mouse is actually longer than the drive. When it is plugged in the base of the drive glows yellow and when you are transferring data the yellow light fades and comes back slowly in a very pleasing manner.
One other point worth mentioning is that the drive comes with some software. I don’t know what this does, and frankly I’m not interested so I just created a new directory on the drive and moved everything that was on there already to that directory in case I wanted it later. As a result of moving the hidden Autorun.inf the software doesn’t auto play when you plug the drive in and it no longer has the custom drive icon. Perfect.
At this point I decided to test the drive. Since CNET suggested a 10GB transfer should be possible in 10 minutes I tried transferring 270 MP3 and video files totaling 1.21GB. I was horrified to see it took 21 minutes and 5 seconds. Something was wrong
A quick look in device manager reveals that I have an Intel(R) 82801DB/DBM USB 2.0 Enhanced Host Controller -24CD on my IBM Thinkpad R50e. This page explains:
The 82801DB I/O Controller Hub (ICH4) contains three USB 1.1 (UHCI) controllers and one USB 2.0 (EHCI) controller, supporting up to six ports. Whether a port is controlled by one of the UHCI controllers or by the EHCI controller, and therefore whether or not it supports Hi-Speed, is up to some internal routing logic. I think the six physical ports (external to the ICH chip) can each be run either by the appropriate Universal Host Controller or the Enhanced Host Controller independently of all the others.
The EHCI driver is responsible for setting up the routing to the EHC or the UHC as appropriate. Either it’s not detecting the speed correctly initially, erroneously routing the hi-speed device to the UHC, or there’s a fault in the hardware or driver.
Sure enough, when I plugged the Power+Data cable into the other USB port the drive burst into life. Bottom line: if you do buy this drive for its speed you absolutely must make sure you have a Hi-Speed USB port to make proper use of it. Here are the real test results using the Hi-Speed USB port rather than the USB 1.1 port:
1.21GB music written to the drive in 71 seconds (about 17MB/second)
1.21GB music read from the drive in 78 seconds (about 15.5 MB/second)
The interesting thing here is that reading was slower than writing which strongly suggests that this drive is actually faster than my laptop’s internal hard disk which frankly is plenty fast enough for me! I also tried it with just the one USB cable rather than the two and I attached my USB hub, mouse, printer and keyboard to the other USB port to see if it made a difference. The results:
1.21GB music written to the drive in 73 seconds (about 16.5MB/second)
Basically it doesn’t make any difference. The two seconds could easily have been due to me not starting and stopping the clock accurately.
One final point worth mentioning is that the drive isn’t really 120GB in size. Most hard disk manufacturers like to say 1GB=1000Mb whereas in computing terms 1GB=1024MB. Consequently Windows describes the drive as 111GB capacity. This is still plenty big enough for my purposes though. The drive also comes pre-formatted as NTFS. If you are using Mac OS X or Linux you will need to reformat it to be something more appropriate or else install the FUSE NTFS driver to be able to use the drive. I’ll try that next.
Update (23/06/07): After investigating ntfs-3g I still think it is too new. Although the software itself is considered stable it requires more recent versions of software than are found in in Debian Etch stable. Although I could install it from testing I’ve learned the hard way that installing software from testing or unstable always causes problems in the long run.
The only filesystem which is natively supported under both Windows, Mac OS X and most Linux distributions is FAT32. It can handle partitions above 32GB as long as you don’t use Windows tools to format it (it would appear Microsoft would prefer you to use NTFS) but it works fine from Linux. The limitations main limitation is that FAT32 does not support files larger than 4GB but if you can live with that then it should be a fine choice.
To reformat your drive you’ll need to install dosfstools and if you prefer GUI interfaces to do this sort of things you can use gparted:
sudo apt-get install dosfstools gparted
To format the drive simply start gparted, select the correct drive and reformat it FAT32. To check it works disconnect and reconnect the device.
Once I’d formatted the drive I rebooted into Windows and re-ran the tests. The same transfer took 78 seconds. Slightly longer than with NTFS but not too bad. I did notice that transferring lots of small files is a bit slower and also that Windows’ time estimates are far too high when it starts copying which give you the impression to start with that FAT32 is a lot worse than NTFS.
Anyway, I’m very happy now. I have a drive which will work on virtually any modern computer with no drivers or filesystem tweaks and I can easily keep it with my laptop or even in my pocket and know I’ll always have access to my important files.
Update2 (25/06/2007): I’ve noticed the FreeAgent Go drive displays files sizes in property dialogs much faster than my laptop hard drive but that for small file sizes, such as my subversion code checkouts, the FAT32 filesystem is vastly less efficient than NTFS. 236MB small files take up 446MB space on NTFS and 1.1GB on FAT32.
Update3 (20/07/2007): On Debain Etch this drive frequently becomes read-only for no apparant reason. This is easily resolved as follows:
1. Get the sdparm package
sudo apt-get install sdparm
Find out your drive device (in my case /dev/sdb1)
sudo fdisk -l
Clear standby mode:
sdparm --clear STANDBY -6 /dev/sdb1
I must admit I don’t fully understand what this does but it looks like it is clearing a flag on the drive itself which causes it to go read only. Anyway, it does the trick for me!