Category Archives: Timely

Ubuntu Oneiric: Final Touches

Note: A month ago I meant to write this article but experienced hardware issues. I wrote that in places that Oneiric was slow… I was wrong. Apologize for any inconvenience.

Here are some edits, additions, and subtractions that help complete the feel of the of Ubuntu’s 11.10 Oneiric desktop. Note that a couple modifications are made only for performance reasons for use with an older computer.

Installing

When installing Ubuntu, it is still recommended to do a clean (fresh) install of Ubuntu. Ubuntu/Debian engineers primarily focus resources on the install route therefore making it the recommended method.

Home folder on a dedicated partition

“How we work can be almost as important as what we do.”

Putting application preferences back together can be a lengthy process. A good work flow can dramatically improve productivity. Putting settings and documents on a dedicated partition will allow them to be easily built on from install to install. In Linux, configurations rarely ever cause problems. The Parted Magic Maintenance CD is a good tool to start with that can help with the process. More on how to do this can be found here.

When doing a clean install with a dedicated home partition, the partition needs to be defined during installation being sure to have it remain unformatted:

Tools

For future reference here is a package management helper script. It makes common package management related tasks easier to execute (and remember).

If planning to stick around with Linux, learn Vim. Vim is an excellent command line editor. Learning Vim can save time and be pleasurable to use (here to edit configuration files). More about Vim can be found here.

Hardware Setup

The first detail to focus on after installing Ubuntu is to get all hardware up and running. Ubuntu does good at discovering/setting up hardware but it isn’t able to do everything. First, the Additional Drivers control panel in System Settings may have hardware needed to be installed (some hardware setup requires user confirmation and is done here). After this, testing all devices and peripherals is recommended. It may in the end be necessary to visit the manufacturers website and download drivers. In most cases though to get the hardware working, information is usually available on the wiki.

Desktop Preferences

A number of options can be made to make a more efficient desktop; these programs will be needed to make the edits:

sudo apt-get install dconf-tools gconf-editor

Remove Unnecessary Startup Applications

To restore the ability to edit the Startup Applications do:

