Test ram with Memtest86+ and ignore bad parts with badram in grub

Recently, my computer kept freezing whenever I started conkeror (with 100+ buffers loading from a previous session). Folks over at #conkeror on freenode suggested that the problem might be due to faulty ram. They suggested testing my ram with Memtest86+. It is installed by default on Ubuntu.

If you have multiple sticks of ram, test one stick at a time. It’s best to test one stick per night as the test can take hours. To test the ram, restart your computer and go to the grub menu (hold shift if your grub menu doesn’t display automatically). Then, select the “Memtest86+” boot option. Press “c”, “4″, and “3″ to display the error locations according to the BadRAM syntax (converting the default faulty memory addresses is not obvious to me and others). If you don’t do this, you will end up wasting time fixing your boot options (details later).

If you know which ram sticks are bad, replace them if they are under warranty. If they are not under warranty and you can’t afford new ram, you can make use of BadRAM, incorporated by default in grub2, per these documentations. That is, edit /etc/default/grub and specify the faulty ram addresses with the GRUB_BADRAM option.

More information on running Linux with broken memory can be found here.

When I tried this out, I did not use the proper memory address syntax so my computer failed to boot. What made things even worse was that my hard drive was encrypted. Luckily, I can still access grub, and after many trials and tribulations, I fixed the problem by booting the computer with an Ubuntu live disk (usb), mounting the first, unencrypted partition (/dev/sda1) of the hard drive that stored /boot, and removing the badram option in /boot/grub/grub.cfg (replace “boot” with the mount path). Before figuring out the solution, I was trying to mount /dev/sda5, the encrypted partition, according to this and this as I thought that was where /boot resided. I also thought I had to generate a new initrd image. Luckily I didn’t have to (and didn’t succeed in trying) as that would have further complicate my boot options as I have experienced in the past.

After removing the bad ram, conkeror still crashed for me. Either something is wrong with other pieces of my hardware or something is going on with the xulrunner sucking up my system resources. I was able to stop the crashes by placing this in my conkeror rc file.

Build 32 bit R on 64 bit Ubuntu by utilizing chroot

In the past, I’ve described how one could build multiarch (64 bit and 32 bit) versions of R on a 64 bit Ubuntu machine. The method based on this thread no longer works as of R 2.13 or 2.14 I believe. I received advice from someone on #R over on freenode (forgot who) a few months ago that suggested the chroot route (see this also). I recently tried it and wanted to document the procedures. Although the solution isn’t as nice as the previous multiarch route, it will suffice for now. With the chroot method, first compile the 64 bit version of R the usual way. For the 32 bit version of R, do:

#### change my.username to your username, or modify path per your taste
### create chroot jail
sudo apt-get install dchroot debootstrap
sudo mkdir ~/chroot-R32
sudo emacs -q -nw /etc/schroot/schroot.conf
## paste the following in the file: (no quotes)
"
[natty]
description=Ubuntu Natty
location=/home/my.username/chroot-R32
priority=3
users=my.username
groups=sbuild
root-groups=root
"

## build a basic Ubuntu system in the chroot jail
sudo debootstrap --variant=buildd --arch i386 natty /home/my.username/chroot-R32 http://ubuntu.cs.utah.edu/ubuntu/ ## pick a mirror from https://launchpad.net/ubuntu/+archivemirrors

## copy my source locations for apt
sudo cp /etc/apt/sources.list /var/chroot/etc/apt/sources.list ## edit this new file if to reflect only the needed source

### do following steps whenever you need to access 32 bit R
## access to proc and dns
sudo mount -o bind /proc /home/my.username/chroot-R32/proc
sudo cp /etc/resolv.conf /home/my.username/chroot-R32/etc/resolv.conf
## go into jail; do this whenever you want
sudo chroot /home/my.username/chroot-R32
dpkg-architecture ## make sure system is i386
### now the root / location should reflect the jail

### following happens in jail
## tools needed to build R
apt-get install gcc g++ gfortran libreadline-dev libx11-dev xorg-dev
## get svn to get latest r source code
apt-get install git-core subversion

## compile 32 bit R
cd home/
mkdir R32
cd R32
svn checkout https://svn.r-project.org/R/trunk/ r-devel
cd r-devel/
apt-get install rsync
./tools/rsync-recommended 
./configure
make
make install
R

How big is my /home/my.username/chroot-R32 folder? It is at 791 MB after the above steps. Let me know if you have suggestions for having both 32 bit or 64 concurrently on Linux. I believe Windows and Mac ships and compiles both 32 bit and 64 bit versions of R. I’m surprised this isn’t the case for Linux.

Beware: certain Amazon EC2 AMI’s terminate at shutdown

I toyed with Amazon EC2 last year by migrating my web server there. After issuing shutdown -P in Ubuntu last week, my instance disappeared from the list in the AWS dashboard. I seeked help and found out that some AMI’s are set to terminate at shutdown. Unfortunately, the AMI I used was one of them. Files and settings are not recoverable after an instance is terminated. Luckily, I transferred most of my critical information out prior to the shutdown; I’m only missing one file. Note to self: for all future instances, the shutdown behavior to stop (as opposed to terminate) could be modified per these instructions. First, create and download the X.509 certificate and private key. To access the EC2 api, do the following on your computer:

sudo apt-get install ec2-api-tools ec2-ami-tools ##ec2-init

Then, do the following to find out what behavior is currently set on your instance:

ec2-describe-instance-attribute i-AMAZON-INSTANCE-ID --instance-initiated-shutdown-behavior -K /path/to/x509-key.pem -C /path/to/x509-cert.pem 

If the value is not stop, then do

ec2-modify-instance-attribute i-AMAZON-INSTANCE-ID -K /path/to/x509-key.pem -C /path/to/x509-cert.pem --instance-initiated-shutdown-behavior stop

Symlinks in samba and sshfs

When setting up sshfs mounts and Linux samba servers, one can make it so that symbolic links are followed (so they aren’t broken). For sshfs, add the follow_symlinks option. In /etc/fstab/, the entry would look something like

sshfs#USERNAME@SERVERNAME: /mnt/acer fuse fsname=sshfs#USERNAME@SERVERNAME:,comment=sshfs,noauto,users,exec,uid=1000,gid=1000,allow_other,reconnect,transform_symlinks,follow_symlinks,BatchMode=yes 0 0

For samba, add the following to either the [global] options or the individual location in /etc/samba/smb.conf:

follow symlinks = yes
wide symlinks = yes
unix extensions = no

Make sure samba is restarted and the sshfs mount point is re-mounted.