Install Arch Linux on VirtualBox

start

desktop

Yesterday, I installed Arch Linux on my Kubuntu by using VirtualBox. The installation process was much easier compared with Gentoo. But that doesn’t mean I give it up, I will try to install Gentoo some days later.

I downloaded Arch Linux here. I would recommend to scroll down the page and look for a session called HTTP/FTP Download. BitTorrent download is recommended by the website, but it was barely connectible at the time I visited, so I chose HTTP/FTP Download.

I downloaded archlinux-2009.02-core-i686.iso here. I could either burn it into a CD or mount it into VirtualBox. I chose the 2nd options, since I wanted to test it on VirtualBox before actual installation.

The installation is straight forward, but in case you are interested to try it yourself. I embed a Arch Linux installation walk-through below:

One thing I would love to mention is partition. In this case, I didn’t need to worry about partition, since the entire process was inside a virtual environment. If I want to install Arch Linux on my actual machine, I need to be careful and I should write down different partition names (e.g sda1, etc) before I run the live CD.

Another thing is, in order to install extra packages, I needed to highlight a package, then pressed space bar to select it. (I think it is a good idea to put some text description somewhere on the installation screen)

After around 20 minutes, the installation was completed. I ran pacman -Syu (Which is similar as sudo apt-get update in Ubuntu, to synchronize your local packages to remote repositories). Things didn’t run smoothly, pacman (Package management tool) timed out. At this stage, I was able to ping different websites. That indicated there was Internet connection. Then I looked into /etc/pacman.d/mirrorlist. mirrorlist contains various URLs of repositories. I was recommended to use rankmirrors to filter out the best connections inside /etc/pacman.d/mirrorlist. Unfortunately, it required python and python was not installed. One way to get around this is, on terminal type wget http://mirror.internode.on.net/pub/archlinux/extra/os/i686/python-2.6.1-1-i686.pkg.tar.gz, then type pacman -U python-2.6.1-1-i686.pkg.tar.gz. pacman was smart enough to handle it for me.

After installing python, I ran rankmirrors -v /etc/pacman.d/mirrorlist > output.txt. The output.txt file now had a list of URLs, which was ranked by connection speed. I replaced the mirrorlist with output.txt. That would be cat output.txt > /etc/pacman.d/mirrorlist. In my personal case, the FTP URLs didn’t work for me. The HTTP URLs were fine for me, even I needed to try multiple times or used a trick (The trick is to use my favorite web browser to access some of the packages on the repository. I guess the reason is to rebuild the connection with remote server.)

I commented out FTP URLs on the top of the mirrorlist and use HTTP URLs instead. I ran pacman -Syy. Dada……. It worked!

The last thing I needed to install in my mind was Gnome. You can find instructions here. Make sure you create at least one user account, if you intend to use login screen. Gnome doesn’t allow administrator (i.e. Root) to login, due to security reason. The Gnome installation was easy, even though the connection was unstable. I just needed to resume the downloaded each time it timed out.

I know it is a long process, but I can start to enjoy Arch Linux now. I am not sure what will break next time, but I will keep you update to date.

Advertisements

Gentoo gave me a hard time

gentoo

I tried to install Gentoo on VirtualBox by using Minimal CD. The instruction I found on the web is very clear and easy to follow, but the end result was not I expected. I failed to compile the kernel and it was not able to boot, due to kernel panic.

I tried for the 2nd time by using Live CD on VirtualBox. This time was better. It was able to compile the kernel, but it failed to install Gnome or other extra packages. It was funny that I was not able to select Gnome, Firefox or other packages during the install stage. There is a bug that even you select a package by pressing the enter key (Later, I realized that I should press space bar to select a particular package. Ok…..), it won’t actually be selected, at least in VirtualBox environment. I guess I can install Gentoo on the machine, rather than on VirtualBox. But I found that there was no partition utilities during the partition stage, suddenly, my willingness to install Gentoo declined.

It seems there are lots of processes to install Gentoo and they are not very straight forward either. But if I think about that it is a learning process, I actually feel better. Indeed, I learned a lot during this awkward installation.

Gmail notification with command line

Instead of opening Gmail on a web browser, I want to check emails with command line. Unfortunately, this script is only able to check whether new emails are received or not. It does nothing other than that. As usual, I include usage and source code below:

Usage:

./checkmail.sh

Source code:

#!/bin/bash
# name : checkmail.sh

# Username
echo "Eneter your gmail username: "
read login

# Password
echo ""
echo "Enter your gmail password: "
trap "stty echo; exit" 1 2 15 # able to restore stty setting, even on "Ctrl+C"
stty -echo
read passwd
stty echo
trap "" 1 2 15