mkdir -p ~/.config/autostart
cd ~/.config/autostart
cp /etc/xdg/autostart/*.desktop .
sed -i "s/NoDisplay=true/NoDisplay=false/g" *.desktop

To save resources, select what is needed in Startup Applications. If not needed, Ubuntu One, Desktop Sharing, and Check Hardware Drivers can be removed. Removing Update Notifier too can save a good bit or resources if willing to update manually. To complete Update Notifier disabling:

dconf write /com/ubuntu/update-notifier/auto-launch false
sudo apt-get remove apt-xapian-index  # actually an old Synaptic plugin remnant

Launcher

The Launcher with a couple edits can become more able to streamline the workspace.

Disable Auto-hide:

To have the Launcher always visible (usually recommended) do:

dconf write /com/canonical/unity-2d/launcher/use-strut true

Remove Multiple Desktops/Workspaces:

Save space on the Launcher if not using the multiple desktops feature:

gconftool-2 -s /apps/metacity/general/num_workspaces --type int 1
sudo cp /usr/share/unity-2d/launcher/Launcher.qml{,.bck}
sudo sed -i '/items.appendModel(workspaces)/d' /usr/share/unity-2d/launcher/Launcher.qml

This edit is temporary and will need to be run again when the unity-2d-launcher package is updated.

Add Show Desktop:

The ability to show the desktop can be done with the Super + D keypress (thats usually the Windows key) but to have the icon available on the Launcher an Xorg server interface tool will be needed:

sudo apt-get install xdotool

Create the .desktop so it can be pinned to the launcher:

echo "[Desktop Entry]
Name=Show Desktop
Exec=xdotool key --delay 300 super+d
Icon=desktop
Terminal=false
Type=Application
StartupNotify=false" >>   ~/.local/share/applications/show-desktop.desktop

Open the file manager and drag the .desktop to the Launcher:

nautilus ~/.local/share/applications/

Numlock Enabled on Login

Because the numberpad exists on most keyboards and since it’s primary use is for doing calculations having the Numlock on by default is usually is the preferred option:

sudo apt-get install numlockx
sudo sed -i 's|^exit 0.*$|# Numlock enable\n[ -x /usr/bin/numlockx ] \&\& numlockx on\n\nexit 0|' /etc/rc.local

Turn Off Resume from Sleep Lock

More obstruction than protection for some the resume from sleep lock can be disabled:

gsettings set org.gnome.desktop.lockdown disable-lock-screen 'true'

File Manager Possibilities

Once the behavior is adapted to this feature can save time; however this behavior can be persistent: to streamline workflow consider using a single-click for files in the file manager/desktop. Set this in the File Manager under > Edit > Preferences > Behavior > Single click. For a slight speedup in the file manager, lower the preview values (Nautilus > Edit > Pref > Preview > No text icons, Thumbs for smaller file sizes, and Count number).

Application Indicators

Application indicators are the feedback icons in the menu bar on the top right. Here are some edits/considerations (changes to application indicators area don’t take effect until Logout/Login).

Switch Users Unneeded:

For single-user computer or if the feature is never used, save space by disabling the Switch Users indicator:

dconf write /apps/indicator-session/user-show-menu false

Google Web Mail:

Because of its’ efficient use of space and it’s connectivity possibilities the web interface of Google mail is preferred over email programs by a good number of people. There is an application indicator to notify of new Gmail email called gm-notify:

sudo apt-get install gm-notify

gm-notify can be configured additionally to play a sound when new mail arrives, check /usr/lib/libreoffice/basis3.4/share/gallery/sounds/curve.wav ia a possibility.

Other Indicators:

Additional application indicators can be found at Ask Ubuntu.

Laptop Touches

For regular laptop users the thought of limiting the touchpad from accidental scrolling and mouse click tapping is kept in the front of the mind. Consider using two-finger scrolling and disabling touchpad tapping instead.

Firefox Security

If on the Internet a lot, it’s a good idea to protect the application that primarily accesses it. There is a nice script written by Ignorant Guru that puts Firefox in a sandbox. To learn more read here. First install the PPA then install the script through the package manager:

sudo apt-get update
sudo apt-get install sandfox

The script is most productive in protecting from Adobe Flash security holes. A perk of the script is that it allows Flash preferences to be saved; a disadvantage is this allows a security hole. To plug the hole change the preference directories to read-only only by root:

cd ~
rm -rf .adobe .macromedia
sudo mkdir .adobe .macromedia
sudo chmod ugo-wx .adobe .macromedia

Then bind the folders read-only in the script:

sed -i 's_^hide=/home/\\$user/.adobe.*$_bindro=/home/\\$user/.adobe      # bind folder read-only_g' /usr/bin/sandfox
sed -i 's_^hide=/home/\\$user/.macromedia.*$_bindro=/home/\\$user/.macromedia # bind folder read-only_g' /usr/bin/sandfox

After this, the Sandfox package could be put on hold to prevent it from updating (thereby preserving changes made to the script):

echo sandfox hold | sudo dpkg --set-selections

Under the Hood

A few options on the system-level can help improve performance and help unexpected delays.

No Timestamping on File Access

Since Linuxs’ early days the kernel behavior has been to re-date a files’ timestamp every time a file is accessed. This reasoning goes back to its’ server days when users were more interested in knowing when a file was accessed rather then when it was edited (written to). For desktop users however the expected behavior is for the timestamp of a file to be when it was last edited. Tagging the option noatime to the filesystem will give the expected behavior, also this option additionally improves system performance by saving a number of writes to the disk. See more on this here.

Swap Value

For computers with plenty of memory available (1 Gigabyte will be enough for most uses), lowering swap priority can help improve performance. To change immediately do:

sudo sysctl -w vm.swappiness=20
sudo sysctl -w vm.vfs_cache_pressure=50

And to have it as this value used regularly add the values to /etc/sysctl.conf:

vm.swappiness=20
vm.vfs_cache_pressure=50

Match Filesystem Check Times

If more than one partition is used, having filesystem check times run at the same time will cause less number of unexpected boot delays. This can be done with tune2fs (Ubuntus’ default value is 33 mounts and six months):

sudo tune2fs -c 33 -C 0 -i 6m -T now /dev/partition1
sudo tune2fs -c 33 -C 0 -i 6m -T now /dev/partition2

Other Programs

Other useful programs are these (most are additional command line utilities that come in useful down the road):

sudo apt-get install cd-discid curl dos2unix dnsmasq epiphany-browser gdebi gimp gparted imagemagick inkscape iotop irssi lame librsvg2-bin links mp3gain msmtp openjdk-6-jre p7zip pdftk ppa-purge pwgen realpath ripit ruby tree unrar vim xclip

Vims is set up well as is, but to make it even better use a more-optioned configuration:

sudo mv /etc/vim/vimrc{,.bak}
sudo cp /usr/share/vim/vim73/vimrc_example.vim /etc/vim/vimrc

Being on the Internet a good deal a Domain Name Server address cache/query daemon can help a lot with improving web browser load times, particularly during busy hours (the NetworkManager connection will need to be re-established afterward for changes to take effect):

sudo sed -i 's:^#listen-address=:listen-address=127.0.0.1:g' /etc/dnsmasq.conf
sudo sed -i 's:^#prepend domain:prepend domain:' /etc/dhcp/dhclient.conf
sudo service dnsmasq restart

Extrenui

  • Missed Touchpad Button Clicks – fix for a touchpad button that missed clicks regularly.
  • Hosts File Help – Only really a good idea for aging computers that can’t process complex ad-laden webpages.
  • Root Required – If around Linux for a bit eventually the root account will have to be used. To work in a familiar environment when it root link common home settings: sudo ln -s ~/.{bashrc,profile,vimrc,vim} /root

Editors’ Opinion

I’m happy with my setup. Originally I had thought I’d go straight to Gnome 3 Fallback but I’ve stuck with Unity and I like the simplicity of it; plus it runs well. With a desktop setup like this, I’m beginning to feel productive. Thanks to Linux and Ubuntu engineers that made this possible.

Links

Random Tidbits

Today, I’ll be going over the jet and flotsam I’ve been thinking about lately. Since everybody’s desktop is extraordinarily unique in Linux so there should be something here for everyone :).

Gnome Smaller Icons

For a smaller screen like I got (800×600) having smaller icons helps save a good amount of screen real estate. I figured I wanted them about half the size they normally were. I was using Lxappearance which controls a few Gnome desktop attributes, but not the icon size unfortunately. Lxappearance writes to the gtk configuration file (~/.gtkrc-2.0) and is supposed to be able to inherit additional settings in (/home/user/.gtkrc-2.0-mine) which it wasn’t doing. Had to give up Lxappearance and just manually write to the (~/.gtkrc-2.0) file directly. By adding this I get nice appropriately felt sized icons:

gtk-icon-sizes="panel-menu=16,16:gtk-menu=16,16:panel=16,16:gtk-large-toolbar=16,16:gtk-small-toolbar=16,16"

Gentoo Quick Install

The last update to this installation guide was on April 2009, whether it is accurate still I can not say. Gentoo evolves gradually so for the most part it should be alright, best to use in reference with the Gentoo Handbook.

Installing Gentoo really is a breeze… once it has been done before. This guide is for installing Gentoo in a logical straight-forward manner. I have written everything generically, with necessary links for additional resource, look at the Gentoo Handbook from which this guide derives for more complex set-ups.

I choose to install from a LiveCD [1]. I choose not to use Gentoo’s Minimal Install CD because many distro CD’s create a nice desktop to work on and a web browser can be useful to look up any questions.

Partitioning

Just about any Live CD a person has/likes can be used to install Gentoo with. For beginners it helps if it contains Gparted, an easy tool to partition with. If it doesn’t consider using Gparted’s LiveCD [2] to first partition the drive.

For security purposes and for convenience, I’d recommend having a partition for the system (root “/“) and another for “/home” (aka the users partition).

Linux uses a considerable less amount of memory than Windows or Mac OS X. Users with memory of 2GB or more probably don’t need a swap partition. If you choose not to have a swap partition and need to use swap, a swap file can be created later [3].

Date

When done partitioning, restart and open the BIOS. Make sure the hardware clock is set to the right time, start the install disk and check the time in the terminal:

date

Possibly the installCD is using the UTC clock (Universal Time Clock – aka Greenwich Mean Time) for time and date and the clock will be skewed. This is not a problem. The correct settings will be entered on the new installation.

Network

Gentoo will likely detect your network card and setup your network. If it doesn’t try the configuration utility:

net-setup eth0

You can find the name of your network device with ‘ifconfig -a‘.

Remote Install (Optional)

Some people may want to use another computer to install Gentoo from. This can be handy if say the remote machine has a bigger screen or has notes on it you’d like to access.

Begin by starting sshd on the computer to be installed upon:

/etc/init.d/sshd start

How to start a daemon differs though per distribution. Give root a password on the machine to be installed on for security purposes:

passwd

Type “ifconfig” to find the internet address, then on the remote computer:

ssh -l root@address

Preparing the Storage Unit

Mount the system partition created for the system install:

mount /dev/devicename /mnt/gentoo && cd /mnt/gentoo

You can find out the partition you need to use with:

fdisk -l

(e.g. /dev/hda3, or /dev/sda4) are examples of what your partition may be named.

A stage3 tarball will be needed now. Stage3 tarballs are tools and a base system that contains just enough necessary to boot your system. Gentoo builds regular stage3 tarballs. You should find the newest on the mirror (contained in /releases/<architecture>/autobuilds and download it.

On the LiveCD the internet networking needs to be working. Learn how to do this (it probably already is) and copy DNS info over to the system that is being built so the network will work on it:

cp -L /etc/resolv.conf /mnt/gentoo/etc/

Mount /proc and /dev on the system being built:

mount -t proc none /mnt/gentoo/proc && mount -o bind /dev /mnt/gentoo/dev

Enter the new Gentoo environment by changing root:

chroot /mnt/gentoo /bin/bash
env-update && source /etc/profile && sleep 2 && export PS1="(chroot) $PS1"

Portage Configuration

The Portage Tree (the software-repository) will need to be downloaded, this is done by:

emerge –sync

Portage is the package installer for Gentoo. Gentoo does have some binary packages (packages pre-built) but mostly Gentoo is about compiling packages specific to your system.

For some reason Gentoo doesn’t add the portage configuration files:

mkdir /etc/portage
touch /etc/portage/package.keywords
touch /etc/portage/package.use
touch /etc/portage/package.mask
touch /etc/portage/package.unmask

Vim Default Editor (Optional)

I to do my editing with vim, why it’s not installed I don’t know.

emerge vim

Basic Settings – Add Timezone, Locales, Keymap

Add timezone

ls /usr/share/zoneinfo
ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime

Set Time Type

vim /etc/conf.d/hwclock # or
vim /etc/conf.d/clock

Set time type to “local” if dual-booting Windows or Mac OS =<9. Later we’ll add an NTP program the syncs the time on boot, so it might be a good idea to edit “clock_systohc” to “YES” to keep the hardware clock in sync with Network Time Protocol.

Don’t bother to look at “date” as the chroot still uses the CD settings. The effect won’t be seen until you boot into your Gentoo system.

Glibc Locales

Locales provide information on regional settings – money type, character maps… To see available locales look at:

vim /usr/share/i18n/SUPPORTED

Set locales in:

vim /etc/locale.gen

Enter your locale. Here’s and example of the United States local setting:

en_US ISO-8859-1
en_US.UTF-8 UTF-8

To generate locale, run “locale-gen” and “locale” to check if the correct locale is set.

Update environment:

env-update && source /etc/profile

Keyboard Layout for Console

vim /etc/conf.d/keymaps

Available keymaps are in /usr/share/keymaps.

Make Files

The make files are basic settings for the system being built. There is the “make.default” file that is the system profile for building a system. And there is the “make.conf” file – a user-controlled profile that contains hardware information, properties wanted in packages (USE flags), and adds to or overrides the “make.default” file.

A system profile link to “make.default” is set by default, make sure it is the correct one for the system:

ls -l /etc/make.profile

Link to the most appropriate system profile:

ln -sf /usr/portage/profiles/default/linux/<arch>/<gentoo-version-year>/<desktop|server…>

The “desktop” and “server” subdirectories are optional but provide more detailed settings.

Confirm the link is correct:

ls -l /etc/make.profile
… /etc/make.profile -> /usr/portage/profiles/default/linux/x86/<version>/

Make.conf

“Make.conf” sits on top of the system profile choosen, adding and over-riding those settings. The most important item to a successful Gentoo build is providing as complete a “make.conf” as possible.

vim /etc/make.conf

CHOST defines the basic architecture of the computer – 486,586,PPC… This is important to get right. It is alot of work and dangerous to try and fix this later in the build, research and be sure that it is right one.

CFLAGS are used to define the CPU architecture more specifically.

USE flags define options programs have that can be enabled or disabled. Try “emerge -pv gcc” to see available flags.

It is nice to install Gentoo and have a reference to USE flags. You can install “gentoolkit” and use equery to find out about USE flags per packages:

equery uses gcc

The ACCEPT_KEYWORDS variable defines what software branch to use on the system. In Gentoo, there is a stable branch for already tested software and an experimental branch. If user is willing to test more recent software, consider using the testing branch, but expect more time debugging problems. To have Portage use the testing branch, add a ~ in front of the architecture.

VIDEO_CARDS define video card type. This value will tell xorg-server what video card drivers to pull in, and what DRI to use for the X server. Also a video card DRM is required either by selecting it in the kernel, x11-drm package, or the driver may have support for it: e.g. nvidia, ati, intel video card… A few values are available.

INPUT_DEVICES tells xorg-server what basic devices are or will be connected. Items include keyboard, mouse, touchpad…

GENTOO_MIRRORS are used for syncing the portage tree. You can test and add the three fastest mirrors by:

mirrorselect -s3 -b10 -o -D >> /etc/make.conf

Beginning to Build

There will be a lot of compiling that can take several days to build on older computers. Portage is a well tested and complete compiling system and eases the process, but likely a few bugs will appear. A few tips:

Previous Versions

Occasionally during compiling errors can occur. If choosing to use the unstable branch, the newest updates and less tested programs come with it. If there is a problem compiling along the way, check Dibb’s Package Page and revert back to an older version to compile. Or you can install eix (run eix-sync to update database) and do a quick search with “eix <package>“.

Dependencies

Check the dependencies of a program to see if a dependency is causing the problem:

emerge -pv –tree <program>

Custom USE Flags per Package

Apply custom USE flags for packages (e.g. “media-sound/lame -gtk” removes the gtk dependencies of lame) and put in:

vim /etc/portage/package.use

Read the Developer’s Notes After Emerging Packages

When emerging finishes developers will often leave notes about the program. It may mean more time and work but it is usually a good idea to follow them.

If you miss a note, developer notes are recorded in:

vim /var/log/portage/elog/summary.log

Installing a Kernel

The kernel contains the information of almost all the hardware on the computer and how to run it.

If this is the first time working with a kernel, I’d recommend using the genkernel – a basic all types kernel that will run on most systems.

Otherwise the configuration can be done manually. Manual configuring the kernel can make for a slightly faster boot but isn’t necessary in most cases. Manual configuration can take a long time though and requires alot of research, begin by:

emerge gentoo-sources
cd /usr/src/linux

Make sure the “/usr/src/linux” link matches the downloaded kernel source[5]:

ls -la /usr/src/linux

Enter the directory and run “make menuconfig” to get to the kernel configuration editor.

A Few Tips for Configuring the Kernel

  • A good amount of details about the computer can be discovered with “lspci” (part of the “pciutils” package).
  • lsusb” can be useful for USB hardware (“lsusb” is part of the “usbutils” package).
  • It’s a good idea to build sound support into the kernel if you need it.
  • If unsure about an option, try adding it as a module – these can be specified to load or not load at boot time.
  • More information can be found on the kernel in the Gentoo Handbook.

When the kernel config file is finished, compile the kernel, the modules, and install them:

make clean bzImage modules modules_install install

Now the modules that were created need you need to specify which ones you need to boot.

find /lib/modules/ -type f -iname '*.o' -or -iname '*.ko'

Now add the ones needed to /etc/modules.conf. Gentoo hasn’t added OpenRC to it’s stage3 yet but that should happen soon. When that happens you’ll have to add modules to /etc/conf.d/modules. See the OpenRC migration guide for details.

Filesystem Information

The fstab file contains storage devices (drives and partitions), their mount points and any options that will mount at boot time. The “/etc/fstab” file must be edited manually with the storage units you plan to be use.

An example fstab file:

# /etc/fstab
# static file system details

# <file system> <mount point> <type> <options> <dump> <pass>
shm /dev/shm tmpfs nodev,nosuid,noexec 0 0
/dev/hda3 none swap sw 0 0
/dev/hda4 / ext3 noatime,defaults 0 1
/dev/cdrom /mnt/cdrom auto noauto,user 0 0

Unique device nodes (UUID’s) can be used too that can prevent possible device conflicts. Take a look at this.

Setup the “/etc/mtab” file here too. Usually the system discovers what filesystems are mounted and adds them to this file, but since this isn’t a full system yet, it needs to be created for your bootloader later:

grep -v rootfs /proc/mounts > /etc/mtab

Configuring the Network

Naming the pc is important so people on a network can recognize you. This is done with a hostname. A good practice is to name the computer <owner>-<machine> but people can name them anything – after famous philosophers, your favorite Gentoo developers… Open /etc/conf.d/hostname

HOSTNAME=”smith-dell”

Add the hostname boot script to run at startup:

rc-update add hostname default

Hostname will also need to be set in “/etc/hosts” so some programs can become aware of it:

127.0.0.1 smith-dell localhost

Setting a domainname is primarily used if the computer is to be server or if on a specialized network. Most people can ignore this setting.

Networking with DHCP

Most ISP’s (Internet Service Providers) use dhcp (network discovery) that makes setup easy.

Type “ifconfig” to see if your devices have been recognized. There should be a “lo” (loopback) device (necessary for some programs to access the network) a wired interface (eth0 is a common wired interface) and possibly a wireless interface (eth1, ath0…).

Any wired/wireless device will have to be linked to net.lo for the boot init system to recognize it.

ln -s /etc/init.d/net.lo /etc/init.d/net.eth0

Wait until reboot to see if the wired/wireless devices connect to the internet. Networks that require greater configuration can be done in “/etc/conf.d/net“, see the Gentoo Documentation links below.

Now the init script needs to be added to load at boot:

rc-update add net.eth0 default

Adding System Daemons and Tools

Daemons are constantly running programs that provide necessary services. Each service is listed below, or for ease of install, with one command:

emerge sysklogd vixie-cron slocate ntp acpid \
&& rc-update add sysklogd default && \
rc-update add vixie-cron default && && rc-update add acpid default \
&& rc-update add ntp-client default

The System Logger logs many events (good for debugging problems):

emerge sysklogd && rc-update add sysklogd default

Cron Daemon schedules programs to run at a certain times.

emerge vixie-cron && rc-update add vixie-cron default

Indexing Files for quick searches, use slocate to index files:

emerge slocate

ACPI (Advanced Configuration and Power Interface) is used by most modern computers for power saving, suspend…

emerge acpid && rc-update add acpid default

NTP client (Network Time Protocol) keeps the computer in sync with an internet time server.

emerge ntp && rc-update add ntp-client default

File System Tools, if using another file system beside ext2/3, you’ll need their tools – xfsprogs, reiserfsprogs, jfsutils.

Check out what boot scripts are to load to be sure you got them all:

rc-update show

Adding Password and User

Root doesn’t have a password yet, so give it one and also create a new user.

passwd

If you need to create a regular user (not root) and you made a home partition (/home) partition, it needs to be mounted now [4]:

mount /dev/devicename /home

Now add a new user. Groups give the user permission to do certain tasks. Add a user to the wheel group to allow the user to ‘su’ to root. Other programs you add later may require you add a group to gain certian permissions (a developer note will usually tell you when you have to do this).

useradd -m -G adm,audio,cdrom,cdrw,cron,portage,users,usb,video,wheel -s /bin/bash USER
passwd USER

Warning: For the install, root user is being used for installing but besides this process it is not a good idea to log in as root. Login as regular user and use ’su‘ to log into root when you need administrative priveledges.

Configuring the Bootloader

A boot loader is required to load Linux. The boot loader should almost always be installed in the Master Boot Record (the first 512k of the disk – not partition). The MBR defines partitions, partition types, labels, whether it’s bootable… Getting this right is very important. Grub is the preferred bootloader, installing makes it the default system bootloader and will boot both Windows and Linux.

Grub nomenclature is different for devices. The first disk it recognizes is called “hd0“, the first partition it sees is “0” So the Linux root partition located on the first hard drive on the first partition, is labeled “hd0,0“.

First, the Grub configuration file (/boot/grub/grub.conf) needs to be created manually:

Here’s a sample grub configuration file:

# /boot/grub/grub.conf

# Default system to boot, 0 is first,…
default=0
# Timeout to wait before automatic loading of default system
timeout=10

title Gentoo Linux 2.6.27-r1
root (hd0,4)
kernel /boot/kernel-2.6.27 root=/dev/sda5

title Gentoo Linux 2.6.27 (Rescue)
root (hd0,4)
kernel /boot/kernel-2.6.27 root=/dev/sda5 init=/bin/bb

title Microsoft Windows Vista
rootnoverify (hd0,1)
makeactive
chainloader +1

Grub also looks for kernel images relatively. So if a person has created a separate /boot partition the correct path would be “kernel-2.6.27” instead of “/boot/kernel-2.6.27“.

The only require fields are default, timeout, title, root and kernel. You can also add password protection to the Grub, see Grub Password-Protection.

When done writing the grub file, create a link to it called menu.lst (this is required because grub looks for this file):

ln -sn /boot/grub/grub.conf /boot/grub/menu.lst

Install Grub the Easy Way

Grub developers recommend using “grub-install“, this usually works. If it doesn’t you’ll have to install grub manually.

grub-install –no-floppy /dev/devicename

“devincename” needs to be the hard disk your are installing Gentoo on. Often devicenames are “hda”, or “sda”. Grub needs to be installed at the beginning of the disk drive, not the partition.

Install Grub Manually

grub # Enters Grub shell
root (hd0,2) # Define where the “/” (aka root partition) lies”
setup (hd0) # Install Grub to the MBR
quit

Reboot

Now that your basic system is set up. Its a good time to see if it’s installed correctly. We’ll exit chroot here and umount the partitions:

exit && cd /
umount /mnt/gentoo/home /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo

Reboot (command is ‘reboot‘) and test the new system.

After you see if it boots to a command prompt, I’d recommend rebooting back into the LiveCD, chrooting again, and building from there so you have a browser… to work with.

Final Touches

Now you should update everything. Even though the stage3 is fairly new a good number of changes may have been made already. You can update everything with:

emerge –update –newuse –deep world

With everything installed, now check that all library links meet their dependencies in case any breaks occured during the build (requires gentoolkit):

revdep-rebuild

Now you can continue with the Gentoo documentation if for say you want to install a desktop.

For more on managing Gentoo take a look at Gentoo Linux Tidbits.

Troubleshooting and Notes

[1] If a distro CD refuses to boot, trying burning it to a DVD. Some BIOS’s have trouble with Linux CD’s.

[2] If Gparted makes a Windows install unbootable read Recovering Windows Boot

[3] If needing to use swap later a swapfile can be created:

dd if=/dev/zero of=/swapfile bs=1024 count=2097152
mkswap /swapfile
swapon /swapfile

[4] These two warnings will occur when there is no “/home” partition mounted before adding a new user (i.e. a “/home/user” folder beneath the “/home” partition”):

xauth: timeout in locking authority file
No directory, logging in with HOME=/

[5] With numerous kernel-sources, link “/usr/src/linux” is best done by:

eselect kernel list
eselect kernel set <no.>

One More KDE 4 Gmail Checker

Not so far back, I was attempting to cope without a mail notification program on my KDE 4 destkop and not doing so well about it. There are plenty mail notification applets available on Linux most are for Gnome though and they pulled in alot of dependencies (mail-notification , gnubiff, checkgmail-notify-osd). For KDE a couple plasmoids exist (gx-mail-notify, emailnotify). I like both of these, particularly gx-mail-notify (the later though I found to be buggy). I also thought about kbiff from KDE 3 but it doesn’t look like it’s going to be updated to KDE 4. I’d been using KCheckGmail but somehow, someway, it broke recently. Yeah, I tried replacing the plasmarcs and recreating KCheckGmails’ configuration file but got nothing. Besides re-building all my KDE configurations again (~/.kde4) (which I’m not going to do [but does work when I created a new user]) I was up the creek. Luckily though I stumbled upon KGmailNotifier when I was on KDE apps. Marcel has taken KGmailNotifier just recently and updated it to KDE 4. The first thing I noticed is that KGmailNotifier doesn’t use the KDE 4 notification system and instead uses it’s own built-in popup. The effect is nice and has a nice display though I found that sometimes it will miss a mouse click. Beside that is a nice application. Both KCheckGmail and KGmailNotifier offer about the same functionality so I could go either way. For now I’m happy that I got my mail notifications back. Thanks for your work marcel.

plasmabac – When plasma solidifys.

Plasma being a new technology for KDE it can still, at times, behave like a bad child. Alot of you may have noticed that plasma from time to time will have the tendency to cause the desktop to freeze or crash. This usually happens with widgets that have bugs in them or if there are errors in the plasma configuration files. Instead of losing all my plasma configurations anytime plasma goes rogue, I’ve made it a routine to back them up regularly. I decided to build a script that can backup the current plasma configs and then automate it to run once a week. The script will both backup and restore:

plasmabac b
plasmabac r

When you choose to restore, it will give you a list of saved plasma configs by date:

plasmabac r
 0) plasmarcs-2009-10-13.tar.gz
 1) plasmarcs-2009-10-18.tar.gz
 2) plasmarcs-2009-10-23.tar.gz
 3) plasmarcs-2009-10-24.tar.gz
 4) plasmarcs-2009-10-25.tar.gz
 5) plasmarcs-2009-10-29.tar.gz
 6) plasmarcs-2009-11-01.tar.gz
 7) plasmarcs-2009-11-02.tar.gz
Choose the plasma configuration to restore: 

To backup on a weekly basis, add it to the cron jobs:

  57  00  *   *   0       ~/.bin/root/backup/plasmabac b    # w - plsm cnfgs
# |   |   |   |   |   user
# |   |   |   |   weekday (0-6) (Sunday=0)
# |   |   |   month (1-12)
# |   |   day (0-31)
# |   hour (0-23)
# minute (0-59)

The script will automaticaly delete configurations older than two months to prevent overflow.

Enjoy :)

#!/bin/bash
# plasmabac - backup and restore local plasma config

backdir=/opt/backup/pc-emach/kde4-plasma-rcs
userdir=/home/gen2ly

# Use filename as program name
prog=${0##*/}

