February 2010 Archives
Upgrading to Lucid
I'm going to upgrade my server to the new Ubuntu and make it 64 bit in the process. This means a complete re-install.
This means I'm going to be offline for some time.
Ubuntu Lucid Alpha-3
I want to upgrade my server to the new Ubuntu and switch to 64 bit on my main server. This is how I managed to get Ubuntu Lucid (Alpha 3) running on my (test) machine, with RAID1 + BTRFS and 64 bit. It is a running story on how I spend my Saturday afternoon, you might need some decent Linux knowledge to follow my lead.
Here we go.
The following lists sums up my needs and troubles:
- BTRFS for my main partitions (only
/and/bootwill beext4); - install Ubuntu Lucid (Alpha3);
- Lucid's installer does not support BTRFS;
- there is no CDROM drive in sight.
The attack plan:
- use unetbootin to create bootable (usb) hardisk image;
- format the external disk as
vfat! (notext3will not work when booting); - install minimal Ubuntu image on RAID1 ext4 partitions;
- leave 2 disks with a large partition for BTRFS;
- install Ubuntu 10.04;
- reboot;
- configure BTRFS;
- move
/var,/usr, n' stuff over to BTRFS.
0th problem: system will not boot from external disk
First I needed to make my system boot from the external USB hardisk, after fiddling in the BIOS, this was fixed.
Back to installing!
1st problem: external hardisk was not recognized as a CDROM
Fixed by adding: cdrom-detect/try-usb=true to the kernel boot
parameters as told
here
If you get "Incorrect CD-ROM detected" error on detection stage, reboot, press F6 and then ESC to go to manual boot line editing, and add the option 'cdrom-detect/try-usb=true'. On Ubuntu 9.10 server edition the install menu will be shown right after reboot. Chose "Help" and then press F6. At the boot prompt type "install cdrom-detect/try-usb=true" and hit enter.
Back to installing!
2nd problem: installer files missing
The installer could not copy some files. Luckily you can switch
terminals in the installer with Alt+F2 which drops you in
a busybox shell. Go to /var/log/ and check the log files.
In there I found that it was borking on, some deb called:
linux/fs-secondary-modules-2.6.32-14-generic....udeb
Which wasn't there. I did have:
linux/fs-secondary-modules-2.6.32-14-generic....ude
(No closing 'b'!!). Lets fix that by linking the correct name:
# ln -s .....ude ....udeb
operation not permitted
Of course, it is read-only mounted and a VFAT partition which does not support symbolic links. Plan B (copy it):
#mount -o rw,remount /cdrom
cp fs-secondary-modules-2.6.32-14-g.....ude \
fs-secondary-modules-2.6.32-14-g....udeb
Okay, that worked.
Back to installing!
3rd problem: /dev/md1 is used as swap
This system already had a RAID1 configuration on it, so I had to get rid of that first. Also see this link.
I could not delete that raid partition because it is in use
as swap by the installer. WTF? Again the Alt+F2:
swapoff /dev/md1 # md1 was the culprit
I also tend to find fdisk much easier to partition the disks
so I also did this from the command prompt - then let the installer
rescan the newly partitioned disks. I went for the following layout (for
2 disks):
/dev/sda1 /dev/sdb1 combined to form md0 (boot)
/dev/sda2 /dev/sdb2 combined to form md1 (root)
/dev/sda3 /dev/sdb3 combined to form md2 (swap)
/dev/sda4 /dev/sdb4 not used, for BTRFS
Back to installing!
4th problem: grub did not install
Grub failed to install on /dev/sda and /dev/sdb. I tried
grub-legacy and grub2 both failed.
When the installer asks "Install in master boot record", say "no" and
specify only /dev/sda. It performs a grub-install /dev/sda which
fails for some reason. Time to try it ourself. First where is
grub-install located, turns out: /target/usr/sbin/grub-install
Now some more foo, drop to the shell again, and chroot to your new
install
# chroot /target
This is with grub2:
grub-probe: error: no mapping exists for `md0`
See this. Next I tried:
grub-install --modules=raid /dev/sda
you are attempting a cross-disk install, but the filesystem
containing /boot/grub does not support UUIDs
Hmm, see here for a bug report.
Still in the chroot I did the following:
mount /proc
grub-install --modules=raid /dev/sda
Installation finished. No error reported.
Okay, that worked. No go back to the installer and choose "Continue without a bootloader", this will finish up installation.
Back to installing!
5th problem: does not boot
GRUB Loading stage1.5.
GRUB Loading, please wait...
Error 2
Hmm, back to the BIOS and enable my disks again - they were disabled so
that I could boot from the external USB hard disk. Reboot and...
I'm dropped in a grub2 shell. Back to
reading the
docs.
Next:
grub> ls
(hd0) (hd0,4) .... (md0) (md1) (md2) # yes! md devices
grub> insmod linux # needed?
grub> insmod raid
grub> set root=(md1)
grub> linux (md0)/vmlinuz-2.6.32-14-generic root=/dev/md1
grub> initrd (md0)/initrd.img-2.6.32-14-generic
grub> boot
The kernel names came from this
announcement. So I knew
it had to be something like vmlinuz-$version-generic.
6th problem: failed to mount root file system
Somehow I managed to miss type the above grub commands.
ITS
ALIVEBOOTS!
I still need to figure out how to make this permanent. Looks
like you only have to give update-grub as root when you are
logged in. This creates a /boot/grub/grub.cfg to will boot your
system. (Turns out that config file was missing).
The BTRFS part comes in a separate blog - this is already too long.
LaTeX Nirvana
I'm no fan of Word or OpenOffice for that matter, all that WYSIWYG stuff is not for me. For years now I'm using LaTeX for my editing needs. An added bonus for using LaTeX is that the output is stunning.
But for really nice looking output I wanted the following:
- Fonts in images/graphics should match the font of the main document
- TrueType fonts, instead of the standard TeX fonts. To avoid the "Heeh, that looks like a LaTeX document"-reactions;
- UTF-8 support and international character support;
- Easy integration of images (SVG based);
- Automatic building.
I'm using the following tools for this:
- Inkscape and
pdfcropfor graphics generation; - make for building;
- VI for editing (with syntax highlighting);
- evince as PDF viewer;
- xelatex for building the pdf.
General setup
As said earlier, I'm a fan of
the memoir class as a replacement of the standard LaTeX classes. So
I'm using it here again. When you are using xelatex (better UTF-8
support) you should also include the package xltxtra and xunicode.
Fonts
The package for TrueType font support is fontspec, to keep
the math fonts working I had to include the package as
\usepackage[cm-default]{fontspec}.
Note: fontspec mandates xelatex.
To use special characters I also found the pifont package. In my
current working document I use the Liberation Fonts and Courier New:
\defaultfontfeatures{Scale=MatchLowercase}
\setmainfont[SmallCapsFont={* Caps}]{Liberation Serif}
\setsansfont{Liberation Sans}
\setmonofont[SmallCapsFont={Courier New}]{Courier New}
\fontsize{10}{10}
LaTeX will make TrueType fonts slightly larger than its core
fonts, the Scale=MatchLowercase tries to remedy that.
Graphics
I'm using Inkspace to draw my graphics, an added bonus for using TrueType fonts in my LaTeX documents is that I can use the same fonts in the Inkspace drawings. So any text I add will be of the font Liberation Serif at 10 points.
Further more Inkscape has the nice feature that it can be used on the command line
$ inkscape --export-pdf=drawing.pdf drawing.svg
generates the pdf file. To make it fit in the document we need to crop the resulting pdf
$ pdfcrop drawing.pdf output.pdf && mv output.pdf drawing.pdf
And now we are left with a nice, cropped, pdf. See this link on how to include graphics in your LaTeX document, I just use:
\begin{figure}[h!b]
\includegraphics{drawing.pdf}
\caption{Fake caption line.}
\end{figure
Which will probably be extended somewhat to allow for cross references
(search for \label and \ref).
Building
To help in the sometimes tedious building of LaTeX documents, I use
make. For instance creating the pdf graphic files from the svg
source files is done with the following Makefile:
pdfs := $(patsubst %.svg,%.pdf,$(wildcard *.svg))
%.pdf: %.svg
inkscape --export-pdf=$@ $<
pdfcrop $@ output.pdf && mv output.pdf $@
all: ${pdfs}
clean:
rm -f *.pdf
The only thing I need to do is to create a file with Inkscape,
save it and run make.
For the document itself I'm using a similar, small Makefile.
.PHONY: fig
all: fig go.pdf
go.pdf: go.tex go-setup.tex chapter*.tex ex*.tex src/*.go
xelatex go.tex && xelatex go.tex
fig: fig/*.svg
( cd fig; make all )
clean:
rm -f go.lol go.aux go.log map.log go.pdf
( cd fig; make clean )
Putting it all together
Next to the above Makefiles I have the following in the preamble:
\documentclass[a4paper,openany]{memoir}
\usepackage[cm-default]{fontspec}% provides font selecting commands
\usepackage{xunicode}% provides unicode character macros
\usepackage{xltxtra} % provides some fixes/extras
\usepackage[answerdelayed,lastexercise]{exercise}
\usepackage{pifont}
\usepackage{caption}
\usepackage{alltt}
\usepackage{url}
\usepackage{listings}
\usepackage{color}
\usepackage{graphicx}
\defaultfontfeatures{Scale=MatchLowercase}
\setmainfont[SmallCapsFont={* Caps}]{Liberation Serif}
\setsansfont{Liberation Sans}
\setmonofont[SmallCapsFont={Courier New}]{Courier New}
\fontsize{10}{10}
\graphicspath{{fig/}} % set default import pat
% among other \newcommands the follow environment for
% indented alltt (verbatim) text
\newenvironment{display}{%
\def\FrameCommand{\hskip\parindent}%
\MakeFramed {\advance\hsize-\width \FrameRestore}%
\small
\begin{alltt}
}%
{\end{alltt}\endMakeFramed}
My master text go.tex used \input to include all other pieces
of text, so there I have:
\chapter{Intro}
\input{chapter-intro.tex}
This keeps the main document file nice and clean and you can easily
re-arrange entire chapters. After any significant change I just
run make and view the resulting pdf file with evince, which is
an awesome pdf viewer btw. It looks something like this:

The very-much-work-in-progress pdf can be seen here.