if [ "$login" == "" -o "$passwd" == "" ]
then
	echo "Error: Username or password is empty."
	exit 65
fi


inbox=`wget -T 3 -t 1 -q --secure-protocol=TLSv1 --no-check-certificate \
--user=$login --password=$passwd \
https://mail.google.com/mail/feed/atom -O - | \
sed -ne '/fullcount/s:.*>\([0-9]\+\)/dev/null`
# Notice the 'x', it is from bounce shell 
# to check whether it is null string or not, but it works in bash.
if [ ! x$inbox == x'' ] 
then
	if [ ! $inbox -eq 0 ]
	then
		echo “$inbox new mails in your box.”
		Xdialog --msgbox "Please check your email!" 5 40 & # You may need to install Xdialog or comment it out
	else
		echo “No new mails found!”
	fi
else
	echo “Some error occurs!”
fi

I should give some credits to the creator of original shell script (I also made some modifications), but I forgot where I found it. Hmmmmmm.

Twitter users a-z

I am not sure why people chose these usernames. Perhaps they are simpler and easy to remember. In fact, most of them picked the first letter of their names as twitter usernames

Name: Andrei Zmievski
Twitter: http://twitter.com/a
Web: http://gravitonic.com/projects
Bio: Bio I’m Russian. ’nuff said.

Name: Ben Bradley
Twitter: http://twitter.com/b
Web: http://moblog.bradleyit.com/
Bio: I’m like a chimney sweep, but for the intarweb toobs

Name: Coley Wopperer
Twitter: http://twitter.com/c
Web: None
Bio: I’m a very serious designer—a seriously joyous designer! Life is grand 🙂

Name: dave
Twitter: http://twitter.com/d
Web: None
Bio: None

Name: erin
Twitter: http://twitter.com/e
Web: http://erin-alexander.blogspot.com/
Bio: none

Name: Fred Oliveira
Twitter: http://twitter.com/f
Web: http://helloform.com
Bio: Designer-developer hybrid. I like to make people smile.
I founded Webreakstuff, a design and development company.

Name: Greg Leding
Twitter: http://twitter.com/g
Web: http://brainofg.tumblr.com/
Bio: Trouble is my business.

Name: Helgi
Twitter: http://twitter.com/h
Web: http://www.helgi.ws
Bio: Whacky

Name: Sarah
Twitter: http://twitter.com/i
Web: none
Bio: none

Name: Juliette
Twitter: http://twitter.com/j
Web: http://juliemelton.com/
Bio: UX, SF, Lumos Labs

Name: Kevin Cheng
Twitter: http://twitter.com/k
Web: http://kevnull.com
Bio: Author:seewhatimean.org
* Comic:ok-cancel.com
* Director of Product:raptr.com
* Curator:@inspiring
* Founder:offpanel.com

Name: ant
Twitter: http://twitter.com/l
Web: none
Bio: none

Name: Mark Douglass
Twitter: http://twitter.com/m
Web: http://claimid.com/markdouglass
Bio: none

Name: Naoki Hiroshima
Twitter: http://twitter.com/n
Web: http://n.h7a.org/
Bio: A guy who cares nothing but his family
and his friends, and what they care.

Name: Oliver Thylmann
Twitter: http://twitter.com/o
Web: http://blog.thylmann.net/
Bio: Geek, Blogger since 2001, Entrepreneur,
Performance Advertising

Name: paolo i.
Twitter: http://twitter.com/p
Web: none
Bio: things never happened in this order.
maybe they never happened at all.
the old man told me: ‘this planet is like a cougar’

Name: Rex Hammock
Twitter: http://twitter.com/r
Web: http://RexBlog.com
Bio:
* founder/ceo of Hammock Inc. (hammock.com)
* knowledge hunter-gatherer
* media creator-consumer

Name: Sandy
Twitter: http://twitter.com/s
Web: http://iwantsandy.com/
Bio: I’m Sandy, your personal email assistant.
I’ll remember the details so you can focus on what’s important.
Twitter me directly with: d s hi

Name: Tantek
Twitter: http://twitter.com/t
Web: http://tantek.com/
Bio: barcamp bicycler buildingblocks climber cultural
evolution hacker independent microformats nerdy optimist
pescatarian scientist skeptic

Name: u
Twitter: http://twitter.com/u
Web: none
Bio: none

Name:William Lawrence
Twitter: http://twitter.com/v
Web: http://zaxbypass.com/
Bio: …. versus all stand for veeliam. And, he stands for Accessibility.

Name: Walter
Twitter: http://twitter.com/w
Web: http://wvk.spaces.live.com/
Bio: exec producer of my life. Where’s my cast?

Name: gene x
Twitter: http://twitter.com/x
Web: http://pulp.orangephotography.com/blog
Bio: photographer and friend of lemurs