# Text color variables
txtbld=$(tput bold)       # bold
txtund=$(tput sgr 0 1)    # underline
bldblu='\e[1;34m'         # blue
bldred='\e[1;31m'         # red
bldwht='\e[1;37m'         # white
txtrst='\e[0m'            # text reset
info=${bldwht}*${txtrst}
pass=${bldblu}*${txtrst}
warn=${bldred}!${txtrst}

plasmarcs=($(find "$userdir"/.kde4/share/config -type f -name "plasma*"))
bkpplasmarcs=($(find "$backdir" -type f -name "plasma*" | sort))
date=$(date +%F)

# Display usage if full argument isn't given
if [[ -z "$@" ]]; then
  echo " $prog b|r - backup or restore plasma configurations"
  exit
fi

# Check if the directory exists and user has access to it
if [[ -n $(ls "$backdir" 2>&1 | grep denied) ]]; then
  echo -e "$warn User doesn't have access to the backup directory"
  exit
  else
  if [[ ! -d "$backdir" ]]; then
    mkdir "$backdir"
    echo -e "${bldblu}*${txtrst} KDE 4 plasma config backup directory doesn't exist.  Created."
  fi
fi

# Delete backups older than two months
if [[ -n "$(find "$backdir" -mtime +60)" ]]; then
  find "$backdir" -mtime +60 -exec rm {} \;
  echo -e "$pass Configurations older than two months deleted"
