Thursday, 7 January 2010

grub-probe: error: Cannot find a GRUB drive for /dev/sdb1

I got this error;
grub-probe: error: Cannot find a GRUB drive for /dev/sdb1

after adding a drive to my laptop and running
sudo /usr/sbin/grub-mkconfig

I had to add an entry for the new drive in /boot/grub/device.map
sudo vi /boot/grub/device.map

I added the second line;
(hd0) /dev/sda
(hd1) /dev/sdb

I then regenerated the grub config
sudo /usr/sbin/grub-mkconfig

Finally, I updated grub with the new config
sudo update-grub2

Note: Initially, I failed to update grub with the new config and received another error "Invalid signature" when trying to boot Windows off the second drive.

Monday, 14 December 2009

Blank screen when logging in to VMware server




I use vmware server a lot and unfortunately this happens way too frequently. I'm not sure if the bug lies in Firefox or VMware but there should be a username and password entry box in the middle of that screenshot.

So far I have not found a cure for it.

I do have workaround however, but it's not a pretty one.

Basically, what you have to do is hit ctrl+shift+r quickly and repeatedly until the dialog appears. Stop every half a dozen or so presses to let it catch up and hopefully the dialog will appear. If not, rinse, lather, repeat until it does.

Hardly an elegant solution I know, but at least you will be able to log into your console.

P.S. Performing the same procedure using F5 does not produce the same result (well, not for me anyway)

Sunday, 6 December 2009

Inheriting group ownership for shared files

Use the SGID attribute to allow users to create files that can be opened by other users in their group.

When the SGID (Set Group Identification) attribute is set on a directory, files created in that directory inherit its group ownership. If the SGID is not set the file's group ownership will be set to the user's default group.

To set the SGID on a directory or to remove it, use the following commands:
chmod g+s directory
chmod g-s directory

When set, the SGID attribute is represented by the letter "s" which replaces the "x" in the group permissions:
ls -l public
drwxrwsr-x 10 brett users 4096 2009-012-10 17:40 public

Wednesday, 2 December 2009

Wednesday, 11 November 2009

Sort du output in readable format.

UPDATE: Download script from here

I got sick of typing "du -h --max-depth=1" all the time, and even then the output is not sorted. Unfortunately you cant use the sort util with the human readable output provided by du.

I found the awk part of this shell script in a forum somewhere and it works a treat.


#!/bin/bash
sudo du -k --max-depth=1 $1 | sort -nr | awk '
     BEGIN {
        split("KB,MB,GB,TB", Units, ",");
     }
     {
        u = 1;
        while ($1 >= 1024) {
           $1 = $1 / 1024;
           u += 1
        }
        $1 = sprintf("%.1f %s", $1, Units[u]);
        print $0;
     }
    '
 

This produces output like this;

884.0 MB .
385.5 MB ./Downloads
528.0 KB ./eBooks
48.0 KB ./My Shapes
32.0 KB ./1984_files
8.0 KB ./Xerox
8.0 KB ./My Pictures


Also, to avoid having to enter your password (for the sudo command) add this line to your sudoers file;


brettg ALL=NOPASSWD: /usr/bin/du

Tuesday, 27 October 2009

Search files for text and delete

I had to do this when a mail queue ended up with hundreds of bounce messages. I needed to delete these messages and keep the rest.

rm `fgrep -lir searchstring *`

Saturday, 24 October 2009

Preparing for Karmic

With less than a week to go until Karmic goes live you might want to avoid the rush and pre-download the packages you will need for when you decide to upgrade.

Do this by using the "download only" flag in apt-get

First, change your sources.list file to point to the Karmic repositories.

Next, do a "download only" upgrade.
sudo apt-get -d upgrade

At the end of the process, instead of stepping to the "Installing packages" stage you will see a message "Download complete and in download only mode"

Cool.

Finally, do the same for a distribution upgrade
sudo apt-get -d dist-upgrade

If you have more than one PC on your network to be upgraded, you probably want to use apt-cacher so that you only need to download all those packages once.

Come the time to do the upgrade proper, repeat these steps (simply to update any packages that have changed since you downloaded them into your cache).

Then, when you do the upgrade for real, it will skip past the normally lengthy download stage and straight to the "installing packages" phase while all the other plebs are fighting over bandwidth trying to download packages on the release day!