Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision bf7ddde7202032c4d6e8e1cce492754096b46905)
+++ uspace/lib/c/Makefile	(revision 70815a24cf429286a07e08f8ad1f2a835d6be638)
@@ -154,4 +154,5 @@
 	generic/assert.c \
 	generic/pio_trace.c \
+	generic/uuid.c \
 	generic/vbd.c \
 	generic/vol.c
Index: uspace/lib/c/generic/uuid.c
===================================================================
--- uspace/lib/c/generic/uuid.c	(revision 70815a24cf429286a07e08f8ad1f2a835d6be638)
+++ uspace/lib/c/generic/uuid.c	(revision 70815a24cf429286a07e08f8ad1f2a835d6be638)
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2015 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file Universaly Unique Identifier (see RFC 4122)
+ */
+
+#include <errno.h>
+#include <uuid.h>
+#include <stdlib.h>
+
+/** Generate UUID.
+ *
+ * @param uuid Place to store generated UUID
+ * @return EOK on success or negative error code
+ */
+int uuid_generate(uuid_t *uuid)
+{
+	int i;
+	struct timeval tv;
+
+	/* XXX This is a rather poor way of generating random numbers */
+	gettimeofday(&tv, NULL);
+	srandom(tv.tv_sec ^ tv.tv_usec);
+
+	for (i = 0; i < uuid_bytes; i++)
+		uuid->b[i] = random();
+
+	/* Version 4 UUID from random or pseudo-random numbers */
+	uuid->b[8] = (uuid->b[8] & ~0xc0) | 0x40;
+	uuid->b[6] = (uuid->b[6] & 0xf0) | 0x40;
+
+	return EOK;
+}
+
+/** Encode UUID into binary form per RFC 4122.
+ *
+ * @param uuid UUID
+ * @param buf 16-byte destination buffer
+ */
+void uuid_encode(uuid_t *uuid, uint8_t *buf)
+{
+	int i;
+
+	for (i = 0; i < uuid_bytes; i++)
+		buf[i] = uuid->b[i];
+}
+
+/** Decode UUID from binary form per RFC 4122.
+ *
+ * @param buf 16-byte source buffer
+ * @param uuid Place to store UUID
+ */
+void uuid_decode(uint8_t *buf, uuid_t *uuid)
+{
+	int i;
+
+	for (i = 0; i < uuid_bytes; i++)
+		uuid->b[i] = buf[i];
+}
+
+/** @}
+ */
Index: uspace/lib/c/include/uuid.h
===================================================================
--- uspace/lib/c/include/uuid.h	(revision 70815a24cf429286a07e08f8ad1f2a835d6be638)
+++ uspace/lib/c/include/uuid.h	(revision 70815a24cf429286a07e08f8ad1f2a835d6be638)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2015 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_UUID_H_
+#define LIBC_UUID_H_
+
+#include <stdint.h>
+
+enum {
+	uuid_bytes = 16
+};
+
+/** Universally Unique Identifier */
+typedef struct {
+	uint8_t b[uuid_bytes];
+} uuid_t;
+
+extern int uuid_generate(uuid_t *);
+extern void uuid_encode(uuid_t *, uint8_t *);
+extern void uuid_decode(uint8_t *, uuid_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/label/include/types/liblabel.h
===================================================================
--- uspace/lib/label/include/types/liblabel.h	(revision bf7ddde7202032c4d6e8e1cce492754096b46905)
+++ uspace/lib/label/include/types/liblabel.h	(revision 70815a24cf429286a07e08f8ad1f2a835d6be638)
@@ -41,4 +41,5 @@
 #include <sys/types.h>
 #include <vol.h>
+#include <uuid.h>
 
 typedef struct label label_t;
@@ -96,4 +97,6 @@
 	/** Partition type */
 	uint64_t ptype;
+	/** Partition UUID */
+	uuid_t part_uuid;
 };
 
Index: uspace/lib/label/src/gpt.c
===================================================================
--- uspace/lib/label/src/gpt.c	(revision bf7ddde7202032c4d6e8e1cce492754096b46905)
+++ uspace/lib/label/src/gpt.c	(revision 70815a24cf429286a07e08f8ad1f2a835d6be638)
@@ -40,4 +40,5 @@
 #include <mem.h>
 #include <stdlib.h>
+#include <uuid.h>
 
 #include "std/gpt.h"
@@ -335,4 +336,5 @@
 	uint64_t resv_blocks;
 	uint32_t pt_crc;
+	uuid_t disk_uuid;
 	int i, j;
 	int rc;
@@ -399,4 +401,6 @@
 			goto error;
 		}
+
+		uuid_generate(&disk_uuid);
 
 		for (j = 0; j < 8; ++j)
@@ -409,5 +413,5 @@
 		gpt_hdr->first_usable_lba = host2uint64_t_le(ba_min);
 		gpt_hdr->last_usable_lba = host2uint64_t_le(ba_max);
-		//gpt_hdr->disk_guid XXX
+		uuid_encode(&disk_uuid, gpt_hdr->disk_guid);
 		gpt_hdr->entry_lba = host2uint64_t_le(ptba[i]);
 		gpt_hdr->num_entries = host2uint32_t_le(num_entries);
@@ -594,4 +598,5 @@
 	part->nblocks = pspec->nblocks;
 	part->ptype = pspec->ptype;
+	uuid_generate(&part->part_uuid);
 
 	/* Prepare partition table entry */
@@ -651,5 +656,5 @@
 	memset(pte, 0, sizeof(gpt_entry_t));
 	pte->part_type[0] = 0x12;
-	pte->part_id[0] = 0x34;
+	uuid_encode(&part->part_uuid, pte->part_id);
 	pte->start_lba = host2uint64_t_le(part->block0);
 	pte->end_lba = host2uint64_t_le(eblock);
@@ -686,4 +691,5 @@
 	part->block0 = b0;
 	part->nblocks = b1 - b0 + 1;
+	uuid_decode(pte->part_id, &part->part_uuid);
 
 	part->label = label;
