Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Sunday, October 21, 2012

Seeing GTK mouse cursor in KDE?

If you have upgraded to Kubuntu 12.10, you’d notice that KDM has been replaced with LightDM.  LightDM looks pretty, but somehow doesn’t play well with KDE.  One annoying issue I have noticed is that GTK applications run in KDE use GTK mouse cursor under certain circumstances.  When Chrome shows a menu, the mouse cursor changes to a GTK one and it looks jarring.  Turns out, there’s a fix for that.

1. Install LightDM KDE greeter
sudo apt-get install lightdm-kde-greeter
2. Make LightDM use KDE greeter, and all will be well again. To do that, edit the file /etc/lightdm/lightdm.conf and change the value of greeter-session.  The file will look something like this after the change.  (Boldface text is the change you’d have to make.)
[SeatDefaults]
greeter-session=lightdm-kde-greeter
user-session=ubuntu
3. Save the file and test your changes by running LightDM in test mode:
lightdm --test-mode
If LightDM doesn’t open correctly, check if you have made any typing errors in the config file.  If you cannot fix the issue, just restore the file as it was before you edited; you’ll still have the ugly mouse cursor issue, but at least your computer will continue to work.

Saturday, September 8, 2012

Disabling Ubuntu menu proxy when not using Unity

Does seeing messages like this on your terminal annoy you?
** (gvim:8016): WARNING **: Unable to create Ubuntu Menu Proxy: Timeout was reached
It sure does annoy me.  Turns out, it’s because the app you’re running is trying to connect its menus to Unity’s “global menu” (or whatever that’s called).  The way to fix this problem would be to disable Unity menu proxy when you’re not using Unity.  Add this to your shell’s startup script (.bashrc, .zshrc, etc):
if [[ $DESKTOP_SESSION != "ubuntu" && $DESKTOP_SESSION != "ubuntu-2d" ]]
then
  export UBUNTU_MENUPROXY=0
fi

Sunday, April 29, 2012

Auto-deleting files from Trash and trash-cli package

Two tips about using Trash (aka Recycle Bin) folder efficiently on KDE:
  1. You can configure Dolphin to automatically delete files from Trash that are older than a certain number of days.  Use Dolphin menu > Configure Dolphin... > Trash > Delete files older than setting.
  2. You can access your Trash from command line if you have trash-cli package installed.  (Install it by running sudo apt-get install trash-cli command.)  Once installed, trash-list command shows the contents of your Trash, trash-put command moves files to Trash, and trash-empty command permanently deletes everything in Trash.
Source: A comment on Stefaan Lippens’ webface.

Saturday, January 14, 2012

Running Ubuntu on a Toshiba Z830

