anderstornvig.dk

Where’s your head at?

Archive for June 2008

Installing Arch Linux with Awesome

with one comment

A couple of weeks ago I wiped out Ubuntu on my shuttle in favor of Arch Linux. I wanted to use it exclusively as I have for about half a year on my laptop. In my experimenting with Arch I’ve installed it quite a few times and this time I felt confident taking notes to the entire procedure. Most of it can also be found in pieces on the excellent Arch wiki, so what you can get here is the structure. My way of dealing with the black and lonely CLI you face when first installing Arch. An experience which can actually be quite confusing and scary if not guided. I expect this guide to be updated every now an then if I figure out optimizations and new stuff.

Since you’re installing Arch I’m going to assume that you’re not a complete novice in Linux. Some – well actually more than that – basic knowledge about Linux is expected. Also, just skip steps concerning specific settings you don’t need. I am however going to advise you to read the entire paragraph you are going to follow – BEFORE you actually follow it. I hardly ever do this and it’s just incredibely stupid sometimes.

Although I’m sure you’d find a complete list of specifications on my shuttle pc very interesting, I’m just going to tell you what’s relevant. I have an nvidia video card along with a dual monitor setup. That’s it. Let’s get started.

Installing Arch

This is pretty straight forward. You burn an i686 image (right now the 2008.03 is stable) from http://www.archlinux.org/download/ and boot it. Then you follow the guide.

Packages

I installed everything except wifi drivers and firmware.

Configs

All of a sudden a list of config files is thrown at you. Don’t worry. The only one I normally edit is the rc.conf file. You should know that this is a very central config file in your Arch system. It takes care of things like locale, CLI layout, network and the startup process. The crucial lines are:

LOCALE="en_US.utf8"
HARDWARECLOCK="localtime"
TIMEZONE="Europe/Copenhagen"
KEYMAP="dk"
CONSOLEFONT="cp850-8x16"

You might also want to correct the network settings. I use this in a wired network:

HOSTNAME="atcshuttle"
eth0="dhcp"
INTERFACES=(eth0)

Root password

The last line of the list. Set this to anything you might like.

Bootloader

Fancy word but I’m just talking about grub. Install it to your master boot record. To the config (/boot/grub/menu.lst) I always add ” vga=795″ to the end of the kernel line to get a prettier framebuffer – or higher CLI resolution in layman terms.

If you’re dualbooting with Windows you also want to uncomment the Windows entries.

Finishing installation

Well, just reboot as it tells you to, then log in as root.

Update

It’s good practice to finish your installation doing an update. It might also be crucial to your later install of the nvidia driver. As you probably know, Arch uses the package manager Pacman. It’s basically the same as apt on Debian and extremely useful. You’re going to use this tool a lot so I recommend that you look commands and features up on the archwiki. For now, update your entire system with:

# pacman -Syu

This might take a while and you might have to run the command twice if pacman has to be updated. Check that the packages are both downloaded and installed. If it’s not pacman will tell you why and what to do. The point, update your system.

Adding a user

This is similar to other distros. Just do an “adduser” and follow the instructions. To get sudo, do:

# pacman -S sudo

The configuration of sudo is done in the /etc/sudoers file. We’re going to use nano to edit this.

# nano /etc/sudoers

Add “USERNAME ALL=(ALL) ALL” below the similar root entry. This will give the new user sudo rights.

Command completion when sudoing is enabled by adding “complete -cf sudo” to /home/USERNAME/.bashrc. After doing this, chown the file to the user.

# chown USERNAME /home/USERNAME/.bashrc

Installing X

Getting it

The graphical user interface comes with X. And X requires a graphics driver, nvidia in my case.

# pacman -S xorg nvidia

Xorg is big so this will also take a while. Next, generate an xorg config file in the /etc/X11 directory with the following.

# nvidia-xconfig

The generated file will be given the name XF86Config. I’m used to xorg.conf, so I do a:

# cp /etc/X11/XF86Config /etc/X11/xorg.conf

Configuring it

The configuration of X is obviously done in the configuration file. So,

# nano /etc/X11/xorg.conf

Comment out “Load type1″. It’s old and now replaced by the freetype fonts. Also to get a danish keyboard layout in X, add to the inputdevice for the keyboard:

Option         "CoreKeyboard"
Option         "XkbRules" "xorg"
Option         "XkbModel" "pc105"
Option         "XkbLayout" "dk"
Option         "XkbVariant" "nodeadkeys"

Save and close the file.

To activate the nvidia driver on boot, load the module by adding “nvidia” to the MODULES-line in /etc/rc.conf.

Fonts

To make the fonts in X look bearable, install the following. The command is stolen from http://www.cdavis.us/wiki/index.php/Installing_Arch_Linux#Install_Fonts. A great guide about the same.

