(UPDATE: Finally added a css once again! - 21/12/09 )
by Abhishek (abhi23iiser@gmail.com) at November 08, 2009 06:37 AM
by Abhishek (abhi23iiser@gmail.com) at November 06, 2009 05:07 PM
by Abhishek (abhi23iiser@gmail.com) at October 27, 2009 12:02 PM
by Abhishek (abhi23iiser@gmail.com) at October 06, 2009 05:43 PM
by Abhishek (abhi23iiser@gmail.com) at September 11, 2009 11:00 AM
by Abhishek (abhi23iiser@gmail.com) at September 07, 2009 01:29 PM
by Abhishek (abhi23iiser@gmail.com) at August 21, 2009 08:57 AM
by Abhishek (abhi23iiser@gmail.com) at July 06, 2009 06:28 AM
by Abhishek (abhi23iiser@gmail.com) at July 06, 2009 06:27 AM
by Abhishek (abhi23iiser@gmail.com) at July 06, 2009 06:26 AM
by Abhishek (abhi23iiser@gmail.com) at July 03, 2009 05:02 AM
by ritesh (riteshindian@gmail.com) at June 20, 2009 08:11 PM
by Abhishek (abhi23iiser@gmail.com) at April 27, 2009 05:39 PM
I have a 400GB Seagate IDE HDD connected to Mars, our hostel's file-server using an USB enclosure. The USB enclosure is a cheap "Made in China" product. Consequently it has some special "features". One such notable "feature" is that the disk is kept spinning by the controller even if there has been no disk I/O for a long time. I have three other USB disks connected to the same machine, a 1TB Seagate FreeAgent Desk External Drive, a 500GB Maxtor Basics External Drive and a 2.5" 60GB Fujitsu SATA Disk inside a Transcend USB enclosure. All of these spin down themselves if there has been no I/O for sometime. Keeping the hard disk spinning unnecessarily for ever, not only wastes power but also overheats the drive, thereby reducing its life.
I tried noflushd, which is supposed to force idle hard disks to spin down, but found it to be of no help. USB enclosure generally work by performing an SCSI emulation over USB. sdparm is an utility which can be used to send simple SCSI commands. A peep into its manpage revealed that the disk could be ordered to spin down by sudo sdparm -C stop /dev/sdb1 where sdb1 is the required disk (the disk has a single partition, "sdparm -C stop /dev/sdb1" and "sdparm -C stop /dev/sdb" did the same thing here, however if there are multiple partitions, it is more meaningful to specify "/dev/sdb" rather than "/dev/sdb1", since it is the disk that stops spinning).
However I need to do this automatically whenever the disk is idle. First, it is necessary to check whether the disk is active or idle. Info about disk I/O is available from /proc/diskstats.cat /proc/diskstats | grep sdb1
shows info about sdb1, the output is something line this:8 17 sdb1 210583 56943 24739612 2328860 11777 24804 292648 69260 0 1209770 2397450
It has several fields after "sdb1", denoting the following:
Field 1 -- No. of reads issued
Field 2 -- No. of reads merged
Field 3 -- No. of sectors read
Field 4 -- No. of milliseconds spent reading
Field 5 -- No. of writes completed
Field 6 -- No. of writes merged
Field 7 -- No. of sectors written
Field 8 -- No. of milliseconds spent writing
Field 9 -- No. of I/Os currently in progress
Field 10 -- No. of milliseconds spent doing I/Os
Field 11 -- weighted No. of milliseconds spent doing I/Os
cat /proc/diskstats | grep $DISKNAME | mawk '{ print $(NF-2) }' does the trick.mawk '{ print i }' prints the ith field.cat /proc/diskstats | grep $DISKNAME | mawk '{ print $(NF-2) }'0. To ensure that the disk is really inactive, the check has to be carried out quite a few times.There is another pitfall, there are 4 USB disks connected to the machine. Which one would be named sdb is not fixed. At every reboot this may change. On the other hand uuid of a disk never changes (unless the partition table is modified). So the name of the disk has to determined from its uuid. grep, AWK, and sed comes to our rescue once again.DISKNAME=`ls -l /dev/disk/by-uuid/ | grep "c5df6a02-b7a6-4f39-ad26-7eb915b76709" | mawk '{ print $(NF) }' | sed s_\.\.\/\.\.\/__`
What this essentially does is explained below."ls -l /dev/disk/by-uuid/" gives the following output
sambit@mars:~$ ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 2009-04-07 14:20 0db6e806-8d4b-4968-8ccc-c00af59bb065 -> ../../sdc1
lrwxrwxrwx 1 root root 10 2009-04-07 14:20 4294e561-df28-4ddd-a689-0aba31d4d663 -> ../../sda2
lrwxrwxrwx 1 root root 10 2009-04-07 14:20 4cb989c6-87b7-4179-bb4d-81b2b0193ab2 -> ../../sdd1
lrwxrwxrwx 1 root root 10 2009-04-07 14:20 4cf2093e-f08c-4127-ae75-fff11edd81ae -> ../../sdd2
lrwxrwxrwx 1 root root 10 2009-04-07 14:20 87ba9975-056d-4635-85e4-53f1c76d57fb -> ../../sda3
lrwxrwxrwx 1 root root 10 2009-04-07 14:20 a74b47fb-a33c-4a5a-ad62-0bc831f6ffda -> ../../sdd3
lrwxrwxrwx 1 root root 10 2009-04-07 14:20 af0c007b-a15c-4661-84eb-7dc689dec861 -> ../../sda1
lrwxrwxrwx 1 root root 10 2009-04-10 22:09 c5df6a02-b7a6-4f39-ad26-7eb915b76709 -> ../../sdb1 narrows it to:
ls -l /dev/disk/by-uuid/ | grep "c5df6a02-b7a6-4f39-ad26-7eb915b76709"lrwxrwxrwx 1 root root 10 2009-04-10 22:09 c5df6a02-b7a6-4f39-ad26-7eb915b76709 -> ../../sdb1 prints the last field:
ls -l /dev/disk/by-uuid/ | grep "c5df6a02-b7a6-4f39-ad26-7eb915b76709" | mawk '{ print $(NF) }'../../sdb1
Finally sed puts some finishing touches, by replacing "../../" in "../../sdb1" with "".
ls -l /dev/disk/by-uuid/ | grep "c5df6a02-b7a6-4f39-ad26-7eb915b76709" | mawk '{ print $(NF) }' | sed s_\.\.\/\.\.\/__
sdb1
So putting everything together, the script at-last looks something like this:
#################################################################################################################################
#!/bin/bash
DISKNAME=`ls -l /dev/disk/by-uuid/ | grep "c5df6a02-b7a6-4f39-ad26-7eb915b76709" | mawk '{ print $(NF) }' | sed s_\.\.\/\.\.\/__`
let a=0
#check 100 times with 0.1s gaps,
#and go on adding
for i in `seq 0 100`
do
let a=`cat /proc/diskstats | grep $DISKNAME | mawk '{ print $(NF-2) }'`+a
sleep 0.1s
done
echo $a
if [ $a == 0 ]
then
echo "No Activity"
sdparm -C stop /dev/$DISKNAME
else
echo "Disk Active"
fi
exit 0
#################################################################################################################################
I added this to crontab and made it run hourly. The hard disk can rest in peace for sometime in between heavy work now.
The upcoming Ubuntu (codenamed Jaunty Jackalope) 9.04 has a new notification system. Since it’s so beautiful, you may wonder if it’s possible to get that stuff onto your Arch box. Here’s how:
[archlinuxbr] Server = http://repo.archlinux-br.org/i686/
For those of you on 64-bit you can install the notify-osd-bzr package from AUR.
For more information on the new notification system in Jaunty you can read up the specification at: http://wiki.ubuntu.com/NotifyOSD.
Posted in linux Tagged: arch, jaunty, linux, notifications, ubuntu, ui
by ...Abhiket+thoughts... (noreply@blogger.com) at March 15, 2009 06:34 AM
Keyboard shortcuts in GNU/Linux are not as uniform as in, say the Macintosh. Having uniform keyboard shortcuts for common tasks which do not conflict is an integral part of a good user interface. While the trinity of cut-copy-paste shortcuts have been almost universally implemented, there are quite a few other shortcuts that should be common (closing a window, quitting an application, opening preferences). Yesterday, I tried to get some uniformity in keyboard shortcuts in my GNOME desktop.
The first thing to do is to allow changing the accelerators (keyboard shortcuts) in the GNOME configuration. This can be done by issuing the following command at a Terminal:
gconftool-2 -t bool -s /desktop/gnome/interface/can_change_accels true
Then I mapped Ctrl to the Alt key (which is just in the place where the Command key is on the Mac) and the Alt key to the Windows key. This can be done in GNOME by going to System »Preferences » Keyboard » Layout » Layout Options… and changing Alt/Win key behaviour. This is not really necessary, but mapping the Ctrl key to the Alt key made it a lot easier for my fingers.
Now to change the keyboard shortcut corresponding to any menu in GNOME, you simply have to select the menu item and press the shortcut you wish to have associated with the menu item. However, this does not work for all GTK programs. The programs for which I could change the shortcuts using this way included Nautilus, Rhythmbox, Pidgin, Totem, Terminal, Gedit, Image Viewer. For example, I changed all the preferences shortcuts to Control+comma. Keep in mind that if the shortcut you assign is already assigned to some other function, then the shortcut will be reassigned to the menu item you’ve selected and the previous functionality corresponding to the shortcut will not have any shortcut assigned to it.
Some other shortcuts that I changed in Nautilus are: Control+I for Properties (this is consistent with the same shortcut for Firefox’s Page Info and the Mac OS X Finder), Control+D for Duplicate, Control+Shift+Delete for Empty Trash and Control+Shift+C for Computer.
Of course, we also have to change the shortcuts for the window manager we’re using. Since I’m using Compiz, I used ccsm (Arch: ccsm, Ubuntu/Debian: compizconfig-settings-manager package), to change the shortcut for closing an window to Control+W (in General Options » Key bindings). Also I changed the default shortcut for Run Command… from Alt+F2 to Control+space in Gnome Compatibility. Since I’d gotten used to pressing Alt+Tab for switching windows, and now Alt had become the Win key, I also had to change the shortcut for switching windows to Control+tab (in Application Switcher).
Firefox: I used the Keyconfig extension to change the keyboard shortcuts in Firefox. I changed the Preferences, Back and Forward shortcuts, as well as the shortcuts for switching to tabs 1 to 9. Since Control+W was now used to close the window, I assigned Control+Shift+W for closing the tab (the same applied for other applications which use tabs a lot, like Gedit).
VLC. I tried to change the shortcut for preferences in VLC to Control+comma but I could not find any way of doing so. There is an option for changing the hotkeys, but that does not include Preferences. So I’ve to stick with the default for the time being. GIMP had a nice shortcut editor, using which I could easily change the shortcut for Preferences.
After all this, you might want to turn off the ability to change accelerators in GNOME by issuing this at the terminal: gconftool-2 -t bool -s /desktop/gnome/interface/can_change_accels false
Update (18 Oct 2009): Registered the uniform-keyboard-shortcuts blueprint in Launchpad.
Posted in Uncategorized Tagged: interface, keyboard, linux, mac, ui
by Abhishek (abhi23iiser@gmail.com) at February 06, 2009 05:57 AM
by cosmos delight (ranjan6398@gmail.com) at January 26, 2009 05:51 AM
by Abhishek (abhi23iiser@gmail.com) at January 20, 2009 12:20 PM
by cosmos delight (ranjan6398@gmail.com) at January 11, 2009 10:11 AM