I bought a Toshiba Z830 recently.  This post is to document how I am running Kubuntu on it.  First, let me show you how fast it boots :)

  1. The machine has only 128GB storage, which cannot be upgraded yet, which means having both Windows and Linux on the machine may not be realistic.  But there’s a way to back up Windows!  Toshiba bundles a program with the computer that creates recovery USB drives for the Z830.  I bought a new 16GB USB drive and made it a recovery drive.  The plan is to use this for restoring Windows when I am giving this laptop away to somebody in future.
  2. I downloaded 64-bit Kubuntu 11.10 installer from kubuntu.org.  Since I have a backup copy of Windows, I removed all NTFS and recovery partitions from the disk and created new partitions for installing Kubuntu.
  3. After the installation, almost everything worked out of the box.  I had no issues with the laptop sleeping or waking up; 3D graphics worked fine; audio, bluetooth, webcam... everything worked.  Except the following one issue.
  4. Screen brightness controls sometimes worked, but sometimes they didn’t.  The technique that helped in 2008 helped me this time too, except I needed to make a minor modification to the program: the file that required changing was /sys/class/backlight/intel_backlight/brightness (i.e. intel_backlight instead of acpi_video0).  And the brightness value seem to be in the range of 100 through 4400.
  5. Battery life was bad.  More worrying than battery life was the heat generated by the laptop.  I found some tips to reduce power usage on Putokaz blog, and tried it (thank you, voloder!).  While it did reduce power consumption, it also resulted in some screen update issues.  After some trial and error, I found that frame buffer compression was causing issues, so I left that one out.
    Update: Kubuntu 12.04 provides a very good battery life out of the box.
  6. ZDNet recommends disabling “elevator” I/O scheduler by passing elevator=noop to kernel.  Based on tips from both sources, I have updated my /etc/default/grub to have this line:
    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash elevator=noop"
    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pcie_aspm=force i915.i915_enable_rc6=1 i915.lvds_downclock=1 elevator=noop"
    (Power management flags may work on other computers with the same Core i5-2467M Sandy Bridge processor as well.)
  7. Based on the same ZDNet story mentioned before, I updated my /etc/fstab as well.  I added noatime flag to my ext4 partitions and mounted /tmp on RAM using tmpfs.  (I didn’t change the caching parameters as that sounds a bit scary.)
    UUID=dbccce1d-8e31-428e-a25a-227afc54651f /      ext4  noatime  0  1
    UUID=720c576c-2c1a-435f-ae90-9151acda2005 /home  ext4  noatime  0  2
    tmpfs /tmp tmpfs nodev,nosuid,noexec,size=1G 0 0
    
Update: Someone was asking about battery life, so here's a screenshot of expected battery life.  With Ubuntu 12.04, you'd get more than 5 hours of battery life on a full charge.

Saturday, January 7, 2012

Partitioning disk for installing Linux

Are you installing Ubuntu on a new machine and you’re not sure how much storage space the installation would need or how to partition your disk?  I have a few suggestions:
  • Create separate partitions for Linux installation (mounted at /) and data (mounted at /home).  This way, you can completely wipe and reinstall your OS or switch to a different distro without worrying about data in your home directory.
  • A typical Linux installation doesn’t need a lot of space.  I allocated 20GB for my root (/) partition purely based on some guess work, but I’m using only about 7.2GB in that partition.  If I’m starting over again, I’d go with a 12 or even a 10GB partition.  (You’re a lot more likely to eventually run out of space on your home partition than on the root partition.)
    % df -hl
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/sda1              19G  7.2G   11G  40% /
    udev                  2.9G  4.0K  2.9G   1% /dev
    tmpfs                 1.2G  996K  1.2G   1% /run
    none                  5.0M     0  5.0M   0% /run/lock
    none                  2.9G  2.8M  2.9G   1% /run/shm
    /dev/sda6              93G   78G   11G  89% /home

Wednesday, November 16, 2011

Migrating to a new SSD without data loss

I have a Samsung N150 netbook that came with Windows 7 preinstalled on a 250GB hard disk.  I created a bunch of new ext4 partitions on this disk and was running Kubuntu on it.  I almost never used Windows, but I had kept it on the disk anyway.  Last week I thought of upgrading to an SSD, and bought a 240GB SSD.  This post is to document how I copied over the Windows installation and recovery partition to the SSD before swapping the disks.

I connected the SSD to my computer using an USB interface and ran sudo fdisk -l to see the partition tables of both disks.
% sudo fdisk -l

Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xd937cf59

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048    31459327    15728640   27  Hidden NTFS WinRE
/dev/sda2   *    31459328    31664127      102400    7  HPFS/NTFS/exFAT
/dev/sda3        31664128   232622079   100478976    7  HPFS/NTFS/exFAT
/dev/sda4       232624126   488394751   127885313    5  Extended
/dev/sda5       480397312   488394751     3998720   82  Linux swap / Solaris
/dev/sda6       232624128   291215359    29295616   83  Linux
/dev/sda7       291217408   480391167    94586880   83  Linux

Partition table entries are not in disk order

