Solutions Log by Dan Reiland

1Oct/090

Device Manager does not display devices that are not connected to the Windows XP-based computer

Issue:
Device Manager displays only non-Plug and Play devices, drivers, and printers when you click Show hidden devices on the View menu. Devices that you install that are not connected to the computer (such as a Universal Serial Bus [USB] device or "ghosted" devices) are not displayed in Device Manager, even when you click Show hidden devices.

Workaround:

  1. Click Start, point to Run, and type cmd.
  2. Click Ok
  3. At the command prompt, type the following command and then press ENTER:
    set devmgr_show_nonpresent_devices=1
  4. Type the following command at the command prompt and then press ENTER:
    start devmgmt.msc
  5. Troubleshoot the devices and drivers in Device Manager. NOTE: Click Show hidden devices on the View menu in Device Managers before you can see devices that are not connected to the computer.

Note that when you close the command prompt window, Window clears the devmgr_show_nonpresent_devices=1 variable that you set in step 2 and prevents ghosted devices from being displayed when you click Show hidden devices.

If you are a developer or power user and you want to be able to view devices that are not connected to your computer, set this environment variable globally:

  1. Right-click My Computer.
  2. Click Properties.
  3. Click the Advanced tab.
  4. Click on the Environment Variables tab.
  5. Set the variables in the System Variables box.

NOTE: Use this method only for troubleshooting or development purposes, or to prevent users from accidentally uninstalling a required device that is not connected to the computer (such as a USB device or docking station that is not connected to a laptop computer).

Reference: http://support.microsoft.com/kb/315539

30Sep/090

Clear Spotlight Index

From a terminal window:

sudo mdutil -avE

That is, sudo (because you have to have admin rights to run this), mdutil (the program that does the work for you) -a for “work on all volumes”, -v for “be verbose in telling me what you’re doing”, and -E for “erase the data store and rebuild it”.

27Aug/090

Disable disk checking during boot on Linux systems

Issue:
Linux (appropriately) checks filesystems after a number of boot cycles.

Cause:
This is by design. By default, ext[2,3,4] filesystems are automatically checked every 34 mounts or 180 days (whichever comes first).

Resolution:
In some cases (ephemeral machine instances in a cloud) this behavior is undesirable. It may be tuned with the following:

To disable it use the following at the terminal:

tune2fs -c 0 -i 0 /dev/hdXY

Set it to check after 30 system boots

tune2fs -c 30 -i 0 /dev/hdXY

Also ensure that your /etc/fstab file reflects a similar setting. The sixth column should contain a 0 (never check) rather than a 1 (check at boot).

25Aug/090

Convert a .dmg to a .iso

Issue:
Mac formatted disk image (.dmg) cannot be directly burned on Windows or Linux systems.

Resolution:
One can convert a .dmg to a CD master via the Disk Utility application embedded in OS X, or by opening a terminal window and issuing the following command:

hdiutil convert /path/to/filename.dmg -format UDTO -o /path/to/savefile.iso

The output file will be named savefile.iso.cdr -- you may strip the .cdr and burn the .iso with any standard utility for doing so.

Tagged as: , , No Comments
25Aug/090

Mirror a Directory Structure Using the Command Line

Issue:
You need to mirror the directory structure (but not contents) for a tree.

Resolution:
Execute the following command from the root of your source directory. Adjust the destination variable to suit your tastes: %i will match the first token, %j the second, %k the third, and %l will match everything else.

for /F "tokens=1,2,3* delims=\" %i in ('dir /Ad /B /N /S') do mkdir t:\dest\%l

Reference: http://www.dostips.com/DtTipsStringManipulation.php

19Aug/090

C compiler cannot create executables received after emerge world

Issue:
When attempting to emerge a new package after a recent emerge -DunNv world the new package emerge fails with:

