Category Archives: Useful Items That I Forget

Copy a VirtualBox Hard Drive Image/Clone it

I always forget about the clonevdi option to vboxmanage so I always end up just copying the vdi manually.  But I need to create a new uuid for the freshly copied hard drive image.  Here’s what I always forget:

vboxmanage internalcommands sethduuid [[filename]]

Now that I’ve recorded it here I won’t have to search for it next time (Yeah, right).

Tunneling a Windows/Samba Share over SSH with PuTTY

Here are my notes for tunneling a samba share to a local computer between two locations.

A little background:

The server site is running a Debian Linux server with openssh. This server acts as a firewall running iptables. There is another host inside of the server site which is running Samba and serving shares to Windows hosts within that network. I needed to get access to the share so I could continue to work on a book.

The client machine I’m writing on is running Windows XP and I’m using PuTTY to access the remote/server site.

Essentially, getting access to the share involves adding a Microsoft Loopback Adapter to the local Windows XP client machine, giving that a real IP, one that’s really in my subnet, and then port forwarding through Putty, with a source port of that IP (172.16.0.30:139 for my case) to the remote host port 139.

The Microsoft Loopback Adapter is added through Control Panel, Add Hardware.

This worked quite well until I rebooted (for other reasons (Windows Update, if you must know)). When I rebooted it seemed that the Microsoft Loopback Adapter got NetBIOS services bound to it. In order to correct this problem, I went into the properties of the Microsoft Loopback Adapter network connection and unchecked the Client for Microsoft Networks, and the File and Printer Sharing checkboxes. Then I could connect again.

Debian Backports

Here’s stuff that I forget. Like how to install something from Debian backports.

apt-get install debian-backports-keyring
apt-get -t etch-backports install package-name

http://www.backports.org/dokuwiki/doku.php?id=instructions

Don’t forget to add to /etc/apt/sources.list:
deb http://www.backports.org/debian etch-backports main contrib non-free

It’s not a bad idea to make sure that etch-backports then updates that file. So pin it in /etc/apt/preferences (that file might not exist):

Package: package-name
Pin: release a=etch-backports
Pin-Priority: 200

Windows Vista Domain Join Error “format of the specified network name is invalid”

I’ve been working with Windows Vista for a while and recently got an error when working with it in domain mode, that is, a Windows Server 2003 server domain. I had recently renamed the domain and was receiving an error like the “format of the specified network name is invalid”. After some troubleshooting I found it to be a DNS-related problem.

Specifically, the domain server couldn’t resolve its own hostname any longer and therefore was having problems which translated directly into the Vista PC not being able to join the domain.

Here’s the scenario: The Windows server was master for the example.com domain and was also the DNS master authority for that same domain. Its hostname was win2k3.example.com and it was happily able to look itself up within its own zone file. I renamed the domain to example.org using the Microsoft domain rename tool. However, the hostname of the server still remained win2k3.example.com.

I ended up running tcpdump from my real DNS servers and noticed that when the Vista client attempted to join the domain that the client started sending out DNS queries for win2k3.example.com. Obviously, since this domain didn’t exist any longer on the network, it couldn’t resolve the hostname and therefore the domain join failed. I went onto the Windows 2003 server and changed the hostname to win2k3.example.org. After the required reboot (and why is a reboot required just to change the hostname?) the domain join worked perfectly.

Changing Boot Order in Grub and LILO

One question I’ve seen in a few forums is how to change the default boot order of operating systems when using Linux (Debian, Ubuntu, Red Hat, others) and more specifically when using either the GRUB boot loader or LILO. There are of course various reasons for doing so such as making a different kernel boot by default or making Windows boot first, and so on.

Since I tend to compile my own kernel, I find that I work closely with both boot loaders, depending on the Linux flavor installed.

Note: The methods described herein are ones that I’ve used. Use caution if you choose to use them in your set ups. Because you’re working with boot loaders, you can make it so that the computer won’t boot, potentially losing all of your data and whatever else that may bring. I wouldn’t recommend using anything here on your computer. If you mess up or misinterpret my notes here, you might break your rig.

Grub

To change the boot loader order in GRUB you need to edit menu.lst. The location of that file is usually /boot/grub/menu.lst, but it might be elsewhere, maybe in the /etc hierarchy. If it’s not at /boot/grub/menu.lst (that’s where you’d find it on Debian Etch), then do this to find it:

find / -name "menu.lst"

Edit menu.lst in your favorite editor. A simple editor to use is nano (run: apt-get install nano). I personally use Vim. Within menu.lst, you’ll see a section like this, though the content may vary:

title Debian GNU/Linux, kernel 2.6.22.1
root (hd0,0)
kernel /vmlinuz-2.6.22.1 root=/dev/sda3 ro
savedefault

title Debian GNU/Linux, kernel 2.6.22.1 (single-user mode)
root (hd0,0)
kernel /vmlinuz-2.6.22.1 root=/dev/sda3 ro single
savedefault