fi

case $1 in
  b | backup )  tar -czpf "$backdir"/plasmarcs-"$date".tar.gz ${plasmarcs[@]}
                echo -e "$pass Plasma configurations backed up. (${bldwht}$date${txtrst})"
                ;;
  r | restore ) for((i=0;i<${#bkpplasmarcs[@]};i++)) ; do
                  echo -e " ${txtbld}${i}) ${bkpplasmarcs[$i]##*/}${txtrst}"
                done
                echo -n "Choose the plasma configuration to restore: "
                read restore
                selection="${bkpplasmarcs[$restore]}"
                tar -xvf "$selection" -C /
                echo -e "$pass Restored plasma configs: ${txtbld}${bkpplasmarcs[$restore]##*/}${txtrst}"
                ;;
esac

Mplayer as default DVD player in KDE 4

I got a thing for MPlayer. There’s a good number of video players in Linux but the simplicity of MPlayer has always made it what I like to use. I like to use MPlayer without the GUI because once I learned the keybindings it makes for fast and bare-bones video player (to learn a little more about setting up MPlayer settings, look at this page). To be able have MPlayer as your default video player in KDE 4 you’ll have to do change mime associations and add MPlayer to the ‘Open with’ dialog.

Changing mime Associations

If you install MPlayer with a GUI, you can skip this step because it should install an icon and .desktop file (file for displaying in the Application menu and listing associated file types). If you install MPlayer without a GUI, likely it will not have one. Here’s a ‘mplayer.desktop’ file you can use:

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=MPlayer
GenericName=Multimedia player
Comment=Multimedia player
Comment[de]=Multimedia-Player
Comment[es]=Reproductor multimedia
Comment[fr]=Lecteur multimédia
Comment[it]=Lettore multimediale
Icon=/home/todd/.local/share/pixmaps/mplayer.svg
Exec=mplayer %F
Terminal=false
Categories=AudioVideo;Audio;Video;Player;TV;
MimeType=application/ogg;application/ram;application/sdp;application/smil;application/vnd.rn-realmedia;application/x-extension-m4a;application/x-extension-mp4;application/x-flac;application/x-flash-video;application/x-matroska;application/x-netshow-channel;application/x-ogg;application/x-quicktime-media-link;application/x-quicktimeplayer;application/x-shorten;application/x-smil;application/xspf+xml;audio/3gpp;audio/ac3;audio/AMR;audio/AMR-WB;audio/basic;audio/midi;audio/mp4;audio/mpeg;audio/mpegurl;audio/ogg;audio/vnd.rn-realaudio;audio/x-ape;audio/x-flac;audio/x-it;audio/x-m4a;audio/x-matroska;audio/x-mod;audio/x-mp3;audio/x-mpeg;audio/x-mpegurl;audio/x-ms-asf;audio/x-ms-asx;audio/x-ms-wax;audio/x-ms-wma;audio/x-musepack;audio/x-pn-aiff;audio/x-pn-au;audio/x-pn-realaudio;audio/x-pn-realaudio-plugin;audio/x-pn-wav;audio/x-pn-windows-acm;audio/x-realaudio;audio/x-real-audio;audio/x-sbc;audio/x-scpls;audio/x-tta;audio/x-wav;audio/x-wavpack;audio/x-vorbis;audio/x-xm;image/vnd.rn-realpix;image/x-pict;misc/ultravox;text/google-video-pointer;text/x-google-video-pointer;video/3gpp;video/dv;video/fli;video/flv;video/mp4;video/mp4v-es;video/mpeg;video/msvideo;video/quicktime;video/vivo;video/vnd.divx;video/vnd.rn-realvideo;video/vnd.vivo;video/x-anim;video/x-avi;video/x-flc;video/x-fli;video/x-flic;video/x-m4v;video/x-matroska;video/x-mpeg;video/x-ms-asf;video/x-msvideo;video/x-ms-wm;video/x-ms-wmv;video/x-ms-wmx;video/x-ms-wvx;video/x-nsv;video/x-ogm+ogg;video/x-theora+ogg;

Place this file in the application menu folder:

mv mplayer.desktop ~/.local/share/applications/

And the icon that goes with it:

mplayer icon

mv mplayer.svg ~/.local/share/pixmaps

Open ‘System Settings’ (or whatever your distribution calls it), click on the Advanced tab and choose File Associations. Then select video in ‘Known types’. Go through videos you’d like MPlayer to open as default and place MPlayer at the top of the list then ‘Apply’. Note, you may have to wait a minute after doing the previous action before the mime types get registered. Now videos that you have saved on you hard drive can be clicked and loaded with MPlayer.

Mplayer in ‘Open with’ Dialog

Adding to Device Actions in System Settings

It may be faster and quicker to copy and paste the configuration file I post in the next step. I put this method up is case you want to learn how to add and configure special device actions.

Open ‘System Settings’ and go to the Advanced tab and click on Device Actions. ‘Add’ a new action named ‘MPlayer’. Add a new action like: ‘mplayer dvdnav://’. Most distributions compile MPlayer with DVD navigation now so this should work. Remove ‘The device must be of the type Storage Volume’ and ‘The devices property Storage.Volume.ignored must equal false’ properties. Select ‘All of the contained conditions must match’ then click ‘Add’.

  Requirement type: Contains Other Requirements
  Requirement type: Is A Requirement

Select ‘All of the contained conditions must match’ then ‘Add':

  Requirement type: Is A Requirement
  Restriction type: Compare Value To
  Device type:      Storage Volume
  Value name:       Ignored
  Equals:           false

Add another to ‘All of the contained conditions must match’ and add this to recognize you DVD disk:

  Requirement type: Is A Requirement
  Restriction type: Compare Value To
  Device type:      Optical Disk
  Value name:       Avaliable Content
  Equals:           'Data|VideoDvd'

Save the configuration and you should see the ‘Open with’ dialog display MPlayer. For me this didn’t though and I ended up creating the configuration manually and only then did it show up after I rebooted. Rebooting should be necessary though and likely this step would have worked if I had just logged out and back in again. I had been playing with the configuration a bit before I learned how to do this and likely this is a bug in system settings. If this doesn’t work for you look at the alternative below.

Using a Pre-made Configuration

Use this pre-built configuration if you don’t want to do the above and put it in the right directory to have MPlayer appear in the ‘Open with’ dialog:

[Desktop Entry]
X-KDE-Solid-Predicate=[[ StorageVolume.ignored == false AND OpticalDisc.availableContent == 'Data|VideoDvd' ] OR [ StorageVolume.ignored == false AND OpticalDisc.availableContent == 'Data|VideoDvd' ]]
Type=Service
Actions=open;

[Desktop Action open]
Name=Open with Video Player (Mplayer)
Exec=mplayer dvdnav://
Icon=/home/todd/.local/share/pixmaps/mplayer.svg

Now move it to the right directory:

cp Mplayer.desktop ~/.kde4/share/apps/solid/actions/Mplayer.desktop

Again, you may have to login/logout before it becomes available (reboot worked for me but shouldn’t be necessary).

And you should be good. Enjoy MPlayer!

Chromium test (two days without Firefox)

With Firefox becoming fully-fledged, I wasn’t on the look-out to try another browser. Firefox is a well-done application for all it has to do. I can’t say I’m a complete friend of Firefox as the two huge security exploits in the last year will always keep me a bit leary. IMHO, something so predominantly geared on the internet can’t have these types of ommisions. But like good friends we learn to forgive and move on, and Firefox seems to have patched our ways.

When people began doing the “OMG Chrome” thing, I held short, but not because Google has never betrayed my trust (as for as my knowledge goes). For such a influential and in-position company, this begets me a tremendous respect. As one former execuative of AIG said though, “We just got too big.” And it’s true, one bad grape taints the wine. Perhaps I’m just too paranoid, but I didn’t want to touch the thing until I knew that hax0rhig didn’t come tromping into my living room. Curiousity, however, creeped in short of my expectations and I have been taken quick glimpses of Chromium the last two months. And, in this time, Chromium has made some some good gains.

It’s a bit too early to make comparisons, Chromium may not even be considered beta yet by the developers. But lately a lot of pieces have come together to make Chromium closer to becoming an everyday browser. For example, it’s gotten proper font rendering, all the options work now, and (as far as I tested) it no longer hangs. I was interesting in seeing if Chromium could be used two days as my regular browser.

The first thing I’ll say (like everybody else) is that it is fast. Now having a 64bit Firefox with tracemonkey I can see what they mean when they say how much of an improvement faster javascript rendering makes. I did a sunspider test on the new Firefox and got 1600 score. Running the same test with Chromium got me a 1200 score. This may look like a pretty big difference but in reality I couldn’t really tell. On espn, gmail, wordpress dashboard, load times were about the same. Possibly because they are both really fast, and possibly Firefox’s Gecko rendering engine is a little faster with HTML than Webkit is. Not sure.

One of most apparent difficulties I had with Chromium was that it has no setting for minimum font size. I found alot of sites that still like to use pixel size font settings (oh, Arial 8, we love you), so that at times I’d get very large fonts while other fonts had me rocking forward to be able to read them. Not sure this will be fixed anytime soon either as (if I remember right) the news Windows version didn’t have this feature either. Though some fonts may have been small, overall they were a more clear to read. Firefox has some built-in font rendering which isn’t bad but somehow it conflicts with my fontconfig settings and the fonts look a little bit worse than they do in other applications.

Chromium also does good on screen real-estate. The address bar that can also do searchs is a great idea in keeping things simple. I found it’s history search to be not as good as Firefox’s at finding the most used addresses but possibly this is because it imported Firefox’s and didn’t have the statistics about how often they were used.

I think Google is going to have to look at layout though. Chrom(e|ium) uses a new tab to get easily to a new page if you don’t want to use the address bar (or don’t know the address). In the new tab are nice thumbnails of commonly used sites and a bookmark bar on top. But I often found myself wanting to get to a bookmark from an already opened page which required a couple extra steps. I’d also like to see the title bar come back. Currently the title only shows on the tab and a good portion of it can’t be read.

Firefox does better with it’s find search. Why Google didn’t implement the ‘/’ I haven’t figured out yet. Firefox’s extensions though may make it the most popular browser out there. I don’t use many of them myself (NoScript, theme, Dictionary) but realize they might be the main reason Firefox is getting more popular. Besides that though, I’d say these two browsers are about equivicable at least in functionality. I didn’t get to test every site I commonly visit but on a couple sites Chromium does shows that it doesn’t have quite as good of flawed HTML/CSS fixing as Firefox does. But for the most part browsing was comfortable and felt like it did in Firefox. I don’t plan on leaving Firefox (there’s really no reason to), but with as far as Chrome has come so far, it’s be interesting to see where Chrom(e|ium) is in a year or two.

Firefox 64bit with tracemonkey and OSS

HeaderHa, I feel somewhat vidicated. Not me really (I know it’s the work of Firefox and Linux developers) but, hey, I’ll take it. You see, when Firefox 3.5 came out I was rapidly shot down when I learned that tracemonkey wasn’t ready for x86_64 yet. On one of the Firefox development blogs a decent number of Linux users got together and essentially said, “WT?”? I put my voice out too but the developers told us that tracemonkey was developed for 32bit because that is what most people use. Chromium was this way too, but since it was alpha at the time, I wasn’t too concerned about it. Firefox though, I thought, was trying to be a more unified build. Since architectures are going 64bit and since Firefox had been boosting about tracemonkey for the last six months, I was a bit surprised they hadn’t give us any warnings.

Tracemonkey is something I definitely wanted to try out. I wanted to try it, not because I thought webpages were that slow, but because (admittedly) I’m a speed freak and thought the speed gain would be nice. With so much extra getting added to pages the last year, I just learned to deal with slower loading speeds. Not big delays, but the superfluous stuff I see on some webpages makes me want to go back to the Firefox 2 days. The good news now is that Firefox 3.7 (alpha pre 1) now has tracemonkey 64bit support. I hadn’t really thought that a web page would load that much quicker with with a new javascript engine, with flash, ads… packed into pages, I didn’t expect much. But after I got done compiling all I can say is “Damn”. Pages that were jerky at first (espn, wordpress dashboard, stack overflow…) load considerably faster now. This doesn’t effect most pages, but the java centric pages see a good effect.

I also compiled in OSS support because OSS is just awesome. Alsa isn’t bad, but it hitches upon startup of any app, and has never been that responsive (even with a proper asound.conf). Yeah it’s good for compatibility, but to me a sound system should just run and run quietly underneath. I do love my OSS. I’m guessing that some people are asking, “Why build with OSS support?” Yes, flash works just fine with OSS (in fact, it uses OSS which most people run through alsa emulation) but for .ogv files (the new html5 video) alsa is fixed in Firefox. I’m not sure, but I can’t think of anything else in Firefox the built-in alsa might do. I ran through a couple html5 videos and they did pretty good. Really beginning to like this html 5 video thing.

To try it out, take a look at the firefox-pgo-beta AUR files and the edited PKGBUILD. Profiled build (pgo) is disabled in this version (to build correctly) but hopefully this is something that can be fixed in the future. I’ve been using FF3.7ap1 for the last day and it’s been running without any problems so far.

I’d like to thank the Firefox devs for their good work, and blasse and toxygen who did a great job for creating the package files.

movietime – Stop Powersaving to Watch a Movie

Getting down to watching you favorite movie on your computer? Start the movie, sit down, grab your snack and ten or so minutes later the screen goes blank. This happens in Linux because the desktop has built-in defaults for display power management (DPMS) and screensaving. Timeout settings can vary from distribution to distribution but they all got them. Here’s a basic script that can toggle DPMS and screensaving on and off.

Xorg Server Settings

You can set the values of blank, standby, suspend, and off in the the xorg server configuration file. The defaults are: 15, 20, 30, and 40 minutes. Personally I like to set these to better match how I use my computer:

Section "Monitor"
  Identifier  "Monitor0"
  Option      "DPMS"    "true"  # display power management on (true/false)
EndSection

Section "ServerFlags"
  Option "BlankTime"    "13"    # LED still on, no + (0 disables)
  Option "StandbyTime"  "15"    # turns off LED
  Option "SuspendTime"  "0"     # turns off LED, and most power
  Option "OffTime"      "50"    # turns off all power
EndSection

BlankTime is just a cheap screensaver and only real use for me is to tell me that I forgot to disable dpms while watching a movie. Doing this saves me a few seconds that StandbyTime requires to turn on the display again. SuspendTime and StandbyTime are nearly the same thing so I don’t bother setting SuspendTime.

Movietime

Here’s movietime. Movietime should work with just about any type of desktop environment (at least any system with dbus installed which really all of them do). If you aren’t familiar with having your own scripts and how to run them, take a look at this page).

#!/bin/bash
# movietime - disables power savings to watch movies.

# Movietime options
#  Resume time - resume normal display pm and suspend after set time.
# 0 = disabled, time in minutes
resumetime=0
if [ $resumetime = 0 ]; then 
  resumetime=1440 # Re-enable resume after a full day
fi

# Check that values for 'resumetime' are numbers
if [ $(echo $resumetime | sed 's/^[-+0-9][0-9]*//' | wc -c) != 1 ]; then
  echo "$warn variable 'resumetime' is not a number.  Exiting."
  exit
fi

# Name of suspend script
tmploc="/tmp"
suspinhscript="$tmploc"/"movietime-suspend-inhibit"

# Program name from it's filename.
prog=${0##*/}

# Text color variables
txtund=$(tput sgr 0 1)          # Underline
txtbld=$(tput bold)             # Bold
bldblu=${txtbld}$(tput setaf 4) #  blue
bldwht=${txtbld}$(tput setaf 7) #  white
bldred=${txtbld}$(tput setaf 1) #  red
txtrst=$(tput sgr0)             # Reset
info=${bldwht}*${txtrst}        # Feedback
pass=${bldblu}*${txtrst}
warn=${bldred}*${txtrst}

# Check that Xorg server is running
if [[ -z $(ps aux | grep /usr/bin/X) ]]; then
  echo "$warn The Xorg server is not running."
  exit
fi

# Check if user is regular user
if [ $(whoami) == "root" ]; then
  echo "$warn You are the root user, must be a regular user."
  exit
fi

# Current DPMS times (in minutes)
dispdpms=$(xset -q | grep "DPMS is" | awk '{ printf $3 }') # Enab. or Disb.
dispstand=$(xset -q | grep "^  Standby: " | awk '{ printf $2/60 }')
dispsusp=$(xset -q | grep "^  Standby: " | awk '{ printf $4/60 }')
dispoff=$(xset -q | grep "^  Standby: " | awk '{ printf $6/60 }')
dispblank=$(xset -q | grep "^  timeout:  " | awk '{ printf $2/60 }')

# Resume time in hours
resumetimehr=$(echo "scale=1;${resumetime}/60" | bc)

# Display help
case $1 in
  -h | --help | h | help )
    # Help message.
    echo
    echo "  $prog disables screen blanking and screensaver to allow viewing a video.  Running the program again will enable them.  If the 'resumetime' variable is set after that time $prog will resume normal powersaving values." | fmt -c -w 76
    echo

    # Display current values of power management and movietime.
    suspinhtest=$(ps aux | grep -v grep | grep $suspinhscript)
    suspinhval=$([ -n "$suspinhtest" ] && echo "Disabled" || echo "Desktop settings")
    
    # DPMS disabled information
    echo "   ${txtbld}Current settings ${txtrst}(in minutes, 0 = disabled):"
    if [[ "$dispdpms" == "Disabled" ]]; then
      echo "   DPMS:         $dispdpms"
      echo "   Suspend:      $suspinhval"
    fi

    # DPMS enabled information
    if [[ "$dispdpms" == "Enabled" ]]; then
      echo "   DPMS:         $dispdpms"
      echo "   DPMS times:   Blank: ${dispblank}; Standby: ${dispstand}; Suspend: ${dispsusp}; Offtime: ${dispoff}"
      echo "   Suspend:      $suspinhval"
    fi
    echo
    echo "   ${txtbld}$prog settings${txtrst}:"
    echo "   Resume after: $resumetimehr hours"
    echo
    exit
    ;;
  [a-g,i-z,A-G,I-Z,0-9,-]* )
    echo " Use '-h' for help"
    exit
    ;;
esac

# Suspend inhibit script (must be run as seperate process)
suspinhibit () {
    echo '#!/bin/bash
    for time in $(seq 1 '$resumetime'); do
    # Simulate user activity every minute
    dbus-send --print-reply --type=method_call --dest=org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSaver.SimulateUserActivity
    sleep 60
    done'
}

# Toggle powersaving
if [[ "$dispdpms" == "Enabled" ]] && [ -z "$suspinhtest" ]; then
  # Disable blanking, screen power saving
  xset s off; xset -dpms
  # Create script in tmp
  suspinhibit > "$suspinhscript"
  # Make script executable
  chmod u+x "$suspinhscript"
  # Run script
  nohup "$suspinhscript" &> /dev/null &
  echo "$pass $prog started, powersaving disabled."
else
  # Enable blanking, screen power saving
  xset s on; xset +dpms
  # Kill script
  if [ -n $suspinhtest ]; then
    echo "$info $prog stopped, powersaving enabled."
    kill -s 9 $(pgrep movietime-susp) &> /dev/null
  fi
fi

Turn off all cellphones and enjoy the show!

Improve flash performance (a bit, maybe)

Header

I’ve been struggling with flash quite a bit. I like to watch flash videos online because the time I’m able to get to them are usually at odd times of the day. The issue with flash (I’m using the 64bit alpha but think this effects other versions too) is that higher definition flash can often become choppy, and tear – particularly in fullscreen. I read that this has to do with how flash uses Xvideo. I’ve tried numerous hacks I’ve seen around but none that have worked. Flash 64bit alpha has been around coming on 10 months now so hopefully we’ll see an update soon, but until then I did find something that might improve your flash performance a bit. This I found while going through the Ubuntu forums – (thanks to Labello who figured it out). This is just a simple xorg server edit that may on some systems be already enabled. Flash appears to require a couple options that some xorg.confs may not provide. To give an idea on performance, 1080 flash video before was unwatchable sometimes giving me as low as 1 frame every five seconds and 720 video would tear at times. With the edit, low motion 1080 video (yeah I know) like Law and Order is mostly tolerable and 720 is playing without a problem. To get these benefits (will vary from system to system) be sure that these settings are in your xorg.conf and then restart the xorg server.

Section "Extensions"
  Option      "Composite"     "Enable" # for 3D, alpha desktop effects
EndSection

Section "DRI"
  Mode 0666                            # helps flash performance
EndSection

There’s also an edit on the link about overriding gpu checks. I think that this may help a bit, but it could just be my imagination :), not sure.

