Technomancy

Entries tagged “ubuntu”

How to diff RTF files

written by rory, on Nov 27, 2009 10:24:29 AM.

I recently got 2 RTF files and needed to diff them. As a command line jockey, I know how to diff normal text files. However I didn't know how to diff RTF files.

I discovered unrtf a programme for converting RTF files into plain text, (it has some bugs, like all software).

To do a word diff install dwdiff, and use the following command

dwdiff <(unrtf --text file1.rtf) <(unrtf --text file2.rtf)

What would *you* put on a harddrive going to Kenya?

written by rory, on Nov 27, 2009 9:38:00 AM.

When I was in Kenya in July 2008 with Camara teaching people how to use Ubuntu Linux, I brought a hard drive mirror of apt with me. Over in Africa bandwidth is slow and expensive, I was able to use this apt mirror to install new software easily over in Kenya. I gave a talk at OSSBarCamp about Using Free Culture in an Internet Free World.

I'm doing it again. A friend of mine in Kenya asked for a new harddrive. So what would you put on a harddrive going to Kenya?

I asked on the Ubuntu NGO mailing list, and got some great responses, from Ubuntu Screencasts, printer drivers, and wikipedia dumps. What else in the free culture world is there?

This post also appeared on the Ubuntu NGO Blog

Using Android SDK on Ubuntu 9.10 Karmic Koala

written by rory, on Nov 4, 2009 11:30:46 AM.

I have an Android Dev G1 phone. It's still running firmware 1.0, which is positively ancient. I want to upgrade it. I plugged in my android phone and ran "adb devices" to check that it was detected. It didn't come up. It used to work. I described how to do it a previous blog post. Some googling showed that things have changed recently. Despite what this page from Google says, you can't get it to work that way. Thanks to this blog post for point me in the right direction.

You need to create a new udev file

$ sudo gedit /etc/udev/rules.d/51-android.rules

Then put the following lines into it:

SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", SYMLINK+="android_adb" MODE="0666"

Then restart udev:

$ sudo /etc/init.d/udev restart
$ sudo service udev restart

Then plug your device in and you should see it with "adb devices"

Installing (Ed)ubuntu from the network

written by rory, on Jul 28, 2009 10:13:00 PM.

(This is a repost from some archives, hence the references to an old version of Ubuntu. I've written scripts to automate a lot of this, in future there'll be a new post about how to do this anew)

I initially described how to automate an edubuntu install disc so you didn’t have to select the same options again and again.

Next I want to be able to install a PC with edubuntu by just plugging it into the network and booting off the network.

Basic Overview

When a computer does a network boot, a DHCP server gives it it’s network configuration, aswell as the path of the PXE (pre execution environment) that it is to boot. Luckily ubuntu comes with a PXE imagine prepared. It also needs to download the packages from an apt mirror. We can use the packages straight from the install CD for this. We can use one machine for all this. It’s only a matter of sticthing it all together.

Set up dhcpd

On Ubuntu install the dhcp3-server package You also need to tell the DHCP server (which will tell the clients) the path to the operating system to boot.

For example, here is section of my DHCPd configuration for the clients

      subnet 192.168.2.0 netmask 255.255.255.0 {
          filename = "pxelinux.0";
          range 192.168.2.10 192.168.2.254;
          option subnet-mask 255.255.255.0;
          option broadcast-address 192.168.2.255;
          option routers 192.168.2.1;
          next-server 192.168.2.1;
      }

All the install clients will get an IP address in the range 192.168.2.10 → 192.168.2.254. The ‘filename’ option tell the clients to download the file named ‘pxelinux.0′ over TFTP from this server and boot that OS. You’ll need the network interface to have the IP 192.168.2.1 for this.

Set up TFTP

TFTP (Trivial File Transfer Protocol) is used to send the base operating system image to the clients. In Ubuntu install the tftp-hpa package. By default the files in /var/lib/tftpboot will be server to the clients. So the clients will try to boot the image in /var/lib/tftpboot/pxelinux.0. Thanks to Conor Daly for assembling most of this. My /var/lib/tftptboot can be uncompressed into /var/lib/tftpboot to start you off.

Configure the PXE

When a machine boots the PXE, it uses /var/lib/tftpboot/pxelinux.cfg/default to give a little menu to the clients. This is the option for the installer:

      label camarabuntu
          kernel camarabuntu/linux
          append initrd=camarabuntu/ubuntu-installer/i386/initrd.gz locale=en_IE console-setup/layoutcode=uk netcfg/get_hostname=camarabuntu netcfg/disable_dhcp=true netcfg/choose_interface=auto netcfg/get_ipaddress=192.168.2.10 netcfg/get_netmask=255.255.255.0 netcfg/get_gateway=192.168.2.1 netcfg/get_nameservers=192.168.2.1 netcfg/confirm_static=true preseed/url=http://192.168.2.1/camarabuntu.seed --

