2010-10-27

Linux and the UUID

Even after more than 15 years of Linux experience, I sometimes learn new stuff. Today, I figured out why my KDE goes haywire sometimes. It turns out, that my swap file was mounted as /dev/sda1. Which is fine, most of the time. Except when an external USB drive is plugged in. Then that one becomes sda, and the internal drives goes to sdb or even sdc, when two external drives are plugged in. So the swap won't work, and the USB drive cannot be mounted via dBus / HAL, since it is suddenly listed in the /etc/fstab. Also, KDE will have some strange troubles during this time, and will not restore my session. But I am not 100% sure this is related. Time will tell... Anyway, what was strange was, that everything else worked. That was because the root filesystem was mounted using a UUID, which identifies a partition or volume uniquely. So, why did the swap not have this? Seems, this was forgotten by Ubuntu upon the upgrade to Maverick. But the Ubuntu Wiki helps. So what I did was:
  # swapoff /dev/sda1
  # MYUUID=$(uuidgen)
  # mkswap -U $MYUUID
  # sed "s/\/dev\/sda1/UUID=$MYUUID/"
  # swapon /dev/sda1
You can also just edit fstab with the editor of your choice...

No comments:

Post a Comment