Update: For KDE 4 users as of 08-10-2009 QT’s glib support can cause some hang on videos. Either put in your ~/.bashrc or run this before you start you browser should be able to help flash performance:

export QT_NO_GLIB=1

Customizable LiveUSB

If you ever have an emergency and need a rescue disk to recover your Linux install, or maybe you just want to brag to your friends there’s some good LiveCD/USB’s out there and many distro’s now make LiveUSB install images, but it is also possible to create your own customizable LiveUSB. Hey, if you’re willing to put the time in, you can have a portable Linux in your pocket.

There’s alot of articles about creating your own custom CD/LiveUSB but many of them seemed dramatic involving messing with things like syslinux… Plus many of these create a fixed image, meaning that once it’s on your USB it can’t be changed. But having a customizable Linux on a USB flashdrive isn’t that difficult – just install Linux to the USB drive.

Partition the USB Drive

The first thing you’ll need is at least a 2GB flash drive. Anything less and you better plan a real basic install. First thing you might like to do is partition the flash drive. This isn’t necessary but I was pretty sure I wouldn’t need the 4GB for what I needed so I partitioned the flash drive to have a 1GB FAT32 partition first (so that Vista can see any files I put on it) then I partitioned the remaining 3GB as ext4 with kparted (there’s also gparted for gnome users).