Name: reYhan
Twitter: http://twitter.com/y
Web: none
Bio: yessir my aura is orchestral but way fresher!

Name: me (not me)
Twitter: http://twitter.com/z
Web: none
Bio: none

The genius behind “Sixth Sense” device

Pranav Mistry is a PhD candidate in the Fluid Interfaces Group at MIT’s Media Lab. He is the genius behind the wearable device “Sixth Sense”, which allows a new kind of interaction between data and the real world.

Here is the demonstration of the device “Six Sense” at TED:

In the past, he worked as a UX researcher in Microsoft before studying at MIT. There are several notable projects Mistry worked previously, namely Quickies, which are intelligent sticky notes that can be searched and sent between devices; a pen that draws in 3D; and TaPuMa, a tangible public map that can act as Google of physical world.

Shell script to generate random password

password

This is a shell script to generate random password. You can specify the length of the password to be generated, otherwise the length of the password will be default to 8 characters.

Usage:

./password.sh length_of_password

Source code:

#!/bin/bash 

MAXSIZE=$1

if [ "$MAXSIZE" != "" -a "$MAXSIZE" == "${MAXSIZE//[^0-9]/}" ]
then
	echo "Default password length is set to $MAXSIZE"
else
	MAXSIZE=8
	echo "Default password length is set to $MAXSIZE"
fi

CHAR_ARRAY=( 
q w e r t y u i o p a s d f g h j k l z x c v b n m Q W E R T Y U I O P A S D 
F G H J K L Z X C V B N M 1 2 3 4 5 6 7 8 9 0 ! @ # $ % ^ & * ( ) 
)

MODNUM=${#CHAR_ARRAY[*]} 

PWD_LEN=0

while [ $PWD_LEN -lt $MAXSIZE ] 
do 
  X=$(($RANDOM%500)) 
  Y=0 
  while [ $Y -lt $X ] 
  do 
    ((Y++)) 
    INDEX=$(($RANDOM%$MODNUM))
  done
  echo -n "${CHAR_ARRAY[$INDEX]}" 
  ((PWD_LEN++)) 
done

echo ""

exit 0

Shell scripts to get rid of “^M”

interesting

It is always good to learn something which I don’t know. I take some time to write 2 similar shell scripts to remove ^M in files. The source code and usage are written below:

cleanM.sh is capable to clean up the ^M symbol inside a file.

./cleanM.sh filename

The source code can be found below:

#!/bin/sh

ERROR_CODE=65
FILENAME=$1

if [ -z "$FILENAME" ]
then
  echo "There is no such file!"
  exit $ERROR_CODE
fi

BACKUP_FILE="$FILENAME".bak

mv -f "$FILENAME" "$BACKUP_FILE"
sed "s/\^M//g" "$BACKUP_FILE" > "$FILENAME"
rm -r ./"$BACKUP_FILE"

exit 0

cleanMDir.sh is capable to clean up the ^M symbols in an arbitrary directory. If there is no directory name provided, current directory will be used instead.

./cleanMDir.sh dirname

The source code is here:

#!/bin/sh

DIR=$1
THIS_SCRIPT=$0

if [ -z "$DIR" ]
then
	echo "==> No such dir! Use current dir instead!"
	DIR="."
else
	echo "Use ${DIR}"
fi


# get rid of trailing "/"
NEW_DIR=${DIR%/}
echo "====> $NEW_DIR"

for FILENAME in "$NEW_DIR"/*
do
  if [ "$FILENAME" = "$THIS_SCRIPT" ]
  then
        echo "Skip ${THIS_SCRIPT}"
  else
	BACKUP_FILE="$FILENAME".bak

	mv -f "$FILENAME" "$BACKUP_FILE"
	sed "s/\^M//g" "$BACKUP_FILE" > "$FILENAME"
	rm -r ./"$BACKUP_FILE"
		
	echo "Complete ${FILENAME}"
  fi
done

echo "==> Done!"
exit 0

———-
Update
———-
So why do we have ^M symbol in the first place?

Text files are organized differently on Unix and Windows. Unix uses the character (i.e. “\n”) to mark the end of a line, while Windows prefers to use (i.e. “\r\n”) to do so.

There is no problem for a decent editor to display text correctly and consistently on Unix or Windows. The problem will raise, if a less decent editor tries to open a Windows file in a Unix environment. The editor will display “\r” as “^M” (i.e. M has the ASCII value of 0x0D, which represents the return key on Unix).

On the other hand, a less decent editor on Windows may display text in a Unix file all in one line, because it can not find the character in the file.

A decent text editor should solve the problem. e.g. Wordpad on Windows or Vim/Kate/Gedit on Linux.