# pacman -S ttf-ms-fonts ttf-dejavu ttf-bitstream-vera ttf-liberation

Window manager – Awesome

A window manager that actually manages your windows is Awesome. Read about it on http://awesome.naquadah.org/. I know I’m crazy about it. Getting it is easy but configuring and using it is a bit trickier. Do a:

# pacman -S awesome

Then login as your user by:

# su USERNAME

And enter you password. Edit the .xinitrc by adding “exec awesome”. In case you don’t know this file is evaluated when starting X. So stuff like wallpapers, widgets and of course the window manager goes here. And the exec command tells X to execute awesome as the window manager for X.

As written the configuration is hard in the beginning. Everything however is done in the .awesomerc config file. I’m planning on writing an article on this too and also posting my config. Until then I recommend that you have a look at the awesome wiki and maybe some user examples. And of course if you ask me nicely you can have mine.

Widgets – Amazing

Later..

Starting X and Awesome

Finally it’s time to actually start X. Assuming that you’re still logged in as your user, run:

$ startx

If X fails I don’t really know what you’ve done wrong. Have a look at the errors and solve them. If awesome fails in any way you will be able to see it by pressing ctrl+alt+f1. Please also correct any errors that might appear here.

Assuming that everything seems to work you are greeted by a black screen and a top statusbar. If you know nothing about awesome your system will be practically useless now. To get you started though you open a terminal by pressing sup+enter, type man awesome and learn the shortcuts. Also sup+f2+appname opens a new application.

Configuring nvidia

The nvidia driver include a great tool for this. As you know I have a dual monitor setup, a 22″ and a 24″. To get this working I just open a terminal and run:

$ sudo nvidia-settings

Do what’s needed and “Save to X configuration file” (which is /etc/X11/xorg.conf if you followed what’s above). I usr “seperate screens” with Xinerama enabled. Works like a charm.

Libraries and applications

This is just a list of stuff I install to a new Arch installation. The most important stuff is probably the gtk stuff so make sure you install that. Else look them up on google and see if you need or want them. I’m also not going to write about how to use them. That’s simply beyond the scope of this article.

When installing this many applications some conflicting files may appear and pacman won’t be able to finish the job in this case, just do “sudo rm thefiles”.

GTK

$ sudo pacman -Sy gtk gtk2 gtk-engines gtk-smoooth-engine gtk2_prefs gtk2-themes-collection

Then run “gtk2_prefs” and set up gtk. I use the industrial theme and a font size 8.

Internet

$ sudo pacman -Sy elinks firefox flashplugin jre pidgin irssi

Mail

$ sudo pacman -Sy mutt

Office and text editing

$ sudo pacman -Sy openoffice-base vim geany vte texlive-most subversion xpdf epdfview

Media

$ sudo pacman -Sy mplayer vlc libdvdcss libdvdread moc ffmpeg tablib speex libmpcdec xine-ui

Graphics

$ sudo pacman -Sy feh xzgv mirage imagemagick scrot nitrogen gimp

Other important ones

$ sudo pacman -Sy htop screen sshfs mc unzip rxvt-unicode wine

The end

That’s it. Thank you for reading. Feel free to leave a comment or question concerning the above.

Written by Anders Tornvig

June 21, 2008 at 19:31

Running existing Windows in VirtualBox on Ubuntu

with 22 comments

By Andreas Møgelmose

A while ago I finally got around to installing Ubuntu on my desktop computer side by side with Windows, having almost exclusively used Ubuntu on my laptop for months. I had been hesistant to migrate from Windows on my desktop, as I still need to use several Windows-only applications and Wine is not an option for some of them. I’ve known about VirtualBox for at while, but did not know until recently, that it was possible to run an existing Windows installation that way. Note that it doesn’t just clone the installation, it actually uses the same installation, so any change you make in your VirtualBox will also appear when you boot up in Windows. As you can read from my last sentence, this approach doesn’t exclude you from using the Windows-installation as a regular dual-boot for that occasional game of Call of Duty 4 (VirtualBox does not, for now at least, support 3D-graphics).

I’ve written this guide, as I haven’t been able to find any thorough guide anywhere. I have to give a lot of credit to Kim Nguyen, who has the best article on the subject I’ve been able to find. Other information in this guide is compiled from the VirtualBox-forum and manual. This guide is written for Ubuntu 8.04 as host and Windows XP as guest, but should be usable for other distros as well. I don’t know whether virtualizing Windows Vista is any different from XP.

Preparations in Windows

In order for VirtualBox to access you Windows-installation, a couple of preparations is needed in Windows. Boot your Windows-installation and do the following:

MergeIDE