Install via VirtualBox

No need to burn an ISO and reboot, use VirtualBox and do it from your desktop. You can follow my Testdrive a LiveCD with VirtualBox post to getting VirtualBox setup. I personally used Arch Linux for this install because it’s easy to configure, Gentoo should work well too, and Ubuntu looks to be easy.

Note: At the time VirtualBox does not have 64bit capabilities. If you want to install a 64bit Linux on your flash drive best to boot a LiveCD and follow these instruction from there.

Make sure your user is part of the VirtualBox group to enable usb recognition:

sudo gpasswd -a <username> vboxusers

Boot the LiveCD/USB iso/img in VirtualBox then in Devices > USB devices select your flash drive. Now the installer will recognize your flash drive. Proceed to install the distro on the flash drive. If you partitioned beforehand you can skip partitioning and go to setting Filesystem Mountpoints. When you reach GRUB setup be sure to install GRUB on the flash drive itself, for me it was /dev/sdb. Be sure NOT to install GRUB to a partition, it should be at the beginning of the drive.

Fix Grub

Because your BIOS is likely setup to recognize your hard drive before your USB drive you get drive denominations like /dev/sda for your hard disk and /dev/sdb for your flash drive on regular bootup. If booting from a flash drive, many BIOS’s have you enter a key (mine is F10) to get to a Boot Menu. So when you select your flash drive in your BIOS Boot Menu your flash drive now becomes /dev/sda, hard drive /dev/sdb. In grub terminology this is hd0 and hd1. Most BIOS’s are like this (though there a few exceptions). To know for sure you won’t be able to detect this until you try and boot your flash drive (more below).

