Posted on Thursday 14 August 2008
You used to be able to use tzconfig to set the time zone in Ubuntu. With Hardy Heron you can no longer do this, so how do you do it? Simple:
sudo dpkg-reconfigure tzdata
You used to be able to use tzconfig to set the time zone in Ubuntu. With Hardy Heron you can no longer do this, so how do you do it? Simple:
sudo dpkg-reconfigure tzdata
In Debian / Ubuntu, sometimes you want to keep a package at a specific version, and not upgrade it. For instance, the Perl module DateTime::Timezone in Ubuntu Dapper lists its version as 1:0.37-1, when the version is actually 0.37. This makes it difficult if I build a new package of the perl module at version 0.7701, because though I can force install that version, if I run an apt-get upgrade later, it’s going to install the former, because it sees it as version 1, which is greater than 0.77.
Fortunately, the fix is easy: put the package on hold. This prevents it from being upgraded, though that also means you won’t get updates to it from the main repositories. If you built it yourself, then that might not be such a bad thing. To put a package on hold, you do:
echo packagename hold | sudo dpkg --set-selections
Replace packagename above with the name of your package (for instance, I would put libdatetime-timezone-perl). Did it work? Let’s see!
$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree... Done
The following packages have been kept back:
libdatetime-timezone-perl
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
$
Looks good to me!
Reference
Due to the recent ssh vulnerability, many releases of Ubuntu found themselves with vulnerable ssh keys.
User Keys
Run ssh-vulnkey to see if you’re unlucky. If you are, you’ll have to regenerate your keys.
ssh-keygen -t rsa
That’s it. If you’re using dsa, use dsa in the above instead of rsa. You should let it overwrite your existing key file. Remember to clean up ~/.ssh/authorized_keys (or ~/.ssh/authorized_keys2) on the servers that might have your old key!
Server Keys
Dumping and re-creating your own keys is okay, but what about the server?
For ssh1 keys, do:
ssh-keygen -q -f /etc/ssh/ssh_host_key -N '' -t rsa1
For ssh2 keys, do the following:
ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa
Note that when you first connect to the server thereafter, it’ll warn you that the keys have changed. Well, obviously, you just regenerated them. You may have to manually edit
~/.ssh/known_hosts
to remove those lines.
Reference
If you’re like me, you may need to build your own packages in Debian, or perhaps have downloaded different versions of packages to install on your system. Sometimes you’d like to go the other way, though, and install an older version of a package you found in the repository, or even the same version, but a different build.
For example, let’s say you built your own version of perl, say 5.8.8-7blindedbytech1. Then, Debian finally gets the same version of perl into their repositories, say 5.8.8-7etch3. Unfortunately, doing an apt-get dist-upgrade isn’t going to install this version. This is particularly annoying if other packages have dependencies on these perl versions.
What’s one to do? Wouldn’t it be nice if you could specify which version of perl package to install? As it turns out, you can. When you do the apt-get install of the package, follow it by an equal sign (=) and the particular package version you want, e.g:
sudo apt-get install perl=5.8.8-7etch3
Obviously, this will only work if the specific version is in one of your repositories. You can do this with multiple packages, too. In fact, I had to, because perl-base was also a different version:
sudo apt-get install perl=5.8.8-7etch3 perl-base=5.8.8-7etch3
Be careful of dependencies. Don’t just blindly run these commands unless you know what you’re doing, and be sure to read the output messages, as it may have unintended effects. For instance, for me, the above command uninstalled mysql-server. Make sure you read the warnings it gives you, and you understand what they mean.
As I don’t always have an Internet connection, being able to get my laptop online through my cell phone (a Blackberry Pearl 8100 on T-Mobile) is quite useful. Here’s how you do it. I presume at this point you’ve already installed the Blackberry Desktop software, and can sync fine over USB.
Determine COM Ports
Right-click on “My Computer” (often found in the Start Menu), and select “Properties”. Click on the “Hardware” tab, and then the Button for “Device Manager”. Expand the section for “Ports (COM & LPT)”. You should see a couple entries here for RIM Virtual Serial Port v2 — for me these were “COM4″ and “COM5″.
Note the COM numbers for these entries. Close out.
Set Up Network Connection
Go to the “Control Panel”, and open up “Network Connections”. (If you have category view enabled, you may have to go to “Network and Internet Connections” first, before being able to select “Network Connections”. Go to “File->New Connection”, which will launch the “New Connection Wizard”. Do not do the Network Setup Wizard — that’s something else.
Click Next. Leave the option as “Connect to the Internet”, and click Next. Select “Set up my connection manually”, and click Next. Select “Connect using a dial-up modem”, and click Next.
At this point it should be asking you to select a device. Make sure to select the entry for one of the COM ports you found above. I noted above that COM ports 4 and 5 were for RIM, and here the only one showing up was COM4, so my choice is pretty clear. Select the correct one, and click Next.
For ISP name, put in whatever is meaningful to you so you know what it’s for. For instance, I called mine “T-Mobile (Blackberry)”. Click Next.
For Phone number, put in the following and click Next: *99#
For “Internet Account Information”, leave the fields blank. Leave “Use this account name and password…” checked, and uncheck the box for “Make this the default Internet connection”. Click Next. That should be the final page of the Connection Wizard, so click Finish.
This will probably pop up the “Connect T-Mobile (Blackberry)” dial-up wizard. Don’t connect yet. Close this out, because we need to make some changes to the modem first.
Go back to “Control Panel”, and go to “Phone and Modem Options”. (If you have Category View enabled, you may have to select “Printers and Other Hardware” first.) On the “Modems” tab, you should see the modem you selected above listed (e.g. “Standard Modem; highlight it and hit Properties.
This will bring up the properties window specific to that modem. On the Advanced tab, there’s a box for “Extra initialization commands”. In here, put the following:
+cgdcont=1,"IP","wap.voicestream.com"
If that doesn’t work, use the following instead:
+cgdcont=1,,"wap.voicestream.com"
OK all the way out, and launch the connection again. You can find it in the Control Panel under Network Connections (again, if you have Category View enabled, you may have to navigate into “Network and Internet Connections” first), under the Dial-up section. Alternatively you may find it under Start->Connect To on the Start Menu, if you have the new style Start Menu enabled.
Click Dial, and it should connect!
While I tend to like running Ubuntu on the desktop, I sometimes find myself needing to run Windows programs for various things. For that, I actually got VMware Workstation for Linux, and set up a Windows XP Professional image, with a partition size of 8 GB. I rarely use the image, so imagine my surprise when I actually ran out of disk space in the partition. I was further confounded to find that you couldn’t dynamically resize the partition. The problem is twofold: needing to resize the VMware disk image, and then needing to resize the partition on which Windows is installed to fill the VMware disk image.
Resize the VMware Disk Image
To resize the VMware disk image, we can use the program vmware-vdiskmanager. Make backups before proceeding. I had an 8 GB partition now, so let’s make it a 40 GB partition instead:
$ vmware-vdiskmanager -x 40GB /path/to/my/image/mywindowsimage.vmdk
Using log file /tmp/vmware-jlee/vdiskmanager.log
The old geometry C/H/S of the disk is: 16383/16/63
The new geometry C/H/S of the disk is: 16383/16/63
Disk expansion completed successfully.
WARNING: If the virtual disk is partitioned, you must use a third-party
utility in the virtual machine to expand the size of the
partitions. For more information, see:
http://www.vmware.com/support/kb/enduser/std_adp.php?p_faqid=1647
Good so far. Now, the disk image is 40 GB, but the partition on the disk is still set to 8 GB. What we want to do is grow the partition to fill the newly allocated space.
Boot an Ubuntu Live CD
To resize the partition, I can use a Linux live CD. Rather conveniently, I can use the same Ubuntu live CD that I used to install Linux on my desktop.
It took me a while to figure out how to boot a CD in VMware, mostly because the BIOS screen for VMware disappears so quickly. When starting up the VMware image, I hit F2 quickly before Windows started loading to enter the VMware BIOS. Then I could go to the Boot menu, and set the CD-ROM drive to boot before the hard disk. Otherwise, it would start directly into Windows.
Once that was done, I made sure that a Gutsy Gibbon live CD was in the CD-ROM drive, and restarted the VMware image.
Resize the Partition
Now I had the Ubuntu live CD running in my VMware image. I went to System -> Administration -> Partition Editor. I clicked on the partition, clicked “Resize/Move”, and dragged the right slider all the way to the right, to fill the disk. I clicked the “Resize/Move” button, then “Apply”. After it completed, I restarted the VMware image, which prompted Windows chkdisk to run, and then reboot again. Once Windows booted up, Windows noted that it had detected new hardware and needed a reboot. I let it do so, and just like that, I had grown my 8 GB drive to 40 GB.
Conclusion
So there you have it — if you have half an hour and a current Ubuntu live CD, you can resize your VMware image. As with any disk editing operations, you should always make backups before making changes. It’s kind of annoying that the image doesn’t dynamically grow, but it’s nice to know that it can be handled. What’s also cool is to be able to use Linux live CDs to edit properties of VMware instances.
Compiz Fusion on a Radeon Mobility X1400 graphics card? Hell yeah!
Oh, driver hell. Proprietary drivers are the bane of Linux’s existence, as any Linux user with a current ATI graphics card can tell you. I have a Lenovo Z61m on which I’d like to install Ubuntu Gutsy Gibbon, but good luck — the ATI Radeon Mobility X1400 will wreak havoc on your installation procedure. This is not new; Feisty Fawn had the same problem. Fortunately, you can in fact work around it.
Installing From the Live CD
First, there’s getting the live CD to work. You can download the alternate install CD and work from text mode, but I’d much rather use the regular live CD. Fortunately, you can! Boot up the live CD, and it’ll eventually die at some point, because the X server can’t launch properly. Hit Cntrl + Alt + F2 to jump to a virtual console. Type clear to clear the screen, then type the following:
sudo apt-get update sudo apt-get install xorg-driver-fglrx sudo depmod -a sudo aticonfig --initial sudo aticonfig --overlay-type=Xv startx
You’ll obviously need a working Internet connection to make this work. Congratulations, you can now use the live CD! Run the installer as per normal.
Special note for Lenovo users: Do not delete the FAT32 service partition! You can use this to restore your Windows partition or run other diagnostics. I found it worked well to resize the existing Windows partition and dual boot.
After installation, you’ll reboot your system and — surprise! It doesn’t work. It’ll die at loading the X server again. Hit Cntrl + Alt + F2, and enter the following:
sudo apt-get update sudo apt-get install xorg-driver-fglrx sudo apt-get install xgl sudo apt-get install xserver-xorg-video-radeonhd sudo depmod -a sudo aticonfig --initial sudo aticonfig --overlay-type=Xv startx
This is slightly different than before. Why? Well, no doubt you want to use those fancy Compiz Fusion effects, right? You didn’t need them to do the installation, but installation is done now. You’ll need to get the right drivers, as well as install xgl. Once you’ve done that, you might also need to edit /etc/X11/xorg.conf to change Option "Composite" "0" to Option "Composite" "1". After that, you should be able to enable Visual Effects through System->Preferences->Appearance, Visual Effects tab.
If you’re a debian user (this includes all of you Ubuntu folks!), then you may be familiar with the strangeness of status codes for dpkg -l. For example, let’s say you install postfix:
sudo apt-get install postfix
We can look at the package list with dpkg -l. Let’s take a look at postfix:
$ dpkg -l | grep postfix
ii postfix 2.2.10-1ubuntu0.1 A high-performance mail transport agent
The ii at the start is some sort of status. Let’s remove the package:
sudo apt-get remove postfix
All fine and good, until we take a look at dpkg again:
$ dpkg -l | grep postfix
rc postfix 2.2.10-1ubuntu0.1 A high-performance mail transport agent
Hmm. Instead of removing it from the list, we see this peculiar rc status. What the heck does that mean?
The answer lies in the dpkg listing itself.
$ dpkg -l | head -3
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
There are three columns here, though y ou usually don’t see the third.
So, if you take the first letter of each potential state for each of those, you get your status code for dpkg. Let’s look at the some of these status codes again:
ii: Desired: (I)nstall; Status: (I)nstalled; Err: none.
rc: Desired: (R)emove; Status: (C)onfig-files; Err: none.
pi: Desired: (P)urge; Status: (I)nstalled; Err: none.
Mystery solved!
I have a Lenovo X41 Tablet PC that I had installed Ubuntu onto. I recently decided to re-install the original Windows software, so I ordered the CDs from Lenovo and broke out an external CD drive. However, when I put in the Rescue and Recovery CD and booted the machine, I ended up with a blank black screen and nothing else. What gives? I updated the BIOS and the embedded controller firmwares, but to no avail. The computer would boot up the CD, a brief message about examining the setup would fly by, then a blank screen. I figured this was a problem with the recovery CDs, because my Ubuntu live CD booted right up.
As it turns out, Lenovo recovery CDs are very picky about their hard drive setup. They need to copy files to disk for a variety of tasks, so if you’re using up all the partitions, then the CDs will stop booting, but give you no other errors.
I had previously installed Linux on the machine, so my partition tables were in a state the machine didn’t really understand. What I needed to do was trash the existing partitions, and flush out the boot record.
Easy enough — I fired up the Ubuntu live CD, and launched the partition editor in System -> Administration. I had to turn off the swap space, by right-clicking on it in the partition editor, and selecting “swapoff”. By default, Ubuntu live CDs will scan your drives for partitions marked as swap space, and use it, so you have to turn off this usage to delete the partitions. I ran through and deleted all the partitions, and applied the changes.
I next had to clear out the master boot record, but I could do that right from the live CD. After doing that, I rebooted with the Lenovo Rescue and Recovery CD and said a little prayer.
Once I had done these steps, the recovery CD started right up. I’m surprised Lenovo doesn’t give more details on this in their support knowledge base.
In the old days, a techie might install Windows on a computer, then install Linux. Later, the techie might decide to trash the Linux partitions for some reason, but on reboot — oops! LILO was still there. These days, GRUB has taken the place of LILO, but the old problem is still there: how do you clear out the master boot record completely?
If you had a Windows 98 boot disk lying around, you probably remember the old magic of fdisk /mbr. This simple command did just what you wanted — flashed out the master boot record, and things worked like you expected.
However, in this day and age of Linux live CDs, there must be a way to do so without breaking out the floppies. As it turns out, there is, through a simple program known as dd.
The beginning of a hard drive is where you keep both the master boot record, as well as the partition table. What you want to do is write zeroes to the master boot record, but not the partition table. Many folks recommend writing zeroes to the first 512 bytes of the drive — this is wrong.
The truth is, the first 446 bytes of the drive are dedicated to the master boot record executable. The remaining 66 bytes are used to hold the partition table. Hence, what we need to do is read in a source of zeroes, and output it to the first 446 bytes of the drive. Simple! Let’s take a look at the command:
dd if=/dev/zero of=/dev/hda bs=446 count=1
This says to do just that — use as an input file the special device /dev/zero, an output file of the drive (substitute the drive identifier in question here!), with a block size of 446 bytes. Oh, and do it just once. No nonsense, quick, and effective. So, put away those MS DOS disks — that Linux live CD works just fine.