You’ll note there is lots of options for the installer in there. In earlier kernels there was a limit of about 8 options on the command line. In that case we would have had to make a custom initrd. Luckily in later kernels we can have up to 32 options, so we don’t need an initrd. We had to do something similar for the CD install. I’m not sure but I think the fact that the network is hardcoded in will break when there are more than one client. The important part is the preseed/url=http://192.168.2.1/camarabuntu.seed option which tells the installer to download that file and use that as the preseed file for the installer.

Preseed file

This is my camarabuntu preseed file. It’s very similar to the one for the CD. However we don’t need to do any network stuff, since that was set as a kernel boot option. Secondly we can’t do any network options here because if the installer is reading this file, it will have downloaded it and hence already have it’s network set up. Place this file in /var/www/camarabuntu.seed so it can be downloaded by the install clients.

      # Set the installer language to Hiberno-English and UK keybaord layout
      # Note: This are set before the cd is loaded, so they must be specified in the
      # kernel options as so:
      # locale=en_IE console-setup/layoutcode=uk
      # These lines are incl
      #d-i debian-installer/locale string ie_IE
      #d-i console-setup/layoutcode string uk
      # Install source
      d-i     mirror/country    string enter information manually
      d-i     mirror/http/hostname    string 192.168.2.1
      d-i     mirror/http/directory   string /edubuntu
      d-i     mirror/suite            string dapper
      d-i     mirror/http/proxy       string
      ## Network
      #d-i netcfg/choose_interface select auto
      #d-i netcfg/disable_dhcp boolean true
      #d-i netcfg/get_nameservers string 127.0.0.1
      #d-i netcfg/get_ipaddress string 127.0.0.1
      #d-i netcfg/get_netmask string 255.255.255.0
      #d-i netcfg/get_gateway string 127.0.0.1
      #d-i netcfg/confirm_static boolean true
      # Adjust the default hostname.
      d-i netcfg/get_hostname  string camarabuntu
      # Apt mirror
      d-i mirror/http/proxy    string  
      ## Partitioning
      # Put everything in one partition
      d-i partman-auto/disk string /dev/hda
      d-i partman-auto/choose_recipe \
             select All files in one partition (recommended for new users)
      d-i partman/confirm_write_new_label boolean true
      d-i partman/choose_partition \
             select Finish partitioning and write changes to disk
      d-i partman/confirm boolean true
      # Sync clock to UTC
      d-i clock-setup/utc boolean true
      # Set the timezone
      d-i time/zone string Europe/Dublin
      ## user set up
      # No root
      d-i passwd/root-login boolean false
      # But make a normal user
      d-i passwd/make-user boolean true
      # Set username & password
      d-i passwd/user-fullname string Camara
      d-i passwd/username string camara
      d-i passwd/user-password password camara
      d-i passwd/user-password-again password camara
      # install grub in MBR, a handy default
      d-i grub-installer/with_other_os boolean true
      # Install the Edubuntu desktop and server.
      tasksel tasksel/first    multiselect edubuntu-desktop, edubuntu-server
      # don’t show us the ‘Installing successful’ dialog
      d-i finish-install/reboot_in_progress note
      # XServer set up.
      xserver-xorg xserver-xorg/autodetect_monitor boolean true
      xserver-xorg xserver-xorg/config/display/modes multiselect 1280×1024, 800×600, 640×480
      xserver-xorg xserver-xorg/config/monitor/selection-method select medium
      xserver-xorg xserver-xorg/config/monitor/mode-list select 1024×768 @ 60 Hz

Set up the ‘mirror’

In a CD install, the software packages are on the CD. When doing a network install you’re obviously going to be grabbing the software from the network cause there is no CD. Luckily you can use the same software packages from the install CD. In Ubuntu install the apache2 package, and start the apache webserver with the command

sudo /etc/init.d/apache2 start