Close VirtualBox and open your GRUB menu list and change to the first recognized drive:

sudo mount /dev/sdb2 /mnt/usb
sudo vim /mnt/usb/boot/grub/menu.lst

or however you edit your system files. Then change:

# (0) Arch Linux
title  Arch Linux
root   (hd1,1)
kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/34393cdf-9f39-431e-88c8-ea89a2518c83 ro
initrd /boot/kernel26.img

to:

# (0) Arch Linux
title  Arch Linux
root   (hd0,1)
kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/34393cdf-9f39-431e-88c8-ea89a2518c83 ro
initrd /boot/kernel26.img

The (hd0,1) value denotes the partition number, again starting with 0. So this denotation tells GRUB the root filesystem is on the first drive, second partition.

Arch-specific Details (Mostly)

If you already did the configuration for your hard disk, you should be able to copy most the configuation files over to the flash drive (rc.conf, mirrorlist, modprobe.conf, local.conf…) and then install xorg, xfce4… by chrooting in. This is my chroot script:

#!/bin/bash
# chrootmount - change root to current directory

cp /etc/resolv.conf etc/resolv.conf
mount -t proc none proc
mount -o bind /dev dev
mount -t sysfs none sys
chroot . /bin/bash
source /etc/profile
grep -v rootfs /proc/mounts > /etc/mtab
source ~/.bashrc

