Moving Ubuntu to a New Hard Drive

Well, I guess it had to happen some time…  the system disk on my home Ubuntu server started going south recently.  Just a few errors here and there, but once it starts, it only gets worse.  So I thought I’d write down the steps I took to move my system to a new disk, partly for my own reference, and partly in hopes that someone else will find it useful.

First, grab a copy of a “live boot” Linux distro that will run off a CD.  I use Knoppix, but there are others available too.  Attach the new disk to the system, boot off the CD, and mount both the old and new disks.  Make sure the old disk is mounted with ‘errors=continue’ option so that it’ll keep going when errors are encountered.

Use “tar” to copy the root filesystem from the old drive to the new.  Example:

cd /oldroot

tar cvpf – . | (cd /newroot; tar xpf -)

You might want to capture the output of the tar command as well, so you can go back over it and see where it found errors on the old disk.  That way you get an idea if any important files might be corrupted.

When the tar command completes, make sure you have a more-or-less complete copy of the old root filesystem.  An easy way to do this is to run ‘df’ and make sure both copies take up roughly the same amount of disk space.

If your old disk has multiple partitions, you’ll want to copy these as well.

Shut down, remove the old disk, and jumper the new one (if necessary) so it appears as the same device.  Reboot into Knoppix and re-mount the new disk.

Install the grub boot loader on the new disk:

/sbin/grub-install –root-directory=/newroot /dev/sda

Some Linux versions refer to disks by UUID rather than device name.  If this is the case, you’ll need to go into /etc/fstab and /boot/grub/menu.lst and change the UUID to reference the new disk.  You can find the new disk’s UUID by looking in /dev/disk/by-uuid.

My old disk had a swap partition, and I didn’t create one on the new disk.  Instead, I commented the swap partition out in /etc/fstab, booted the system without swap initially, then created a swap area on the filesystem:

dd if=/dev/zero of=/swap bs=1024 count=4194304

mkswap /swap

swapon /swap

This gave me a 4-gig swap area.  To automatically add it at boot time, add to /etc/fstab:

/swap swap swap defaults 0 0

I’m sure I’ve left something out somewhere, but that’s the general idea.

Latest Ubuntu Upgrade

I just upgraded my Ubuntu box from 7.04 (Feisty Fawn) to 7.10 (Gutsy Gibbon), and after 3 upgrades (I started out with Dapper Drake) I remain impressed with how easy and painless it is. This time there was a hiccup, though. But, it’s not something that I’d expect an average user to encounter.

First, a bit of background. My desktop machine gets a lot of its files via NFS from a remote server. The server runs a base of Debian Etch with a bunch of stuff from the testing/unstable trees. The two computers are both on the same LAN, and the server currently runs kernel v. Ubuntu 7.10 currently uses 2.6.22.

After completing the upgrade, I rebooted my machine into Ubuntu 7.10 for the first time, and logged on. It took about 5 minutes for all my menus and apps to come up (some of the apps came up before I had any menus, making me wonder if the upgrade had botched something.. but everything did finally appear). I quickly figured out the cause of the problem: all of my NFS mounts were timing out.

I did a few more tests, and I found out that I had no problem mounting and unmounting NFS directories from the server. But when I tried to run ‘ls’, my terminal just froze and I got ‘NFS server blah.blah not responding’ in the kernel log. No amount of rebooting, re-exporting filesystems, etc. seemed to help. I wondered if it was some sort of subtle incompatibility between the two different kernel versions, although I’d never had this kind of issue with NFS before in my almost 20 years of dealing with it. (Wow, has it really been that long?)

I’m aware that there are two versions of NFS nowadays, the older version 3 and the newer version 4. The 2.6 kernel supports both versions, but I’ve always run version 3 because it has always worked for me, and I’ve never seen a need to change. Plus, when I go to configure my kernel, all of the NFS v4 stuff is labeled as EXPERIMENTAL, which makes me shy away from it. This time, though, rather than futzing around trying to get my old NFS v3 setup to work again, I decided to try v4. I built it into the server’s kernel and rebooted the server. I then followed the very helpful Ubuntu NFSv4 Howto, which explained the differences between v3 and v4 and walked me through the setup.  It worked, and it doesn’t hang any more.

It’s a little troubling not knowing why the upgrade broke my NFS v3 setup.  Searching around on Google wasn’t too helpful.  I suspect it’s some kind of issue with the 2.6.22 kernel, but I did not want to spend a lot of time troubleshooting it..  I just need my computer to work.  So I’m glad NFS v4 fixed it for me, otherwise I’d probably have to downgrade back to Feisty.

NFS issue aside, the Gutsy upgrade was very smooth, and I continue to be happy with Ubuntu.

Ubuntu hard drive upgrade

I just finished upgrading the hard drive on my Ubuntu machine, and it wasn’t as easy or straightforward as I was expecting.  So I figured I’d write up some notes for the next time I do it.

First I backed everything up. Then I shut down the computer, put the new drive in, and booted up with a copy of Knoppix I had lying around. Under Knoppix, I opened up a shell and mounted my old root filesystem:

# mount /dev/hda1 /mnt

