Something for your summer holidays: Installing CrunchBang Gnu/Linux in VirtualBox on Debian
It’s been a long time since I posted a computing-related post. So…
This is a brief documentation of how I installed a 32-bit CrunchBang Linux virtual machine on my 64-bit Debian box. Why? Do not ask.. Well, actually, I will explain. I am not an expert, and I find that a lot of instructions gloss over stuff that I spend ages figuring out. On the principle that the right person to explain something is someone who knows a little bit more but not too much more, I am writing this up. Also, so I can use it when I forget everything that is in here.
Step (1) Was go to the http://crunchbang.org/ and download the current 32-bit version, which seems to be named after a salad — ’32-bit Waldorf for Modern PCs’. Named after salads or hotels, I guess. (Must say, I think Linux distros are better w/o names. The whole Toy Story thing with Debian, Ubuntu’s Onanisitic Ocelot, or whatever it is, and so on, doesn’t add much…or maybe I am a humourless and unappreciative twit. Anyway, Debian and #! and other operating systems out there for download are great products and I thank the communities of people who make these resources available to us all.)
Anyway, CrunchBang (#!) is a lean, fast Debian-based distribution, ideal if your hardware is a little behind the times or if you just don’t need the bloat associated with most full distributions.
(2) The iso file was called crunchbang-11-20130506-i486.iso
(3) I put that iso somewhere easy to find — I have a folder called ~/isos for this purpose.
(6) I ran through the installation (it is pretty quick since #! is lean). I took all the default choices, setting up a user account on the way.
(7) Rebooted the guest, then opened a terminal window and:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
(these install all the changes since the iso was minted). You might need to reboot at this point, I can’t say, but apt should tell you.
(8) Then to install the guest additions, which I need to share folders with the host,essential for any serious work on the guest, I suspect, I typed:
sudo apt-get install linux-headers-`uname -r` dkms
Now, what on Earth does this do? Well, the VirtualBox guest additions need to wedge a driver into the Linux kernel to drive all the VB-associated stuff (‘stuff’ is a technical term), and to do that they need a look at the kernel header files, and so I needed to install them. The `uname` part (note the back inverted commas, that’s the key usually up near the ‘1’ and ‘Esc’ on most keyboards) tells the installer for which kernel it needs to grab the headers. dkms helps your system manage kernel modules. You may also want virtualbox-guest-dkms installed on the guest.
It may or may not be a good idea to reboot now. I did.
(9) Then I went to Devices at the top of the #! window and selected Install Guest Additions. Well, actually I searched the web for the Guest Additions CD for my version of VirtualBox, downloaded it as an iso and mounted it as an external CD drive on the guest system. It’s all good.
(10) In a guest terminal, I typed cd /media/cdrom, and looked for a file something like VBoxLinuxAdditions.run. Then
sudo bash VBoxLinuxAdditions.run
I got a few errors, but did not worry. They might not relate to services I need — all I want is shared folders, and the additions do a bunch of other stuff too.
(11) Shutdown the guest.
(12) On the host system, created a folder to share. I called mine ‘shared’ because I have a surfeit of imagination. The full path to it was /home/username/shared.
(13) In the VirtualBox settings for the #! VM, went to ‘Shared Folders’ and added one. Browsed for the folder I just created (‘shared‘) and then gave it a name: ‘shared1'. I add the 1 because them being different helps me remember when to use the name and when to use the path, because I am a simpleton. Do not check ‘automount’. ‘Make Permanent’ is good to check, if it shows up.
(14) Boot up guest machine.
(15) In a terminal on the guest (#!), created the folder to map to the one on the host. Something like
sudo mount -t vboxsf -o gid=1000,uid=1000 shared1 /home/username_on_guest/shared1
So what this does is that VirtualBox creates a ‘device’ called shared1 when you add a shared folder in the user setting on the host. This command then tells the guest to mount that device at /home/username_on_guest/shared1, that it is a VirtualBox file system, and then some options. The ‘1000’ stuff assumes you are the user created during the installation of the guest machine, and may need some tweaking if you have messed with any permissions or if some other random factor is changed. You can also try leaving it out.
If you find something does not work, or you can’t read/write to the folder even if you can mount it, you can try freeing up the permissions on your shared directories at both ends. Something like
chmod 777 shared1
on both host and guest may help, though if it is a shared computer that might compromise your security. Anyway, this is not a tutorial on Linux file permissions. This is.
(16) Created a file in ~/shared on the host. Could I see it on the guest? Yes. Vice versa? Yes.
(17) All that was left was to make the thing automount on booting the guest. On the guest:
sudo cp /etc/fstab /etc/fstab_backup_date
sudo vi /etc/fstab
(I use vi, you use whatever editor you like.) At the end of fstab, I added something like this (should be all on one line):
shared1 /home/username_on_guest/shared1 vboxsf defaults 0 0
so what this does is say mount the device shared1 at /home/username_on_guest/shared1