Windows fails to boot, if the IDE-controller it is installed on differs from the current controller. Since VirtualBox makes a virtual controller, we need to bypass this. To do this, download the MergeIDE-tools, extract the zip-file and run MergeIDE.bat.

Hardware Profiles

Next, in order not to screw up the drivers in the existing install, we need to create a hardware profile in Windows specifically for our virtual machine. This is done in Control Panel -> System -> Hardware Profiles. Click your existing profile and click Copy. Name the new copy “VirtualBox boot” and rename the existing to “Stand-alone boot”. Now order them after your preference (the order determines the order in which they’ll show up in the menu when Windows is booting. I have my VirtualBox-profil first, as that’s the one I’m using the most).

To be safe, check “Wait until I select a hardware profile”. This ensures that Windows will not boot in the wrong profile because you forget to select one.

That’s all you need to do in Windows. Now reboot into Ubuntu.

Preparations in Ubuntu

Okay, now that we’re safely booted in Ubuntu we can relax. We just need to install a couple of tools before the VM’ing can commence.

Install closed-source VirtualBox

VirtualBox exists in two versions. An open-source one (VirtualBox OSE) with most of the functionality and a fully featured closed-source version. As the functions we are going to use apparently “targets enterprise customers”, we’ll need the closed-source version (named just VirtualBox). Don’t worry, it’s free (as in beer) for personal use. And you’re a person I presume.

The version in the Ubuntu repos are VirtualBox OSE. If you have installed that already, go ahead and uninstall it. You won’t need it (it might not hurt to keep it, but I wouldn’t count on it).

Download the appropriate install-binary here: https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_SMI-Site/en_US/-/USD/ViewProductDetail-Start?ProductRef=innotek-1.6-G-F@CDS-CDS_SMI. Save it to, say, your home folder.

The binary is packaged as a nice .deb-file, so you just double click it and install. No need for any dirty make install here. Just accept the defaults during the installation.

Install mbr-tools

Next up we need some tools to create a shiny new MBR for the Virtual Machine. Why do we need a shiny new MBR? Well, you could do without, but in that case GRUB would show up every time you started the virtual machine and you’d have to choose to boot up in Windows. “But I can do that,” you say. Yes, but at some point, by mistake you’d boot into Ubuntu on the virtual machine while already in that very same Ubuntu-install. And then you’ll be in a world of stinkin’ green goo. Or maybe not. But it will be ugly. People will scream.

We also need a new MBR, because we’re only going to allow access to our exact Windows-partition (and maybe the partition on which we have the Program Files-directory, if that’s a different one). Now, quit arguing with me, open a terminal and execute this:

$ sudo apt-get install mbr

Now we’re ready to go ahead and create the Virtual Machine.

Create the Virtual Machine

Create MBR

First we create the new MBR. Open a terminal (or reuse the old window, I don’t care) and make sure you’re in your home directory by executing

$ cd ~

Then create the MBR with this command:

$ install-mbr --force .VirtualBox/vboxmbr.mbr

Create the virtual machine

Before actually creating the virtual machine, we need to know which partitions to give it access to. This will give you a list of the partitions on your computer:

$ sudo fdisk -l

The output will look somewhat like this:

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1958    15727603+   7  HPFS/NTFS
/dev/sda2            1959       60801   472656397+   f  W95 Ext'd (LBA)
/dev/sda5            1959       35449   269016426    7  HPFS/NTFS
/dev/sda6           35450       37939    20000893+  83  Linux
/dev/sda7           37940       38188     2000061   82  Linux swap / Solaris
/dev/sda8           38189       60801   181638891   83  Linux

I have several other harddisks as well, but my Windows (and, coincidentially, Ubuntu) is installed on sda, so I’ve only included that disk here. You might need to look at other disks than sda. Okay. Now we find the HPFS/NTFS formatted disk, that is marked for boot. This is where Windows resides and where we want to give the virtual machine access to. In my case it is sda1. And so we’re ready to let the magic happen. In the following command, replace sda with whatever the disk your Windows is installed on is called and replace the number after -partitions with the partition-number:

$ sudo VBoxManage internalcommands createrawvmdk -filename /home/xerxes/.VirtualBox/WindowsXP.vmdk -rawdisk /dev/sda -partitions 1 -mbr /home/xerxes/.VirtualBox/vboxmbr.mbr -relative -register

If everything went according to plan, you now have the basis for a Virtual Machine.

(Note: If, like me, you like to install your Windows programs on another partition, you can give the machine access to that by providing other partition numbers as well as the Windows-partition. I have my programs on sda5, so I use this instead:

$ sudo VBoxManage internalcommands createrawvmdk -filename /home/xerxes/.VirtualBox/WindowsXP.vmdk -rawdisk /dev/sda -partitions 1,5 -mbr /home/xerxes/.VirtualBox/vboxmbr.mbr -relative -register

)