This will allow you to just cd to the mounted directory and enter command to chroot to the new environment. From there you can install a desktop environment (I choose XFCE because I wanted a lightweight environment and limited disk space):

pacman -Syu
pacman -S xorg xfce4 gdm <few-fonts> nvidia

And a couple other things following the Beginner’s Guide.

The kernel initramfs image will need to be rebuilt too to have usb driver support. In the chrooted environment edit /etc/mkinitcpio.conf and add usb to HOOKS:

HOOKS="base udev autodetect pata scsi sata filesystems usb"

Then find the the kernel version name and version:

uname -r

and build a new initramfs image:

mkinitcpio -g /boot/kernel26.img -k <your-kernel-name-version>

The -k option needs to be specified to use the chrooted kernel and not runtime kernel that is being used by chroot.

When done, exit chroot:

exit && umount proc sys dev

Reboot and Test

Now reboot and get to the BIOS Boot Menu. As I said, all BIOS’s are different so keep an eye for a key to get to it. Once in the Boot Menu select your USB drive.

Try and boot the flash drive. If you get a GRUB 17 error or boot into hard drive OS, you’ll have to edit your menu.lst. You can find the devices Grub sees by starting the flash drive again and in the Grub menu press e to edit. On the root line press e again and delete to:

root (hd

now press tab and it will show you the availble drive and partitions. Enter the correct one, hit escape and then b to boot. That’s it, you should now have your own customizable Linux USB drive.

Troubleshooting

If you get errors loading the kernel, it may be because USB device detection may need a delay before loading root. Try to add this to the end of your kernel line in your menu.lst:

rootdelay=8

Conclusion

I was a bit surprised. I didn’t think a USB drive would be much different that a CD/DVD but actually it was alot faster. And I just discovered that I’m using a USB 1.1 flash drive. :) Not quite as quick as my hard drive but definitely not bad. This is also the first time I ran without an xorg.conf and my desktop runs great. Definitely worth a try if you ever need a rescue os to fix problems with.

Follow

Get every new post delivered to your Inbox.

Join 52 other followers