What happened in Ubuntu today? 2

Posted by bikethetam Sat, 10 Oct 2009 22:19:00 GMT

No post in a long time but it's not that I've been lazy. In fact, I've been working hard. Here's what I have been doing, hopefully, some of you will find this useful.

For a long time, I have been updating my ubuntu machines through the update-manager or aptitude. Both tools naturally show the list of packages that are updated and I immediately proceed to start the update. But an hour later, I would ask myself, what the hell just got updated? And I know of no tools that can give me a straight answer to that question.

So I decided to take things into my own hands and I developed a website to track changes in Ubuntu distributions. This website is called www.ubuntuupdates.org.

The main page has the list of all package updates per release, most recent first, the emergency level of the change, the repository where it was released and the description of what changed. That list is updated hourly.

Each package also has its own page that includes
- description of the package
- version history
- changelog
- bugs fixes for each new version

If you're interested in finding stats on the number of updates per day, check out the dashboard.

You can also search for any package and see what the latest version available in each release and what repository it's leaving in (main, universe, multiverse, backports).

Again it's www.ubuntuupdates.org. Enjoy!
 


How to make the Acer Aspire One faster 11

Posted by bikethetam Sun, 17 May 2009 01:33:00 GMT

Using an SD card to run Ubuntu

The Acer Aspire One 110 is notorious for its small and sluggish SSD disk (SSDPAMM0008G1EA). Firefox is so slow it seems web pages will never finish loading and you'd better not be in a hurry when starting the package manager or setiing up Ubuntu updates. I wanted to find a solution that wouldn't involve tearing the motherboard apart and I found one. It cost me about $40 and a couple of hours of work.

The idea is to use a fast SD card as the primary drive of the laptop by installing Ubuntu on it, the SSD becomes an extra storage device. As you will see below, the SD card shows more balanced performances than the SSD and significantly faster write speeds.

I chose to buy the Transcend 16 GB SDHC Class 6 memory card. Note that it is sold with an USB adapter that comes very handy when installing the OS on the AAO.

Setup

There is just one problem with the setup: the bios on the Acer Aspire One is unable to boot from the SD card. That means that you can't just setup Ubuntu on it and restart. The workaround is to let the laptop boot from the SSD: the bios reads the MBR and starts grub on the SSD. The initrd kernel image is also on the SSD and that kernel is capable of mounting the SD card. Only after this is done can the regular boot process resume and the actual kernel get loaded from the SD card.