Disk /dev/sdb: 240.1 GB, 240057409536 bytes
255 heads, 63 sectors/track, 29185 cylinders, total 468862128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00045231

   Device Boot      Start         End      Blocks   Id  System
/dev/sda is the original hard disk that came with the laptop, and /dev/sdb, which is empty currently, is the new SSD.  I have to clone the first 3 partitions (/dev/sda1, /dev/sda2, and /dev/sda3) bit-by-bit to retain all the preinstalled stuff — this includes Windows 7 installation and the recovery partition.  Replicating the Windows partitions is the tricky part, so this post will describe that in detail.  Copying data from Linux partitions can be done with a simple rsync.

The first step is to create partitions on the new disk that resemble the old disk.  I followed the fdisk guide of TLDP and created the first 3 partitions.  Now fdisk -l shows this configuration:
% sudo fdisk -l      

Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xd937cf59

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048    31459327    15728640   27  Hidden NTFS WinRE
/dev/sda2   *    31459328    31664127      102400    7  HPFS/NTFS/exFAT
/dev/sda3        31664128   232622079   100478976    7  HPFS/NTFS/exFAT
/dev/sda4       232624126   488394751   127885313    5  Extended
/dev/sda5       480397312   488394751     3998720   82  Linux swap / Solaris
/dev/sda6       232624128   291215359    29295616   83  Linux
/dev/sda7       291217408   480391167    94586880   83  Linux

Partition table entries are not in disk order

Disk /dev/sdb: 240.1 GB, 240057409536 bytes
255 heads, 63 sectors/track, 29185 cylinders, total 468862128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00045231

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    31459327    15728640   27  Hidden NTFS WinRE
/dev/sdb2   *    31459328    31664127      102400    7  HPFS/NTFS/exFAT
/dev/sdb3        31664128   232622079   100478976    7  HPFS/NTFS/exFAT
The partitions in the new disk are of the same size and same type as in the old one.  /dev/sdb2 is bootable as is /dev/sda2.  (It won’t boot yet though, since the disk has no OS yet.)  Now to copy the data bits over.  I first unmounted all three partitions.  This is critical because changing data underneath when it’s being copied over is a darn good recipe for data corruption.

dd is the low-level data copying utility I used to clone the partitions.  Copying the data over was as simple as running these commands one by one.  (Swapping if and of can result in wiping out all data from the old partition.  dd cannot even know if you’re passing wrong arguments to it.)
% sudo dd if=/dev/sda1 of=/dev/sdb1 conv=notrunc
% sudo dd if=/dev/sda2 of=/dev/sdb2 conv=notrunc
% sudo dd if=/dev/sda3 of=/dev/sdb3 conv=notrunc

Copying can be painfully slow since we are moving hundreds of GBs around.  Blog O’ Matty has a post that shows how to find status of a running dd command.  Essentially you’d send SIGUSR1 signal to the dd process and it’d print the current status of the transfer.  One of the commenters suggests running sudo pkill -SIGUSR1 dd so that you don’t have to think about process IDs.

Once this was done, I installed Kubuntu on the SSD using the standard installation process, and everything went just fine.  Windows doesn’t boot probably because it thinks mine is a pirated copy.  (Shows an error saying some ‘important’ hardware has gone missing.)  But I can boot into the recovery partition, so I can restore factory settings to get Windows running again when I want it.

I restored all my installed software from the package selection list I had already generated.  That’s it... the computer is exactly like it was before with all my programs and configuration.

Saturday, May 7, 2011

/tmp is your friend

Do you end up with a lot of unnecessary files in your home directory, e.g. in your ~/Downloads folder?  Make it a habit to use /tmp for files that you don't want to keep for a long time.  By default, Ubuntu empties  /tmp every time it boots up so you don't keep accumulating junk.  (If you'd rather keep your temporary files for a longer period, you can change TMPTIME variable in your rcS file.)