Random Linux Tips: Making KDE4 Behave, Thwacking Those Weirdo U3 Partitions on USB Sticks

83

 

Sometimes, we have little tips and tricks that make life easier – but don’t quite take up a full article. So today I’ve bundled a few practices that many Linux.com readers might find helpful. You’ll learn how to control window behavior in KDE4, and make Nepomuk and Strigi be useful; and remove those silly proprietary U3 partitions from USB sticks.

 

Making KDE4 Behave

KDE4 comes with eleventy-eight hundred and fifteen fancy special effects, and the one that are turned on by default seem rather random. With a little digging you can figure out how to control them. The one that drives me around the bend is when dragging a window by its title bar maximizes it. This is entertaining when all you want to do is move it. How many ways do we need to maximize windows? Apparently a whole lot of them. But KDE4 has controls for everything, so you can turn this particular feature on or off in System Settings > Workspace Behavior. Go to the Screen Edges screen, and uncheck “Maximize windows by dragging them to the top of the screen.” Click the Apply button and you’re done.

Underneath that is “Tile windows by dragging them to the side of the screen.” What I really want is a one-click tile all windows, like in Windows 3.1 and some Linux desktop environments. But this feature is fairly useful once you figure it out; when you drag a window to the top right or left edge it shrinks to one-quarter of the screen. Drag it to the bottom left or right it shrinks to half-screen size. Drag it away to restore to its previous size.

Do you get tired of swatting KDE’s oversize information pop-ups out of the way? Go to the Workspace screen and un-check “Show informational tips” and then click Apply.

The fine KDE4 folks have invested a lot of energy into the semantic desktop and semantic search. You’ve probably heard some of the wailing against Nepomuk and Strigi because they crash or bog down the whole system. Together they index files, file metadata, comments, tags, ratings, and file contents.

Nepomuk and Strigi do bog down your system on their first run. If you can leave your computer running until they complete that initial indexing, then after that you won’t even notice them. For example, on my system with a nearly full 2TB hard drive, the first run took about two days, and it used a fair whack of CPU cycles. Nepomuk and Strigi indexed over 80,000 files, and the Nepomuk database is now over 700MB. Since that first run I leave them on all the time, and they barely use 1% of memory and CPU.

You can configure Nepomuk and Strigi in System Settings > Desktop Search. On the Basic Settings tab you can turn them on and off, and the Details link tells you the Nepomuk data store statistics. Use the Desktop Query tab to choose which files and directories are indexed by Strigi. By default temporary files, core dumps, and other non-data files are not indexed. The Advanced Settings tab lets you control how much memory Nepomuk uses.

Once you’ve let Nepomuk and Strigi search and index your files, then what? Here is one example. Figure 1 shows the results of a search for “Dick Macinnis” (author of the Dream Studio distribution) from inside the Dolphin file manager. It found emails we had exchanged, and articles I had written that mentioned him.

You can fine-tune your search in a number of ways: Filename, Content, From Here (the current directory), Everywhere, and on the bottom right you can select Documents, Audio, Video, and other file types. Then right-click on any item found in the search to choose which application to open it, open it in a new window with the full file path displayed, and several other useful actions. So even though this semantic stuff is still a baby, it’s already useful.Figure 1: A Strigi search dives deeply into your system.

Getting Rid of Weirdo U3 Partitions on USB Sticks

I have an 8GB Sandisk Cruzer that comes with a special partition loaded with the U3 Launchpad, which is a portable environment for running applications from the USB stick on Windows. There is an actual U3 specification, and compliant applications can write to the Windows registry and load files on a Windows PC. Then when the device is removed the files and registry entries are also removed, and any application settings are stored on the USB stick. This all sounds cool, except it has a hidden partition that you cannot remove by ordinary means and can’t use for data storage, and it won’t let you create a nice bootable Linux USB stick.

The hidden partition presents itself as a USB hub with a CD drive attached. When you plug one of these into a Linux PC it looks like a normal partitioned block device to fdisk and Gparted, but in Figure 2 we see how it looks to the KDE4 Device Notifier: it sees the U3 partition as an optical device, and can mount it and read the files.

On my system it is mounted as /media/U3 System/. The ls command, like so many old Unix-y utilities, doesn’t like spaces in filenames. But not to worry, because we can still list the files with the help of some quotation marks:

$ ls "/media/U3 System/"
autorun.inf  LaunchPad.zip  LaunchU3.exe

You can’t delete these files the usual way. One way is to search your vendor’s site for a delete utility, which most likely will run only on Windows. We hardy Linux users have our own special tool, and that is u3-tool. If it’s not in your distro repo fetch it from Sourceforge. Run it with no options to see an option summary:

$ u3-tool 
Not enough arguments
u3-tool 0.3 - U3 USB stick manager

Usage: u3-tool [options] 

Options:
        -c                Change password
        -d                Disable device security
        -D                Dump all raw info(for debug)
        -e                Enable device security
        -h                Print this help message
        -i                Display device info
        -l      Load CD image into device
        -p       Repartition device
        -R                Reset device security, destroying private data
        -u                Unlock device
        -v                Use verbose output
        -V                Print version information

For the device name use:
  '/dev/sda0', '/dev/sg3'

Try running sudo u3-tool -i /dev/sdc, using your own device name of course, to see the device’s partitions:

 

$ sudo u3-tool -i /dev/sdc
Total device size:   7.51 GB (8065646592 bytes)
CD size:             7.69 MB (8060928 bytes)
Data partition size: 7.50 GB (8057520128 bytes)

 

Use the -D option to dump complete device information. This reveals a number of interesting things, such as “Max. pass. try: 5”. If it is password-protected that means you get five attempts to enter the correct password. If you fail then the device locks and the only way to get back in is to reset the password, which deletes all the data. You’ll also see the serial number, manufacturer, and exact partition sizes.Figure 2: KDE4's Device Notifier sees the special U3 partition.

Sometimes, though not always, you can read these devices on Linux even when they are password-protected. They’ll mount like a normal USB stick with no password. Sometimes Linux won’t even be able to create the block device and you’ll see a ton of these messages in dmesg:

 

[ 5773.262417] sd 8:0:0:0: [sdc] No Caching mode page present
[ 5773.262422] sd 8:0:0:0: [sdc] Assuming drive cache: write through

 

If that’s the case all you can do is open it on a Windows machine and reset the password. This wipes all the data, but at least you can still use the device.

Now we come to the fun part: eliminating the U3 partition entirely. Stuff it into your Linux box and run this command, using your own device name:

 

$ sudo u3-tool -p 0 /dev/sdc

WARNING: Loading a new cd image causes the whole device to be whiped.
 This INCLUDES the data partition.
I repeat: ANY EXCISTING DATA WILL BE LOST!

Are you sure you want to continue? [yn] y

 

And you now have a nice normal universal USB stick without any tricksy Windows-only guff. Enjoy!