I then mounted the new root filesystem on /mnt2, and copied all the files over:

# mount /dev/hdb1 /mnt2
# cd /mnt
# tar cvpf - . | (cd /mnt2; tar xpf -)

Then, I installed the grub boot loader in the MBR of the new drive:

# grub
# root (hd1,0)
# setup (hd1)

At that point, I shut down the computer, removed the old drive, installed the new one in its place, and attempted to boot back up. Happily, it found the grub boot loader and proceeded to load the kernel. But then it hung trying to mount the root filesystem.

It turns out that a couple releases ago, Ubuntu started referring to disk partitions by UUID rather than using a specific device name such as /dev/sda1 or /dev/hda1. Both /boot/grub/menu.lst and /etc/fstab still contained UUID references for the old hard drive, so I had to go through and painstakingly replace all the old UUID references with the updated UUID for the new disk. I just used vi and did a search-and-replace, although there’s probably an easier way. Once I did this, everything booted up just fine.

I can see the advantages to using UUIDs, but it does add an extra layer of complexity when doing something like this. At least I know what to expect the next time around.

Coming soon: my adventures upgrading from Ubuntu 7.04 (Feisty Fawn) to 7.10 (Gutsy Gibbon).  There were a couple of snags, but it was mostly painless.

Ubuntu 2 1/2 month review, etc.

I’ve been using Ubuntu now for about 2 1/2 months. The verdict so far: I like it. When I initially installed it, I was looking for a Linux distro with a reasonably well-integrated and user-friendly desktop environment, and Ubuntu (with GNOME) has lived up to those expectations. I really like the GNOME file manager with its built-in sshfs support, and the menu/taskbar integration works really well. When I install an app, it automatically shows up in my “Applications” menu, and the GNOME-aware apps also take advantage of the task bar. This works even with GNOME apps that aren’t provided with Ubuntu — for example, today I installed gSTM, which is a GUI interface for managing SSH tunnels. It’s not part of the Ubuntu “universe”, so I downloaded a .deb from Sourceforge and installed it (there’s a handy GUI for installing .debs too, which Firefox launched automatically). Once installed, gSTM showed up in my “Applications” menu and also added itself to the task bar when I launched it. Very nice.

The only thing I’m not quite happy with is my age-old gripe with all Linux distros: fonts. I’ve done all my requisite font-fiddling and I’ve got fonts I’m pretty much happy with now. But the font rendering in Firefox is just horrible. Text is always overflowing table cells and other stuff, and certain web sites just look, well, bad. It’s not bad enough to be a show stopper, but I really wish it looked nicer. I’m not sure what’s to blame: Firefox, X, GNOME, or whatever. But I will say that the fonts look pretty good in most of the other apps.

Linux GUI distros have to fight an uphill battle, because there are so many different apps (some 20+ years old) coded to all sorts of different GUI standards. There’s no way to get all of these apps to look perfect — it’s like herding cats. But the GNOME people have done a pretty admirable job fitting everything together. The user experience is about as seamless as one could hope for.

Ubuntu fonts

I think I’ve finally got an Ubuntu font setup that I can live with. It’s not perfect, but it’s livable. Here’s what I did so I can replicate it if necessary.

  • Install msttcorefonts package.
  • Install MS “Tahoma” and “Tahoma Bold” fonts, neither of which are included with msttcorefonts.
  • Set X server to 96x96DPI.
  • Install a custom .fonts.conf that disables anti-aliasing for smaller fonts, sets some font prefs, and enables sub-pixel rendering.
  • In Firefox, go to Edit->Content->Fonts & Colors->Advanced. Set Proportional font to “Sans Serif”, Size 14pt. Set Serif font to “Times New Roman”. Set Sans-Serif font to “Verdana”. Set Monospace to “Courier New” at 12pt.

I’m pretty sure that’s it. Further references may be found in other posts in this category.

The overall result is a very Microsoft-y look, probably because of the heavy use of the Tahoma font. Some fonts are a little too small, others are a little to big (the default font in Firefox, for one). But, I can live with this until I go to a Mac on my desktop. It took a bit of tweaking, but it definitely looks nicer than my old vanilla Debian setup.

Followup 8/15.. The menu fonts in were still kinda ugly after doing all this.. I fixed this by going to Tools->Options->>View, and unchecking “Use system font for user interface.” Then when I restarted, the menus came up in Tahoma. Problem solved.

Followup 1/11/07: Installed Firefox 2 and found things required some additional tweaking. Changed Sans-Serif font from Verdana to Arial. Changed proportional font size to 16pt and fixed font size to 14pt. Re-enabled anti-aliasing for smaller fonts. Not sure I’m 100% happy with it, but it’s tolerable.

Installed Ubuntu