I followed the very good installation instructions I found on osnews.com. They are very detailed, I followed them point by point and I didn't run into any issue. Here is a slightly modified list of steps that goes straight to the point:

  • Install Ubuntu on the SSD if it's not already there. In my case it was there so I could skip that step. I found the version of linux present on the SSD doesn't really matter, it will just be used for its /boot directory and grub.
  • Boot from a USB drive where you can Install Ubuntu from. I used the 9.04 alternate CD. I had plugged it in the USB slot on the right of the AAO and I had the SD card in the USB adapter  on the left of the AAO. It might be possible to just stick the SD card directly on the left SD slot on the left, I think the 9.04 install USB key would be able to find it but I haven't tried and you will need the adapter on step 4 anyway.
  • Proceed with the actual installation to the SD card from the USB drive.
  • Reboot from the newly installed SD card (inside the USB adapter: there's no way around this for this step). Mount the old SSD on /ssd
mount -t ext2 /dev/sda1 /ssd
  • Now you must reconfigure how initrd.img files are generated. The goal here is to include support for the SD card reader in the initrd. Without it, you won't be able to access the card from grub. Edit /etc/initramfs-tools/modules on the SSD card and add those 4 lines:
mmc_core
mmc_block
sdhci
sdhci-pci 
  • Regenerate the latest initrd kernel image and copy it inside of the SSD /boot directory.
update-initramfs -u 
cp /boot/initrd.img-2.6.28-12-generic /ssd/boot
  • Edit /ssd/boot/grub/menu.lst on the SSD drive. There you will create a grub menu entry that points at a kernel on the SD card. Replace the UUID below with yours.
title           Ubuntu 9.04, kernel 2.6.28-12-generic-SDCard
uuid            5ce02d2f-1fee-4cc5-8c7d-bde5f19b26b8
kernel          /boot/vmlinuz-2.6.28-12-generic root=UUID=5ce02d2f-1fee-4cc5-8c7d-bde5f19b26b8 ro elevator=noop quiet splash
initrd          /boot/initrd.img-2.6.28-12-generic
quiet

Note that the UUID on the "kernel" line is the UUID of the SD card. So in the /boot directory of the SD card, there must be a vmlinuz file that matches the initrd file from the SSD card.

That's it, you can reboot one last time, select  "Ubuntu 9.04, kernel 2.6.28-12-generic-SDCard" from the grub menu and if the gods are with you, you will load the OS from the SD card. At this point you will enjoy an Ubuntu setup that will feel twice as fast as the old one with 3 times more storage space.

Beware: anytime you get a new kernel, by default it's only installed on the SD card but you need it on the SSD drive. So don't forget to copy the new initrd.img to /ssd/boot and to update /ssd/boot/grub/menu.lst whenever needed or you won't be able to use the new kernel.

Disk performance measures

Now that is just a feeling at this point. Here is how to back it with concrete numbers. I found the dd test page very helpful for this experiment. One can easily measure the disk  read speed with hdparm but that ells you nothing about the write speed.

$ hdparm -tT /dev/mmcblk0p1

/dev/mmcblk0p1:
 Timing cached reads:   1144 MB in  2.00 seconds = 572.07 MB/sec
 Timing buffered disk reads:   40 MB in  3.16 seconds =  12.67 MB/sec

So the best way to get both read and write speed is the following:

To measure the sequential write speed, write a large file to disk while measuring the time it takes. Note that the sync command is essential to guarantee all the data gets written instead of staying in some cache. Do not trust the throughput reported by dd, instead divide the size of the file by the duration reported by "time". For example, here is the test on the SD card (it generates a 160 MB file):

$ time sh -c "dd if=/dev/zero of=ddfile count=20000 bs=8k && sync"

20000+0 records in
20000+0 records out
163840000 bytes (164 MB) copied, 13.4757 s, 12.2 MB/s

real    0m18.885s
user    0m0.020s
sys     0m0.640s

To measure the read speed, read the same large file from disk:

$ time dd if=ddfile of=/dev/null bs=8k                
20000+0 records in
20000+0 records out
163840000 bytes (164 MB) copied, 9.96247 s, 16.4 MB/s

real    0m9.974s
user    0m0.016s
sys     0m0.588s

I ran that test on the SD card, on the SSD and on another Acer Aspire One  (AOA 150) with a regular hard disk.

  SD Card
SSD AOA150
Read speed (MB/s) 16.4 26.5 62.2
Write speed (MB/s) 8.42 2.31 51.6

 

As you can see although the SD read speed is just 60% of the SSD read speed, the write speed is almost 4 times higher on the SD card and for normal usage of a laptop that write speed increase changes everything. It worked so well, I decided to use Gnome on this machine and it appears to go twice as fast as Xfce was going on the SSD. Not that the Acer Apire One got magically turned into a Ferrari but with that SD card, it became a pretty decent Toyota!


Is laptop_mode enabled in Ubuntu 8.10

Posted by bikethetam Mon, 24 Nov 2008 03:47:00 GMT

laptop_mode is an extremely poorly documented tool that is distributed with Ubuntu and it's also a dangerous one as it is either the cause or the solution for the very widespread problem of the hard drive spindown issue. It's so poorly documented that nobody seems to know it it's in use or not in Ubuntu. It's also very difficult to figure out how to turn it on or off.

Once this issue is figured out, laptop_tools can be very convenient to configure how your laptop saves power. But unfortunately its interactions with other tools designed for a similar purpose are problematic to say the least.

Here's is what I managed to figure out by experimenting and going through various posts on the net.

What is laptop_mode anyway? laptop_mode is a tool with a set of configuration settings to configure your block devices, the frequency of the CPU, when to turn off the display, all in one place. For all disks on your system you can configure things such as
  • are the disks mounted witth noatime, relatime?
  • APM (Advanced Power Management)
  • using write cache...
All those things you can already set using hdparm and /etc/hdparm.conf but the difference is that laptop_mode makes it possible to have different settings for different modes (on AC or on battery mainly). For example you might want to sacrifice some of the performance of the disks to save some power but only when you're running on battery, not on AC.

laptop_mode files
  • /usr/sbin/laptop_mode: the script that applies the laptop_mode settings when invoked by a power management daemon
  • /etc/laptop_mode/laptop-mode.conf: the configuration file where the power saving parameters can be set for various power states
  • /proc/sys/vm/laptop_mode: current status of laptop_mode
  • /etc/init.d/laptop_mode: init script. If called with the "start" argument, it may create "/var/run/laptop-mode-tools/enabled" and call "/usr/sbin/laptop_mode start" (see below why it may not do that).


How to tell what state laptop_mode is in? There is no laptop_mode process running in the background. Instead laptop_mode is run when needed when the environment changes, it does what it needs to do and exits immediately. /proc/sys/vm/laptop_mode has the current status of laptop_mode:
  • 0: disabled
  • 2: enabled
I've never seen it at 1.
If the status is enabled, then the appropriate settings found in laptop_mode.conf will be applied as soon the power state of the machine changes.

How to turn it on? "/usr/sbin/laptop_mode start" will change the status to enabled. "/usr/sbin/laptop_mode stop" will change the status to disabled. That always works. The problem is to figure out if laptop_mode will automatically be invoked during startup.
There are several conditions that need to be true for that to happen.
/etc/init.d/laptop_mode must be executed by default during initialization. That is the case in 8.10:
me@myhost ~ $ ls /etc/rc?.d/*laptop*
/etc/rc0.d/K99laptop-mode  /etc/rc3.d/S99laptop-mode  /etc/rc6.d/K99laptop-mode
/etc/rc1.d/K99laptop-mode  /etc/rc4.d/S99laptop-mode
/etc/rc2.d/S99laptop-mode  /etc/rc5.d/S99laptop-mode
However that's not enough. Looking closely at /etc/init.d/laptop_mode, we see:
# 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
and in /etc/default/acpi-support in Intrepid:
ENABLE_LAPTOP_MODE=false
What that means is that you can run "/etc/init.d/laptop_mode start" all you want, it won't do a thing, which means that in this configuration "/usr/sbin/laptop_mode start" is never called during startup or anytime after startup.

laptop_mode is not enabled by default in Ubuntu 8.10.
"laptop_mode status" says:
Laptop Mode Tools is NOT allowed to run: /var/run/laptop-mode-tools/enabled does not exist.

/proc/sys/vm/laptop_mode:
0
Naturally, editing /etc/default/acpi-support and setting that parameter to true changes everything. Then and only then will laptop_mode settings be applied on startup.
Experiments show that after setting it to true and rebooting the machine, "laptop_mode status" says:
Laptop Mode Tools is allowed to run: /var/run/laptop-mode-tools/enabled exists.

/proc/sys/vm/laptop_mode:
2
and plugging or unplugging the power cord will produce the expected results. You can easily check for that by checking the drives Readahead states. On my machine it goes from 128kB to 3072kB as configured in laptop_mode.conf.
My feeling is that the "Laptop Mode Tools is NOT allowed to run: /var/run/laptop-mode-tools/enabled does not exist." line is just there to confuse people. Laptop mode tools is seemingly another set of tools that is not directly related to laptop_mode and that has no influence on the interpretation of laptop_mode.conf. /var/run/laptop-mode-tools/enabled is created only by "/etc/init.d/laptop_mode start" but that doesn't seem to matter. Even if that file does not exist, enabling laptop_mode with "/usr/sbin/laptop_mode start" will totally enable laptop_mode.

Interactions with hdparm.conf hdparm.conf will be entirely ignored if laptop_mode is enabled. That's because hdparm settings are applied very early during the boot process by /lib/udev/hdparm and laptop_mode runs later overwriting whatever disk settings may have been set in hdparm.conf.

What about ACPI? laptop_mode, if in charge, also overrides ACPI settings related to hdparm APM (Advanced Power Management).
This is visible in /etc/acpi/start.d/90-hdparm.sh
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
Unfortunately, this is bogus because, as we've seen above, laptop_mode may very well NOT be enabled even if laptop_mode.conf exists and CONTROL_HD_POWERMGMT is non zero. If that happens then no one will take care of tuning the hdparm power management when switching between battery and AC.
See ubuntu-hdparm-apm-and-laptop-mode-tools for more details.

Note: this got fixed in Intrepid in an update mid-January: acpi hdparm fixed

But anyway, if laptop_mode LMT_CONTROL_HD_POWERMGMT is found to be 0, ACPI is in charge and controls the APM settings (-B) between 128 (battery) to 254 (AC).

What a mess! As for me, the poorly managed interactions with ACPI and udev/hdparm convinced me to turn off laptop_mode once and for all.

Debian package manager cheat sheet

Posted by bikethetam Thu, 13 Nov 2008 02:58:00 GMT

Searching the local cache of repositories apt-cache search

$ apt-cache search activerecord
libactiveldap-ruby1.8 - an object-oriented interface to LDAP for Ruby
libactiverecord-ruby - Ruby library that ties database tables to classes
libactiverecord-ruby1.8 - Tie database tables to classes (Ruby 1.8)
...

Finding information about a non installed package

apt-cache showpkg

$ apt-cache showpkg libactiverecord-ruby1.8
Package: libactiverecord-ruby1.8
Versions:
2.1.0-3 (/var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_intrepid_universe_binary-i386_Packages)
Description Language:
        File: /var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_intrepid_universe_binary-i386_Packages
         MD5: 4eabc44d09608d0156c42018917a2881

Reverse Depends:
libactiverecord-ruby,libactiverecord-ruby1.8
Dependencies:
2.1.0-3 - libruby1.8 (0 (null)) libactivesupport-ruby1.8 (2 2.1.0-3) libsqlite3-ruby1.8 (16 (null)) libpgsql-ruby1.8 (16 (null)) libmysql-ruby1.8 (0 (null))
Provides:
2.1.0-3 -
Reverse Provides:

Listing all available packages matching a pattern

The packages matching the patterns may or may not be installed. dpkg -l

$ dpkg -l ruby*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name             Version          Description
+++-================-================-================================================
ii  ruby             4.2              An interpreter of object-oriented scripting lang
un  ruby-elisp                  (no description available)
ii ruby-full 4.2 Ruby full installation
ii ruby1.8 1.8.7.72-1 Interpreter of object-oriented scripting languag
ii ruby1.8-dev 1.8.7.72-1 Header files for compiling extension modules for
un ruby1.8-examples (no description available)
ii rubygems 1.3.0~RC1really1 package management framework for Ruby libraries/
un rubygems-doc (no description available)
ii rubygems1.8 1.3.0~RC1really1 package management framework for Ruby libraries/

Finding information about an installed package

dpkg -s

$ dpkg -s ruby1.8
Package: ruby1.8
Status: install ok installed
Priority: optional
Section: interpreters
Installed-Size: 136
Maintainer: Ubuntu Core Developers 

Listing all files belonging to an installed package

dpkg -L

$ dpkg -L ruby1.8
/.
/usr
/usr/bin
/usr/bin/ruby1.8
/usr/bin/erb1.8
/usr/bin/testrb1.8
/usr/share
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/erb1.8.1.gz
/usr/share/man/man1/testrb1.8.1.gz
/usr/share/man/man1/ruby1.8.1.gz
/usr/share/doc
/usr/share/doc/ruby1.8
/usr/share/doc/ruby1.8/README
/usr/share/doc/ruby1.8/README.ja.gz
/usr/share/doc/ruby1.8/ToDo.gz
/usr/share/doc/ruby1.8/README.Debian
/usr/share/doc/ruby1.8/copyright
/usr/share/doc/ruby1.8/LEGAL.gz
/usr/share/doc/ruby1.8/NEWS-1.8.0.gz
/usr/share/doc/ruby1.8/NEWS.gz
/usr/share/doc/ruby1.8/NEWS.Debian.gz
/usr/share/doc/ruby1.8/changelog.Debian.gz