Apache serves files from /var/www. I created a symlink /var/www/edubuntu to the cd-image folder (eg:

sudo ln -s /home/rory/camara/camarabuntu/cd-image /var/www/edubuntu

Make sure the permissions are OK. All the files and folders are going to have to be world readable.

chmod -R a+rX /home/rory/camara/camarabuntu

Done

That’s it. ☺

References

Files

  • Contents of /var/lib/tftpboot

Automating an (Ed)Ubuntu install CD

written by rory, on Jul 28, 2009 9:42:00 PM.

(This is a repost from some archives, hence the references to an old version of Ubuntu. I've written scripts to automate a lot of this, in future there'll be a new post about how to do this anew)

I’m involved with Camara a charity that sends computers to Africa. We use Edubuntu on all the machines. Installing Edubuntu is tedious if you have to select the same options all the time. I’ve just finished automating the installation CD. This procedure should be similar for other Ubuntu/Debian based Linux OSs.

Prepare the CD image

Firstly, download the Edubuntu CD from http://ftp.esat.net/mirrors/releases.ubuntu.com/releases/edubuntu/edgy/edubuntu-6.10-install-i386.iso. You then have to ‘unpack’ the CD contents in order to change it.

sudo mount -o loop edubuntu-6.10-install-i386.iso ./cd
cp -rT ./cd ./cd-image
sudo umount ./cd
find ./cd-image -exec chmod +w '{}' ';'

This will mount the CD image onto the directory cd, then copy the contents to the directory cd-image.

After you’ve finished modifying the cd image, this script will create the CD again, ready for burning or emulation:

#! /bin/bash
IMAGE=camarabuntu.iso
BUILD=cd-image
mkisofs -r -V "Camarabuntu" \
              -cache-inodes \
-J -l -b isolinux/isolinux.bin \
-c isolinux/boot.cat -no-emul-boot \
-boot-load-size 4 -boot-info-table \
-o $IMAGE $BUILD

It creates a ISO in the current directory called ‘camarabuntu.iso’

Testing the CD with an emulator

Rather than burning it to a CD, I used qemu to emulate the PC. Create a 5GB file to serve as the harddisk with this command:

dd if=/dev/zero of=./hda.img bs=10M count=500

You can emulate the installation with this command:

qemu -cdrom camarabuntu.iso -hda ./hda.img -boot d

If you compile qemu from source you can avail of kqemu, the qemu accelerator, which makes x86 emulation very fast on x86 processors. You may have to run the qemu as root. Don’t forget to load the kqemu module with

modprobe kqemu

after compilation to load it.

Customizing the splash screen

The first thing I wanted to do was change the splash screen on the install CD. The Edubuntu on is
Edubuntu Install Splash
Modify the image in cd-image/isolinux/splash.pcx. To change the menu options, modify the file cd-image/isolinux/isolinux.cfg. My version is:

              DEFAULT /install/vmlinuz
GFXBOOT bootlogo
LABEL camarabuntu
       menu label ^Install Edubuntu
       kernel /install/vmlinuz
       append file=/cdrom/preseed/camarabuntu.seed initrd=/install/initrd.gz ramdisk_size=16384 root=/dev/ram rw quiet -- locale=en_IE console-setup/layoutcode=uk
LABEL check
       menu label ^Check CD for defects
       kernel /install/vmlinuz
       append MENU=/bin/cdrom-checker-menu initrd=/install/initrd.gz ramdisk_size=16384 root=/dev/ram rw quiet --
LABEL hd
       menu label ^Boot from first hard disk
       localboot 0x80
       append -
DISPLAY isolinux.txt
TIMEOUT 0
PROMPT 1
F1 f1.txt
F2 f2.txt
F3 f3.txt
F4 f4.txt
F5 f5.txt
F6 f6.txt
F7 f7.txt
F8 f8.txt
F9 f9.txt
F0 f10.txt

Which results in this splash screen:
Camarabuntu Install Splash

Automating the installer

Note the references to locale and keyboard layout in the kernel boot options, these values can’t be controlled in the preseed file because these are set before the preseed file is read. Put this in it’s own file in cd-image/preseed/camarabuntu.seed.

The preseed file I used is this:

# Set the installer language to Hiberno-English and UK keybaord layout
# Note: This are set before the cd is loaded, so they must be specified in the
# kernel options as so:
# locale=en_IE console-setup/layoutcode=uk
# These lines are incl
#d-i debian-installer/locale string ie_IE
#d-i console-setup/layoutcode string uk
## Network
d-i netcfg/choose_interface select auto
d-i netcfg/disable_dhcp boolean true
d-i netcfg/get_nameservers string 127.0.0.1
d-i netcfg/get_ipaddress string 127.0.0.1
d-i netcfg/get_netmask string 255.255.255.0
d-i netcfg/get_gateway string 127.0.0.1
d-i netcfg/confirm_static boolean trueable all networking, by not specifing anything here.
d-i mirror/http/proxy string

 
# Adjust the default hostname.
d-i netcfg/get_hostname  string camarabuntu
 
## Partitioning
# Put everything in one partition
d-i partman-auto/disk string /dev/hda
 
d-i partman-auto/choose_recipe \
       select All files in one partition (recommended for new users)
 
d-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition \
       select Finish partitioning and write changes to disk
d-i partman/confirm boolean true
 
# Sync clock to UTC
d-i clock-setup/utc boolean true
 
# Set the timezone
d-i time/zone string Europe/Dublin
 
## user set up
# No root
d-i passwd/root-login boolean false
# But make a normal user
d-i passwd/make-user boolean true
 
# Set username &amp; password
d-i passwd/user-fullname string Camara
d-i passwd/username string camara
d-i passwd/user-password password camara
d-i passwd/user-password-again password camara
 
# install grub in MBR, a handy default
d-i grub-installer/with_other_os boolean true
 
# Install the Edubuntu desktop and server.
tasksel tasksel/first    multiselect edubuntu-desktop, edubuntu-server
 
# don&#8217;t show us the &#8216;Installing successful&#8217; dialog
d-i finish-install/reboot_in_progress note
 
# XServer set up.
xserver-xorg xserver-xorg/autodetect_monitor boolean true
xserver-xorg xserver-xorg/config/display/modes multiselect 1280&#215;1024, 800&#215;600, 640&#215;480
xserver-xorg xserver-xorg/config/monitor/selection-method select medium
xserver-xorg xserver-xorg/config/monitor/mode-list select 1024&#215;768 @ 60 Hz

Which completly automates the installation of Edubuntu. All this should be familiar if you have installed Edubuntu before.

References