I tracked down a spare 8.5gig disk today (the one that came with my old P2-300 box, ironically) and installed Ubuntu on it. First problem: I installed the spare disk as an IDE slave, and the Ubuntu install totally hosed the boot loader on the master (Grub). After installation, the boot loader gave some cryptic error message and hung. So, I booted into Knoppix and reinstalled the boot loader, which allowed me to boot into my Debian OS on the master disk. I then attempted to configure my existing Grub to boot Ubuntu off the slave. But, when I booted, grub refused to recognize the slave disk. Not sure why (BIOS issue maybe?) but I ended up copying all of the Ubuntu /boot stuff into the /boot partition on my master disk, pointing grub at that, and just booting everything from there. Once I did that I was finally able to boot Ubuntu. (One hitch with this method — Kernel upgrades in Ubuntu are no longer automatic. I have to copy the kernel and initrd images into /boot on the main disk, then edit the gruf.conf there to boot the new kernel. Not a big deal, as I don’t plan on running this configuration for too long — if I like Ubuntu, I’ll install it as the main OS on the computer.)

Upon bootup, it immediately prompted me to install 160-odd megs of software updates, which mostly worked, but some of them apparently crapped out as I got this happy-fun-ball “some updates failed to install” window after the installation finished. Being that Ubuntu uses apt, this is somewhat to be expected, but I hope it doesn’t screw up further updates (as apt failures on my Debian boxes are wont to do). Followup — no further problems with apt so far. After installing the updates, I was prompted to reboot, which I did, which brings me to where I am now, writing this entry.

Ubuntu seems nice enough, but so far it doesn’t seem much different from other Linux desktop installations I’ve seen, all of which are fraught with quality-control issues such as these. Once configured, they work well, but there’s always that pain of setup and configuration. I guess I’m a little disappointed — after all the hype I’ve read, I was hoping Ubuntu would be more revolutionary — a Linux desktop that doesn’t really feel like a Linux desktop. Oh well. Off I go to a command-line to get my graphics card working and fix my fonts, just like every other Linux desktop….


OK.. Installing the nvidia driver was easy, actually. There’s a package (nvidia-glx) that takes care of it. After installing this, I went in and copied my configuration out of my old xorg.conf, restarted X (by way of the gdm display manager), and it came right up with my dualhead configuration.

I’m now in the process of installing some other “must-have” apps such as emacs, thunderbird, etc. Oh yeah.. and OpenAFS. Uh-oh…

Well, openafs turned out to be painless. Just install the modules-source package and follow the directions in /usr/share/doc/openafs-client/README.modules. Now to work on fonts. Installing msttcorefonts package helped a lot. To do that I first needed to go into Synaptic (Ubuntu’s GUI front-end to apt) and enable the “multiverse” repository, which includes non-free packages. Then, I found that my X display was not set to 96x96dpi, which is supposedly optimal for font rendering. Based on info found here and here, I tweaked the display DPI in xorg.conf by adding the following option to my “Monitor” section:

DisplaySize 783 277 # 96 DPI @ 2960x1050

and the following to “Device”:

Option "UseEdidDpi" "false"

Next it looks like I need to tweak anti-aliasing for certain fonts (reference).

Little by little it’s coming along.

Another good font tutorial for configuring fonts under Ubuntu. This one includes instructions for installing the Tahoma family, which for some reason is not included with Microsoft’s Core fonts for the web. With the MS fonts (plus Tahoma) installed, things look much better already, and apparently I can improve the look further by tweaking anti-aliasing and other stuff… might play with that a bit tomorrow.

First impressions of Ubuntu, etc.

Last Friday I tried out the latest release of Ubuntu Linux. They provide a “live” CD, which boots and runs directly from the CD just like Knoppix. My goal is to find a nice desktop-oriented version of Linux that “just works”. On the server side, I’m sticking with Debian, but I find vanilla Debian a bit lacking in the desktop department. So as a stop-gap between cutting over to OS X completely, I thought I’d try out Ubuntu and see how I like it. Ubuntu is based on the same apt package system as Debian, so it’s familiar, and it’s touted as being very desktop-friendly.

First impressions: it looks nice. apt-get works as expected from the command line, but the default archive server has a very slow connection — I wonder if there are mirrors on Internet2 that I could use. If not, that’s a definite drawback, as I’m not sure I could give up the blazing speed I get from I was able to install xmms easily, and my sound card was immediately recognized, and the system shares the sound card between apps. However, for some reason it didn’t work streaming MP3s from my mp3act server. Recent versions of OpenOffice and Firefox are provided. It didn’t pick up my dual-head setup, but I didn’t expect it to — I’ll need to download and install nVidia’s driver manually. It looks like I’ll need to install some compilers and devel tools before I’ll be able to build the nVidia driver. But I expect it’ll work.

As with every other version of Linux, the default fonts are butt-ugly. Why can’t someone put out a Linux distro that has nice fonts out of the box? That has always been one of my biggest gripes with Linux. There are tutorials on the ‘net to improve the look of the fonts under Ubuntu, but honestly, this shouldn’t be something I have to mess with. Linux is never going to get anywhere in the desktop market until they can get past this issue.

All of that said, I think I may try out an “official” install of Ubuntu on the hard drive, and see how it goes for awhile. I’d rather not wipe out my existing Debian install, so I’ll have to scrounge around for a spare hard drive first.

In other news.. I’m thinking about finally taking the plunge and going with totally paperless bills and financial statements (where possible). My redundant disk setup gives me a more reliable place to store documents electronically, so there’s no reason not to go for it. As with everything else, I’ll see how it goes.