. . .
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for builtin ELF support... yes
checking for ELF core file support... yes
checking for file formats in man section 5... no
checking for i686-pc-linux-gnu-gcc... i686-pc-linux-gnu-gcc
checking for C compiler default output file name...
configure: error: C compiler cannot create executables
See `config.log' for more details.
. . .

Cause:
The issue is related to gcc being upgraded as part of a previously executed emerge world. The /etc/ld.so.conf and /etc/env.d/05gcc-i686-pc-linux-gnu files no longer point to valid gcc library and binary paths.

Resolution:
Gentoo provides the gcc-config command to set the active gcc compiler profile.

Sample gcc-config run to list the available gcc profiles and set the active profile to option 1:

root # gcc-config -l
 [1] i686-pc-linux-gnu-4.3.2 *
root # gcc-config 1
 * Switching native-compiler to i686-pc-linux-gnu-4.3.2 ...               [ ok ]

Reference: http://forums.gentoo.org/viewtopic.php?t=27486&highlight=gcc

Filed under: Linux, sysadmin No Comments
13Aug/090

Shrink VirtualBox vdisks After Freeing Space (Windows guests)

Issue:
On dynamically allocated vdisks, freed space on a guest is never released back to the host once freed.

Cause:
This is by design.

Resolution:
The procedure for shrinking (compacting in VirtualBox parlance) is straightforward and consists of a series of steps.

  1. Delete files on the guest to achieve the desired amount of free space
  2. Zero free space out with an appropriate utility
  3. Shut down guest
  4. Compact disk

Zeroing guest free space is simple: Microsoft provides an excellent utility through its Sysinternals group called SDelete. Download the program, extract it from the archive, and execute it on the disk to be zeroed. Note: this procedure only zeroes free space.

sdelete -c

One the zeroing procedure is completed, you may power off the guest and compact the virtual disk from the command line.

VBoxManage modifyvdi /path/to/machine.vdi compact

Note: This was tested against VirtualBox 3.0.4 r50677

References:
SDelete

Tagged as: No Comments
13Aug/092

Create a Large File For Testing

Issue:
Often you need a set of variable sized files for testing a particular scenario. Generating test data is a painless endeavor.

Resolution:
The Unix dd command is perfectly suited to dispatch this need.

dd if=/dev/zero of=~/testfile.txt bs=1m count=5

The above command will create a 5 megabyte file full of zeroes. Lovely. You may adjust the count (or blocksize) to achieve the results you desire. This data also achieves stellar compression ratios based on its content.

One could also create a test file full of pseudo random data by pointing if to /dev/urandom.

dd if=/dev/urandom of=~/testfile.txt bs=1m count=5

Explanation of /dev/urandom

10Aug/090

Remote Mirroring Using nc and dd

You can use the dd and nc commands for exact disk mirroring from one server to another. The following commands send data from Server1 to Server2:

1
2
Server2# nc -l 12345 | dd of=/dev/sdb
Server1# dd if=/dev/sda | nc server2 12345

Make sure that you issue Server2's command first so that it's listening on port 12345 when Server1 starts sending its data.

Unless you're sure that the disk is not being modified, it's better to boot Server1 from a RescueCD or LiveCD to do the copy.

Reference: http://www.linuxjournal.com/content/tech-tip-remote-mirroring-using-nc-and-dd

29Jul/090

PowerDNS continually dies after creating a slave zone

Issue:
When PowerDNS is configured for a sqlite or sqlite3 backend and a slave zone is added, the PowerDNS daemon continually dies and respawns. This loop persists until the daemon is forcibly terminated.

My logs showed the following:

Jul 29 12:12:38 localhost pdns[14465]: PowerDNS 2.9.22 (C) 2001-2009 PowerDNS.COM BV (Jul 29 2009, 04:47:43, gcc 4.3.3) starting up
Jul 29 12:12:38 localhost pdns[14465]: PowerDNS comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it according to the terms of the GPL version 2.
Jul 29 12:12:38 localhost pdns[14465]: DNS Proxy launched, local port 22293, remote 192.168.8.1:53
Jul 29 12:12:38 localhost pdns[14465]: Launched webserver on 0.0.0.0:8081
Jul 29 12:12:38 localhost pdns[14465]: Master/slave communicator launching
Jul 29 12:12:38 localhost pdns[14465]: Creating backend connection for TCP
Jul 29 12:12:38 localhost pdns[14465]: gsqlite3: connection to '/var/lib/powerdns/pdns.db' succesful
Jul 29 12:12:38 localhost pdns[14465]: gsqlite3: connection to '/var/lib/powerdns/pdns.db' succesful
Jul 29 12:12:38 localhost pdns[14465]: About to create 3 backend threads for UDP
Jul 29 12:12:38 localhost pdns[14465]: gsqlite3: connection to '/var/lib/powerdns/pdns.db' succesful
Jul 29 12:12:38 localhost pdns[14465]: 1 slave domain needs checking
Jul 29 12:12:38 localhost pdns[14465]: Domain domain.local is stale, master serial 349, our serial 0
Jul 29 12:12:38 localhost pdns[14465]: Initiating transfer of 'domain.local' from remote '192.168.8.40'
Jul 29 12:12:38 localhost pdns[14465]: gsqlite3: connection to '/var/lib/powerdns/pdns.db' succesful
Jul 29 12:12:38 localhost pdns[14465]: AXFR started for 'domain.local', transaction started
Jul 29 12:12:38 localhost pdns[14465]: Communicator thread died because of error: Database failed to start transaction: Error while retrieving SQLite query results

Cause:
The PowerDNS sqlite and sqlite3 backends do not support slave zones as of v.2.9.22

Resolution:
Configure PowerDNS to use a different database backend: MySQL, PostgreSQL, Oracle, etc.

Tagged as: , , No Comments