RHEL- Find UUID of Hard Disks

CinderblockAnyone who has added and removed multiple disks from a RedHat server knows very well that your disks may not always enumerate exactly the same way after a reboot. You then have to resort to mounting up your filesystems to a temporary mount point to see exactly whats in them, and were they really need to be mounted.

Want to know if UUIDS are being used on your linux box, well just cat /etc/fstab, and if you see somthing similar to what’s below, then you are using UUIDS, instead of traditional disk device names.

UUID=3fa4603e-9874-4f47-ae1c-3f7715a54238 /                       ext4    defaults,user_xattr        1 1
UUID=483c34a4-b3ec-4860-854f-b9e5b6a6efac /boot                   ext4    defaults        1 2
UUID=7cab6648-b3f3-4aaa-bb2b-d32b78156aab /var                    ext4    defaults        1 2
UUID=7b05f0a9-18d5-42e5-b259-78ba3a8cc1b7 swap                    swap    defaults        0 0

One way of mapping device UUIDS back to device names is the blkid command — usage and output below.

[root@fedora15 ~]# blkid
/dev/sda1: UUID=”483c34a4-b3ec-4860-854f-b9e5b6a6efac” TYPE=”ext4″
/dev/sda2: LABEL=”_Fedora-15-x86_6″ UUID=”3fa4603e-9874-4f47-ae1c-3f7715a54238″ TYPE=”ext4″
/dev/sda3: UUID=”7b05f0a9-18d5-42e5-b259-78ba3a8cc1b7″ TYPE=”swap”
/dev/sdb1: UUID=”7cab6648-b3f3-4aaa-bb2b-d32b78156aab” TYPE=”ext4″
/dev/sdb2: UUID=”rJfNaK-e3Xp-n3qm-4aXM-BfKF-g7sg-Kwm33a” TYPE=”LVM2_member”
/dev/sdc1: LABEL=”raid1″ UUID=”34ed4ffd-cc4a-4b40-892f-6d7714fe7f4e” TYPE=”ext3″
/dev/mapper/vm_vg-v1: UUID=”2d96aa43-b5b8-4185-8014-323ad8a07a0d” TYPE=”ext4″

You can also do an ls on the following directory and get the same information.

[root@fedora15 ~]# ls -l /dev/disk/by-uuid
total 0
lrwxrwxrwx 1 root root 10 Sep 25 21:41 2d96aa43-b5b8-4185-8014-323ad8a07a0d -> ../../dm-0
lrwxrwxrwx 1 root root 10 Sep 25 20:51 34ed4ffd-cc4a-4b40-892f-6d7714fe7f4e -> ../../sdc1
lrwxrwxrwx 1 root root 10 Sep 25 20:51 3fa4603e-9874-4f47-ae1c-3f7715a54238 -> ../../sda2
lrwxrwxrwx 1 root root 10 Sep 25 20:51 483c34a4-b3ec-4860-854f-b9e5b6a6efac -> ../../sda1
lrwxrwxrwx 1 root root 10 Sep 25 20:51 7b05f0a9-18d5-42e5-b259-78ba3a8cc1b7 -> ../../sda3
lrwxrwxrwx 1 root root 10 Sep 25 20:51 7cab6648-b3f3-4aaa-bb2b-d32b78156aab -> ../../sdb1

If you are so inclined, you can also get the UUID and filesystem label (if there is one) with the tune2fs command

tune2fs -l /dev/sda1

Filesystem volume name:   <none>
Last mounted on:          /boot
Filesystem UUID:          483c34a4-b3ec-4860-854f-b9e5b6a6efac
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)


Oh and if you are running Fedora 15 and are wondering what the heck rootfs is (as I was), here is an explanation. More junk that I hope never gets into RHEL.

Oh and if you are really bored, and would like to know more about what a UUID is go here

Systemd/Systemctl in Fedora 15 — WTF is this?