title Debian GNU/Linux, kernel 2.6.16.7
root (hd0,0)
kernel /vmlinuz-2.6.16.7 root=/dev/sda3 ro
savedefault

Essentially, with that configuration of menu.lst, the first section will be the kernel/OS that loads. Therefore, to change the order, move kernel/OS choice to the top. So, for example, if I wanted kernel 2.6.16.7 to load by default, I’d move its section to the top and the code would then look like this:


title Debian GNU/Linux, kernel 2.6.16.7
root (hd0,0)
kernel /vmlinuz-2.6.16.7 root=/dev/sda3 ro
savedefault

title Debian GNU/Linux, kernel 2.6.22.1
root (hd0,0)
kernel /vmlinuz-2.6.22.1 root=/dev/sda3 ro
savedefault

title Debian GNU/Linux, kernel 2.6.22.1 (single-user mode)
root (hd0,0)
kernel /vmlinuz-2.6.22.1 root=/dev/sda3 ro single
savedefault

That’s all there is to it. Save menu.lst of course.

LILO

Like Grub, lilo also has a configuration file that controls the boot options. Lilo’s config file is usually found at /etc/lilo.conf. Edit this file in your editor of choice.

Within that file, usually towards the bottom, you’ll have some sections like this:


image=/vmlinuz
label=Linux
read-only
initrd=/initrd.img

image=/vmlinuz.old
label=LinuxOLD
read-only
optional
initrd=/initrd.img.old

other=/dev/hda3
label=windows

Usually above those definitions you’ll see something like this:

default=Linux

The name after the equals sign, “Linux” in the example above, corresponds to the label option within the image/definition stanza. Therefore, to change the default operating system to say, LinuxOLD from the example, you’d simple change the default line like this:

default=LinuxOLD

For most installations that dual boot or multi-boot Linux and Windows, the label might be simply “windows”. Therefore, the line would be:

default=windows (though obviously this depends on the label of the actual windows stanza so use with caution.)

Once you save lilo.conf it’s important that you run the lilo command. Simply typing lilo at the command prompt should run it just fine (as root). If you forget to run the lilo command after editing the lilo configuration file then the changes won’t take effect and you’ll be left wondering why it didn’t work. Trust me, I’ve been there as have countless others. Run lilo after making changes to lilo.conf.

Debian keyring “WARNING: The following packages cannot be authenticated!”

When you get this error: “WARNING: The following packages cannot be authenticated!”, you should install debian-archive-keyring.

Related error:
W: GPG error: http://192.168.1.2 etch Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY A70DAF536070D3A1 NO_PUBKEY B5D0C804ADB11277
W: You may want to run apt-get update to correct these problems

That’s all. I know I’ll forget otherwise.

Update 9/1/2007: Run apt-get update afterwards.

DTMF in Asterisk

Had a small issue today with a GXP-2000 where Asterisk wasn’t correctly hearing the digits dialed for a user’s voicemail. It couldn’t pick up the username with a “Couldn’t read username” error when using sip set debug peer peername. Turned out that the settings had changed for that individual account for DTMF. Changing DTMF from “In-Audio” to “Via RTP” fixed it. I said it was a small issue, not an interesting one.

Default Editor in Debian Etch

Somehow it appears that the default editor got switched to Nano on the upgrade from Debian Sarge to Etch. At least I think it did. I would certainly remember having to use Nano before and would’ve been sufficiently annoyed to change that.

I messed up a couple crontab entries, expecting to be editing with Vi but instead editing with Nano. Ouch. I caught it but it’s amazing how much habitual hitting ESC to switch between modes in Vi becomes, along with the other keys to come out of command mode within Vi. Those certainly don’t work so well in Nano.

Trying to switch gears mentally from Vi mode to Nano mode after 17 straight hours on the computer is somewhat difficult.

Anyway, /etc/alternatives holds all that fun stuff in Debian and this command will change the setting for the editor:

update-alternatives --config editor

As a side note, I have multiple categories in my blog and this one really fits into both “Random Rants” and “Useful Items That I Forget”.

No word lists can be found for the language en_us

During the Debian dist-upgrade from sarge to etch, I uninstalled aspell and associated packages on one of my servers. So, when I got around to installing it again, it apparently didn’t install a language or word list. Trying to run a spell check from mutt resulted in:

No word lists can be found for the language en_us.

I installed the aspell-en package and all was well. Turns out I didn’t have any spelling errors in my e-mail anyway.

Steve

Add to Places Menu in Ubuntu

Here’s something I forget.

Adding a location to the ‘Places’ menu in Ubuntu. Browse to the location, say, /data, and then select Bookmark -> Add.

It’d be actually kind of helpful if there was an applet or right-click action within the Places menu itself that enabled a location to be set. I wonder if I’ll ever get time to work on that.