Tag Archives: linux

Root Account and Single User Mode

To discourage people to use the root account, by default some distro such as Ubuntu don’t set a password for the root user. This way people cannot login with the root account directly. However, without setting a password for root user, people can log into single user mode (aka recovery mode) with the root account without password, and then the user can do anything including change the password of any users.

You should set a password for the root user even if the distro doesn’t tell you to do so during the installation. If you haven’t set up a password for the root user yet, you can do so by typing sudo passwd root and type the new password. Once you set the password for the root user, next time you log in to single user mode or recovery mode, it will ask you for root’s password instead of just let you in.

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.

Vista Temporary Internet Files Virtualized

Yesterday after scanning virus with Kaspersky online(which is a Java Applet), I saved the log file in my documents; however, I can’t find it anywhere in my document folder. I thought it was lost, so I opened the online scanner and tried to save again and I still saw the old file there. I wondered where did it go, so I searched for it, but Vista’s search function is quite useless and it didn’t find it. I then looked into the AppData folder to try to find it but still nothing. Later on I tried to boot into Linux and searched for the file again, and I found it in the “AppData\Local\Microsoft\Windows\Temporary Internet Files\Virtualized” folder, which was kinda weird. It was Vista’s new security feature to Virtualize those programs that are incompatible and make them to write to a different folder than the actual one, but how come other programs can’t see those virtualized files? To prevent things like this, I have to run Internet Explorer as administrator to save the file in order for the file to be written to the correct folder.

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:
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.

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;

if [ x$ENABLE_LAPTOP_MODE = xfalse ]; then
exit 0;
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

How to kill a hard drive in Linux quietly with an easy way to undo it

We know that we can kill Linux by running the command rm -rf /, but this can’t be undone as your files are gone. Here’s a quick way to make your hard drive look like formatted and how to undo that easily (tested under VMWare with ubuntu), click each picture for more information.

First back up the first 10000 bytes of the hard drive and then replace it with empty data.

Everything seemed to be OK and we could still shut down normally, but……..

After we restart, it won’t boot anymore with an empty MBR and all the partitions are gone! To fix it we need to boot from a boot disk and restore what we backed up.

After all this it everything worked again. Now restart and check it…

Inspiration from my very sad personal experience:

Once upon a time I thought the first 512 bytes of hda1(where my Windows is installed) is the MBR but in fact it’s supposed to be the first 512 bytes of hda, I ran the command “dd if=/dev/zero of=/dev/hda1 bs=512 count=1″ and thought this would reset the MBR, but the Windows partition is ruined instead!

Tips to test potentially unsafe software without hurting computer.

If you really want to test out or use a program that might be potentially unsafe, contain virus, or do something you didn’t expect, but you don’t want your computer to be hurt, what should you do? Here’s some tips to do it safely.

  • for both Windows and Linux you can make a Windows virtual machine with VMware and make a snapshot before testing those programs, if something is wrong with the program you can go back to the snapshot.
  • For linux users there’s even more options, we could test the program with a non-root user account, but still you might want to create a new user account to test it if your own user account has many datas because some programs might destroy datas that they can access.
  • For advanced users they can use other options like make virtual machine with user-mode kernel or mount with unionfs to test the program with a virtual root account.
  • For Windows users running programs with limited users might help, but most Windows programs won’t run properly under those accounts, for now the only solution that I can think of for this is VMware. You can also track what the program does by using Filemon to monitor file changes, Regmon to monitor registry changes, and Urlsnooper to monitor the url the program accessed, or any other utilities in addition of those mentioned above.

Check out colinux, it’s very cool

… “If Linux runs on every architecture, why should another operating system be in its way? ” …

Afraid of installing linux? Want to use linux occasionally while using windows without partitioning? check out colinux, it can install and start linux from a file in windows without rebooting, unlike Vmware, it has very little performance penalty. with it you can do everything in linux under Windows, except for X.

The only thing to remind is the software is still in alpha and it might crash the computer, although for me it almost never crashed.