Nausea_smiley Fresh install of Fedora 15 on my home machine… feeling great, running great. Got myself a fast new SSD, and upgraded to a new quad core and 8gb of ram. Then i run into this.

[root@fedora15 ~]# service nscd start
Starting nscd (via systemctl):                             [  OK  ]


Oh man whats this — systemctl. If this is anything like upstart I am going to be ill.  Well guess what, it is. Even worse, its also kinda like svcadm in Solaris10.

"systemd is a replacement for the System V init daemon for Linux. It is intended to provide a better framework for expressing services' dependencies, allow more work to be done in parallel at system startup, and to reduce shell overhead"

Seriously, was there something wrong with systemV init scripts that i was not aware of.  Looks like systemd is enabled by default in Fedora15,

Anway, the link directly below will take you to a nice cheatsheet for systemd commands. Looks like they are also mucking around with the sysivinit Runlevels. Scroll down for that little gem.


Below is also a FAQ on systemd


And a bit more insight into what it is and where it comes from


Finally the blog post from the developer announcing systemd. Apparently from last year.


Wondering now when we are going to see this in RHEL and if and when systemVinit will be completely deprecated.

Installing Spotify on Fedora

Spotify-logo So Spotify is finally available in the US, which is good news for those who are getting tired of Pandora. Hell, Pandora played Celine Dion on my Hardcore Punk Radio Station the other day…wtf.

So anyway, I decided to sign up and was disappointed to find that they did not have an official linux client, However they do publicize an Ubuntu client here, however, since I run Fedora this is not much interest to me.

Thankfully the Europeans have already figured out how to get Spotify running on other linuxes natively, and google found this link on installing the Debian packages on Fedora 13. I am glad to report that these instructions also work on Fedora 12. So far so good on Fedora 12.

However i decided to explore their repo a bit and found that in fact they do have rpm packages. Check out the link below. Sneaky.


I bit more googling found me this link which contains instructions on installing via the apparently secret rpms.

Btw, if you are a jackass and want to run Spotify under Wine for some reason, click here for instructions.

RHEL – How to Encrypt a Partition using Cryptsetup and LUKS

EUTScglkIUlpZsV Cryptsetup uses dm-crypt to encrypt a disk at the partition level.  In RHEL, cryptsetup is used with Linux Unified Key Setup (LUKS), a disk encryption specification. Mounting a LUKS encrypted partiton requires a passphrase, which can either be passed in a file or via the command line. Read more about dm-crypt here.

Anyway to use crypsetup, you first must have a free partiton on a disk. In this instance I am using /dev/sdc1, which is a freeagent external usb drive.

First initialize the LUKS partition. My target is /dev/sdc1

#cryptsetup luksFormat /dev/sdc1

Then open the LUKS partition setup the dev mapper device. The command below creates /dev/mapper/freeagent

#cryptsetup luksOpen /dev/sdc1 freeagent

Create a passkey file if you want the device to be able to automount at boot. 

#touch /root/freeagent_passkey && chmod 600 /root/freeagent_passkey

Make cryptsetup aware of the key

#cryptsetup luksAddKey /dev/sdc1 /root/freeagent_passkey

#echo "mypasskey" > /root/freeagent_passkey

Dont forget to make a filesystem

#mkfs -t ext4 /dev/mapper/freeagent

Then add the following to /etc/fstab…

/dev/mapper/freeagent   /freeagent              ext4    _netdev         1 1

And add the following to /etc/crypttab. Note that the first entry is the name of the /dev/mapper device

freeagent       /dev/sdc1       /freeagent

To get a status on a device and to see the mappings between /dev/mapper and /dev/sdc1

#cryptsetup status

/dev/mapper//dev/mapper/freeagent is active:
  cipher:  aes-cbc-essiv:sha256
  keysize: 128 bits
  device:  /dev/sdc1
  offset:  1032 sectors
  size:    2930270970 sectors
  mode:    read/write

Make sure you keep track of when to use /dev/mapper/freeagent vs /dev/sdc1 in the commands above.