Tag Archives: ubuntu

Ubuntu 9.10 Grub 2 Caveat

Unlike Grub 1.x, in Grub 2 a partition number is the SAME as the number of the corresponding partition number inside of the /dev/ directory instead of that number minus one. For example, if the partition is /dev/sda1, then in Grub 2 it will be (hd0,1) while in the old Grub 1 it is (hd0,0) instead. Today when I install Ubuntu I wasn’t aware of that and I installed grub to (hd0,1), thinking that it is /dev/sda2 (Ubuntu’s partition) while it is actually /dev/sda1 (Windows’s partition) instead! I didn’t realized that until after I reboot and I couldn’t get into Windows. I then have to restore Windows’s boot sectors with Windows’s CD and try to install grub again! When you install Ubuntu 9.10 you have to be aware of this if you are planning to install Grub to a partition instead of the MBR.

Ubuntu hdparm APM and laptop mode tools

Ubuntu 8.10 is supposed to fix the apm=128 issue which causes high loading/unloading cycles for some hard drives; however, it is still BROKEN by default, here’s why:
the file 90-hdparm.sh located in various folders in /etc/acpi such as /etc/acpi/ac.d/, /etc/acpi/battery.d/, /etc/acpi/resume.d/, and /etc/acpi/start.d/ is supposed to fix the hdparm problem; however, notice the following lines:
DO_HDPARM=y
if [ -e /usr/sbin/laptop_mode ] ; then
LMT_CONTROL_HD_POWERMGMT=$(. /etc/laptop-mode/laptop-mode.conf && echo "$CONTROL_HD_POWERMGMT")
if [ "$LMT_CONTROL_HD_POWERMGMT" != 0 ] ; then
# Laptop mode controls hdparm -B settings, we don't.
DO_HDPARM=n
fi
fi

This checks if the file /usr/sbin/laptop_mode exists and if it exists, then it checks if CONTROL_HD_POWERMGMT in laptop-mode.conf is set to a non-zero number in order to determine if laptop mode is enabled. However, Ubuntu installs laptop-mode-tools by default, so /usr/sbin/laptop_mode always exist and that by itself does not tell whether laptop mode is on. Rather, ubuntu turns laptop mode off by default by setting the variable ENABLE_LAPTOP_MODE=false in /etc/default/acpi-support, but this variable is not used anywhere except in the init script /etc/init.d/laptop-mode from line 30 to 37:
# FIXME: this shouldn't be configured there
if [ -f /etc/default/acpi-support ]; then
. /etc/default/acpi-support;
fi

if [ x$ENABLE_LAPTOP_MODE = xfalse ]; then
exit 0;
fi
which stops the script from executing if the variable is set to false. One funny thing about this is that it says FIXME in the comment but it actually never get fixed even after Ubuntu 8.10 is released. With Ubuntu’s default settings laptop mode tool is supposed to be disabled by ENABLE_LAPTOP_MODE=false, but the script 90-hdparm.sh always thought that it is enabled as long as laptop mode is installed because /usr/sbin/laptop_mode is always there. It then checks the variable CONTROL_HD_POWERMGMT in /etc/laptop-mode/laptop-mode.conf, which is 1 by default, and it will set DO_HDPARM=n, thinking that laptop-mode is on and letting it to handle hard drive’s APM setting instead while actually laptop-mode is OFF and not taking care of the APM problem. This makes nobody changing the hard drive’s default APM setting from 128 to something else, leaving the clicking problem unsolved.
I did some workaround to 90-hdparm.sh by changing the line "if [ -e /usr/sbin/laptop_mode ] ; then" to "if [ -e /var/run/laptop-mode-tools/enabled ] ; then" in order to check if laptop mode tool is enabled, because whenever laptop mode tool is enabled, it creates the file /var/run/laptop-mode-tools/enabled, so I think this is the right way to check if it is actually enabled rather than just installed. I also think that the variable ENABLE_LAPTOP_MODE in /etc/default/acpi-support should be removed instead, just as Debian did in acpi-support version 1.109-5. That variable is just there to confuse people more and mess up the configurations. Even the comment in /etc/init.d/laptop-mode says “FIXME: this shouldn’t be configured there” already, why don’t they just fix it right now and make all these things less messy. I have tested Debian six months before and they really did a good job in fixing those hard drive clicking issues by making the 90-hdparm.sh file and removing the ENABLE_LAPTOP_MODE variable.

Wubi – Install Ubuntu inside Windows w/o Partitioning


If you want to install ubuntu 7.04 Feisty, but you don’t want to modify your Windows partition and you want to install it inside, Wubi is for you. According to its website:

Wubi is an unofficial Ubuntu installer for Windows users that will bring you into the Linux world with a few clicks. Wubi allows you to install and uninstall Ubuntu as any other application. If you heard about Linux and Ubuntu, if you wanted to try them but you were afraid, this is for you.

Moreover, Wubi doesn’t need you to replace the default Windows bootloader, as “Wubi adds an entry to the Windows boot menu which allows you to run Linux. Ubuntu is installed within a file in the windows file system (c:\wubi\disks\system.virtual.disk), this file is seen by Linux as a real hard disk.” Then it loads the file as a loopback root Filesystem, kind like those described in “The Loopback Root Filesystem HOWTO,” but with the loopback filesystem is actually in Windows’s partition.

Since Wubi makes Ubuntu run inside Windows partition, there will be a little bit performance penalty, especially when your Windows partition is fragmented. Moreover, if there were any error in the ntfs partition that affects the system virtual disk, you need to fix the errors with something like chkdsk in Windows first before booting Ubuntu. If you’re not afraid of partitioning, I still recommend you to install Ubuntu in a separate partition.

Wubi’s Website

Make Ubuntu Dapper to display Chinese well in two minutes

With Ubuntu Dapper you can make Linux to display Chinese fonts (or maybe for other languages as well) much much easier than before. After you read this you’ll find out to make Linux to display Chinese well can be as simple as this.

  1. Get the font Simsun.ttc from Windows or some other high quality Chinese fonts and put them in the folder /usr/share/fonts/truetype.
  2. Update the font cache by runing “sudo fc-cache -fv”.
  3. Last and not least run the command “sudo fontconfig-voodoo -f -s zh_CN” and you are done! restart X and check it out.

Here are some screenshots for the effects:

You can even see bold, italic, bold+italic fonts:

Firefox browsing Yahoo China: