TideLog Archive for the “Linux Tips” Category

I’ve had a keen interest on the Elementary OS Project. Now, you might think from reading my blog, that I’m extremely anti-Apple, so you’re thinking, “Why does he like an OS that LOOKS like Mac OS? Well, firstly it’s Her Ladyship Kana’s fault for introducing me, and secondly, the looks are where the similarities stop dead. It’s an exciting and kinda novel concept: bringing a rigorous focus on user experience  (Apple’s main focus, style over substance) to the Linux desktop, as Elementary only comes with a very bare set of apps, such as Midori (Kana’s mum’s name, such a sweet name for a Japanese woman!) as a web browser, it doesn’t come with an office suite, like Mint, it’s quite lightweight. Recently, they released their second beta of the second version, v0.2, of their operating system, called Luna. It’s been a while since I’ve run Luna (last time my experience was too unstable for a production environment), so I decided to install VirtualBox and virtualize this second beta. My experience was riddled with problems and gotchas until I tweaked it, so I thought I would share my notes with everyone in case any are interested in trying it themselves.

Note one, this is a biggie, DO NOT settle for running this VM at default Virtualbox settings, it WILL run like a dog chasing a stick in treacle. I’ll walk you through optimizing it later.

Installing/Setting-up VirtualBox

Even installing VirtualBox is arduous under Linux, I always prefer Windows as host for virtualization, but seeing as I’m considering a switch to Linux from Windows, I thought I’d test my skills from Kana’s training me. For some reason, VirtualBox under recent versions of Ubuntu is a miserable experience. It seems like I always get this error when I try to set up a new virtual machine:

Kernel driver not installed (rc=-1908)

The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Please reinstall the kernel module by executing

‘/etc/init.d/vboxdrv setup’

as root. If it is available in your distribution, you should install the DKMS package first. This package keeps track of Linux kernel changes and recompiles the vboxdrv kernel module if necessary.

And when I follow its advice (by running `/etc/init.d/vboxdrv setup`), the program fails. Apparently, Kana told me as she settled next to me after watching me pull my hair out, the key is installing the generic linux headers FIRST, like so: `sudo apt-get install linux-headers-generic`; however, Kana also tweaked it for per-user, try it in case your environment differs from mine:

sudo apt-get install linux-headers-`uname -r`

Download the Elementary Beta 2 ISO

The next step is downloading the ISO, links for torrents and traditional downloads which can be found on this page. I used wget to download the ISO; however, my connection was interrupted and trying to resume it seemed to have corrupted the file (or at least VirtualBox didn’t like it), so if you really want to use a traditional download (that is, over HTTP, like me), make sure you get it in one shot. Otherwise, I recommend using a torrent, but depending on the version, an age of torrent, the number of seeders, hence the speed, may vary. Once you have that, setup a new VM, point its CD drive at the ISO, and then make the following changes:

Under Display, make SURE you check, “2D & 3D Acceleration”, and make double sure you give it enough System and Video RAM, other wise the forementioned dog-chasing-stick-in-treacle symptom will appear, and it’s laggy as hell. Elementary relies heavily on GPU acceleration. IMPORTANT: If you install Elementary and change the settings afterwards, you WILL need TWO restarts to get everything working properly, as Linux configures itself, as far as it’s concerned you’ve swapped out the graphics card for an accelerated one so it’ll need to adjust itself, and the VirtualBox additions files configs.

Putting the final touches on your VM

Now that you have your Luna VM set up and the OS installed, you may find that the default resolutions provided by VirtualBox (I think I had 800×600 and ~1200×700) too small for your monitor (my laptop supports 1920×1200), so you’ll want to change your VirtualBox configuration.

The first step is installing what VirtualBox calls “Guest Additions”, which are essentially a package of utilities that smooth communications between your host OS (in my case, Ubuntu) and your guest (Luna). For example, Guest Additions allows you to configure your VM to support a shared clipboard so you can copy in the guest and paste in the host or vice-versa. It also supports drag-and-drop between host and guest. To do this, click on your VM’s “Devices” menu, and click “Install Guest Additions”. If you have problems with this, it is also well-documented online, so I won’t rehash it here either. I always find that Linux installs VirtualBox additions via its Online Update, Mint and Debian do, so you can do either, whichever works, but the Devices>Install Additions option can sometimes be the most up-to-date drivers.

The following instructions are host-specific. Now that you have your Guest Additions installed, switch back to your host OS (Ubuntu, in my case), open a terminal, and type the following, replacing the ’1920,1200′ with the max resolution of your monitor:

VBoxManage setextradata global GUI/MaxGuestResolution 1920,1200

I had to restart my guest (Luna) VM in order for the changes to take effect correctly, otherwise I got loads of graphics glitches. I forget what exactly I had to do to make it take effect, but I think it is something along the lines of choosing “Auto-Resize Guest Display” under your VM’s “View” menu (I run my VM in fullscreen mode, also available under the View menu). I believe that’s all that is necessary to enable a sane, full-resolution VM. If that still doesn’t do it, you can try resizing your VM’s window a couple times (to try to get VirtualBox to force a resize the guest resolution) or you can try playing with the resolution in the Settings app’s (on the dock) ‘Displays’ view.

Also, the default menu-bar position for a VirtualBox VM’s toolbar (when in full-screen mode) is at the bottom, directly in front of the dock. This is annoying, but configurable. Select the VM’s “Machine” menu’s ‘Settings’ item, and under ‘General’->’Advanced’->’Mini toolbar’, check ‘show at top’.

Also, for performance reasons, you will want to enable 3D hardware acceleration under Machine->Settings->Display, if you didn’t follow my earlier advice to stop it running like a dog in treacle.

Other Issues

From time to time, I’ve experienced weird focus issues in which my host machine (Ubuntu) will intercept some common keyboard events–namely those using the <super> (aka ‘Windows’ key), which is important for both Ubuntu and Luna–which is extremely annoying.

Also, even with hardware acceleration, I’m having problems with inconsistently laggy/slow Gala (the Window manager) transitions, specifically when it comes to switching workspaces using the <super>+<left/right> shortcuts.

Conclusion

Now you’re ready to explore. If you’re experiencing any difficulties related to the above tutorial, leave a comment and I’ll try to elaborate or clarify if necessary. I find Elementary OS, plus LAMPP, a very lightweight webserver combo, hint, hint 😉

Comments No Comments »

A big bug in the Linux version of Pinta has stopped me from using it as my Photoshop replacement. Here’s my situation: I have an image of one of our Superwoman models, for example, that is quite large, but Superwoman herself is quite tiny, in the middle of the background. I select the whole image, and copy it to the clipboard as-is. I don’t want to use the select or crop tool. I create a new canvas that is smaller than the source image in either height or width, and then paste in my image to the new canvas, so I can move it around and position it just right without having to guess using the select tool on the original.

Make sense? Hopefully! Anyhow, Pinta in its default state, SQUASHES the image to fit the canvas, if you tell it not to resize the canvas, and it looks completely wrong, it literally squashes the image from top down, you know what that looks like without a screenshot, right? I’ve fixed it in my own sourcecode copy and Pinta now behaves as I want it to. I’m not sure the devs would want my changes, but I’ll ask anyhow.

1. Grab a copy of the source, by whatever means by using Terminal (install Git first using “sudo apt-get install git”).

2. Then clone the repo with: “git clone git://github.com/PintaProject/Pinta.git”.

3. Now your source tree is ready, it will be in your Home folder under a folder called ‘pinta’. Install MonoDevelop, and open the Pinta.sln solution file using it.

4. Once open, find the Pinta.Core/Classes/Document.cs file, and after line 806, find:

            // If the pasted image would fall off bottom- or right-
// side of image, adjust paste position
x = Math.Max (0, Math.Min (x, canvas_size.Width – cbImage.Width));
y = Math.Max (0, Math.Min (y, canvas_size.Height – cbImage.Height));

Simply change it so it looks like this:

             // Modified by Tidosho. Image would be stretched/squashed if canvas was smaller and user chooses not to resize it.
//
// If the pasted image would fall off bottom- or right-
// side of image, adjust paste position
//x = Math.Max (0, Math.Min (x, canvas_size.Width – cbImage.Width));
//y = Math.Max (0, Math.Min (y, canvas_size.Height – cbImage.Height));

It’s a bit of a dirty hack, as it simply comments the procedure out, but it works. A possible fulltime modification could be a controllable scale type operation like in Photoshop where you control the scale using handles round the image, but I don’t think Pinta has a scale API.

UPDATE: It isn’t as serious as I first thought, but still annoying. The reason the image is squashed when pasted is because Pinta uses squashed thumbnails for use in the open documents list, and the History. As soon as you drag the layer pasted in, it corrects itself, but then you have to drag it back into position.

 

Comments No Comments »

Mika recently gave me her old eMachines E625 laptop after she bought a new one from me. I dual booted it with Linux Mint, as there was still some of Mika’s files under Vista that she wanted to keep. The only thing that didn’t work was the wireless. The card appeared to be installed under Device Driver Manager, but I received the message “Device not ready – firmware missing.”

I was scratching my head for ages. Using Ethernet for the time being, I tried downloading official Broadcom wireless Linux drivers and building them, but that hit a wall with Error 3 (I never did find out what that was). I swapped drivers under Device Driver Manager, still no luck. Admitting defeat, I phoned my linux chick, Kana, and her simple solution made us both laugh! She told me to open Software Manager, search for “b43”, and install the package “firmware-b43-installer”. It worked! The wireless on/off button light also worked!

She said you can also use Terminal by typing “sudo apt-get install firmware-b43-installer”, but to do that you’d need to have known the package name first. I love you, Kana, my gorgeous Japanese geek goddess xxx Seriously, everyone should have a Japanese geeky programmer for a ladyfriend!

Comments No Comments »

Unless you’ve freshly installed Ubuntu or Linux Mint Ubuntu & Debian Editions, you’ll probably notice that each time you boot up, the GRUB bootloader menu lists a bunch of previous Linux kernels which you can boot into. While this can come in handy for disasters – if you suddenly can’t boot into the new kernel after an upgrade – those previous kernels, images and modules are mostly just wasting disk space.

While you can manually go into Synaptic Package Manager, search for all the bits and pieces of previous kernels, and mark them for removal, here is a much easier method, thanks to Kana, she’s a Linux consultant and teaches me Linux using Mint, OpenSuSE and Debian. In a terminal, simply paste the following command, and it will remove all but the current kernel (if you’ve upgraded your system, or had an update with a new kernel, please reboot your machine before running this). It will also remove old graphics driver modules for old kernels, and modules related to VirtualBox if installed:

dpkg -l ‘linux-*’ | sed ‘/^ii/!d;/'”$(uname -r | sed “s/\(.*\)-\([^0-9]\+\)/\1/”)”‘/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d’ | xargs sudo apt-get -y purge

Yeah, I know, looks like Geek hieroglyphics, doesn’t it? Kana said she studied the docs for Debian Packager and Apt to get all that! You will see some info about what is going on:

The following packages will be REMOVED:
linux-headers-2.6.35-22* linux-headers-2.6.35-22-generic*
linux-headers-2.6.35-23* linux-headers-2.6.35-23-generic*
linux-image-2.6.32-25-generic* linux-image-2.6.35-22-generic*
linux-image-2.6.35-23-generic*
0 upgraded, 0 newly installed, 7 to remove and 13 not upgraded.
After this operation, 586MB disk space will be freed.
(Reading database … 261863 files and directories currently installed.)
Removing linux-headers-2.6.35-22-generic …
Removing linux-headers-2.6.35-22 …
Removing linux-headers-2.6.35-23-generic …
Removing linux-headers-2.6.35-23 …
Removing linux-image-2.6.32-25-generic …

It will then generate a new GRUB menu, and when you reboot, you’ll see only the current kernel is listed. Kana uses this all the time, she says she’s never had any trouble with it 🙂 Aren’t geeky girlfriends cool?

Comments No Comments »