Create the machine in VirtualBox

Before adding the harddisk in VirtualBox, we need to give your regular user permissions to open it. Thus, we change the owner. In a terminal in your home directory, execute this (with your username instead of [username]):

$ sudo chown [username] .VirtualBox/WindowsXP.vmdk .VirtualBox/WindowsXP-pt.vmdk

Good. Open VirtualBox (find it in Applications -> System Tools). First we add the partition as a virtual harddisk. Click File -> Virtual Disk Manager -> Add and find the vmdk-file (if you’re in your home directory type .VirtualBox/WindowsXP.vmdk and click Open). Click OK.

To create the machine, click New in the toolbar and Next. Name your new machine. I call mine Windows XP. Select Windows XP in OS Type. Click Next. Choose how much memory you want to allow it to use. Windows XP needs at least 512 MB, but remember that Ubuntu also uses some. I have 4 GB RAM in my computer (yeah, I know, only 3,2 gigs can be used in 32 bit Ubuntu), so I just crank it all the way up to 2000 MB. Click Next. Choose WindowsXP.vmdk in the drop-down list. Click Next and Finish.

Okay, almost done. In order for Windows to boot, we must enable IO APIC and VT-x/AMD-V. This is easy. Right click on your new machine, click Settings. In the advanced tab, check “Enable IO APIC” and “Enable VT-x/AMD-V”.

That’s it! Hopefully you now have a working Virtual Machine using the same Windows as for dual-booting. When you boot the virtual machine just select the VirtualBox hardware profile and when you dual-boot into Windows, select the stand-alone hardware profile. I won’t write a lot about using it, as VirtualBox has some good and descriptive dialogs, that I will encourage you to read. If, however, you find yourself stuck in the VM without being able to return to Ubuntu (yeah, it’s a horrible thought, I know), you need to know the concept of the Host-key. The host key will relase your mouse pointer and keyboard from the guest when pressed, and you be able to use Ubuntu again. By default the Host-key is set to right Ctrl, but it can be configured. I use Scroll Lock.

Setting up the Virtual Machine

Your VM should now be working, but there is still some tweaks to do, to get the most from it.

Network

These days, a computer without internet isn’t worth much. That’s also true for virtual machines. To enable network, go to Settings (you can only do this when the machine is off), choose Network in the right-hand menu and check Enable Network Adapter. You may need to try different adapter types, not all of them will work. I use PCnet-FAST III.

Installing Guest Additions

Note: Before you install the Guest Additions, be aware that this guide warns you not to do so, as it will allegedly render your native Windows boot useless. With that said though, I took the chance and haven’t had any problems, other than that my VM’s boot now take longer. But that’s a trade-off I can accept. So, to cut to the bone: Install these additions at your own risk.

One of the really cool features in VirtualBox is the possibility to run virtual machines seamless. This means, that you will be able to use guest-programs just as if they were running regularly in your host-system. In order to enable this, you need to install some software on the guest (Windows in our case) called Guest Additions. Guest additions generally has the benefit of integrating the VM better on your desktop.

Before we do this, we need to give the VM more vidoe memory (a requirement for seamless mode). Make sure your VM is closed, right click on the machine and click Settings. On the Basic-tab, change the amount of video-memory given to the VM to whatever you feel you can spare. Seamless windows requires at least 9 Mb, but I just bump it all the way to 128 Mb (of course this depends on which graphics card you have).

Now boot your VM. When it’s ready, go to Devices -> Install Guest Additions… and follow the guide that shows up on screen. You’ll probably need to restart the VM during the install.

When installed, to enable seamless mode, just press Host-L. It is my experience, that seamless mode works best, if you wait to enable it until you have started a program (I use an auto-hide start-menu in Windows which can behave a little weird if you go seamless without have any program started.

Shared folders

Coming later.

The end

Nice job! If you’ve come this far, my guess is that you now have a Virtual Machine running that’s beautifully integrated into your Ubuntu install.

There is one issue this guide has not touched – the incredibly annoying Windows reactivation “feature”. As you know, Windows checks for hardware changes and demands to be reactivated upon major changes. Changing to another system entirely, even if that’s just a virtual machine on the same physical computer obviously makes Windows want to reactivated. I do (believe it or not) actually have a valid license, but that doesn’t really help me at all. I’ve resorted to just cracking my Windows installation (thinking that if I own a legal copy, that can’t be illegal – but I’m not really sure). Another option is described in this guide. Isn’t it wonderful that it is actually easier to use tools for piracy than to do “the right way”?

Thank for reading. If you note any errors or ommisions in the guide, please leave a comment and I’ll see to it.

Written by Anders Tornvig

June 3, 2008 at 22:19

Posted in Linux

Tagged with , , ,