Index: uspace/app/mkexfat/mkexfat.c
===================================================================
--- uspace/app/mkexfat/mkexfat.c	(revision 914c69344bd47cd9bdd70ec10555f3ab28b3c5ab)
+++ uspace/app/mkexfat/mkexfat.c	(revision 87337dc52aa5f13830c6e760d834e32ad660f9e8)
@@ -46,4 +46,5 @@
 #include <byteorder.h>
 #include <align.h>
+#include <rndgen.h>
 #include <str.h>
 #include <getopt.h>
@@ -243,9 +244,28 @@
  * @param mbs Pointer to the Main Boot Sector structure.
  * @param cfg Pointer to the exFAT configuration structure.
- * @return    Initial checksum value.
+ * @param chksum Place to store initial checksum value.
+ * @return EOK on success or error code
  */
 static uint32_t
-vbr_initialize(exfat_bs_t *mbs, exfat_cfg_t *cfg)
-{
+vbr_initialize(exfat_bs_t *mbs, exfat_cfg_t *cfg, uint32_t *chksum)
+{
+	rndgen_t *rndgen;
+	errno_t rc;
+	uint32_t vsn;
+
+	/* Generate volume serial number */
+
+	rc = rndgen_create(&rndgen);
+	if (rc != EOK)
+		return rc;
+
+	rc = rndgen_uint32(rndgen, &vsn);
+	if (rc != EOK) {
+		rndgen_destroy(rndgen);
+		return rc;
+	}
+
+	rndgen_destroy(rndgen);
+
 	/* Fill the structure with zeroes */
 	memset(mbs, 0, sizeof(exfat_bs_t));
@@ -268,5 +288,5 @@
 
 	mbs->rootdir_cluster = host2uint32_t_le(cfg->rootdir_cluster);
-	mbs->volume_serial = host2uint32_t_le(0xe1028172);
+	mbs->volume_serial = host2uint32_t_le(vsn);
 	mbs->version.major = 1;
 	mbs->version.minor = 0;
@@ -283,5 +303,6 @@
 	mbs->signature = host2uint16_t_le(0xAA55);
 
-	return vbr_checksum_start(mbs, sizeof(exfat_bs_t));
+	*chksum = vbr_checksum_start(mbs, sizeof(exfat_bs_t));
+	return EOK;
 }
 
@@ -299,5 +320,7 @@
 		return ENOMEM;
 
-	vbr_checksum = vbr_initialize(&mbs, cfg);
+	rc = vbr_initialize(&mbs, cfg, &vbr_checksum);
+	if (rc != EOK)
+		goto exit;
 
 	/* Write the Main Boot Sector to disk */
Index: uspace/app/mkfat/mkfat.c
===================================================================
--- uspace/app/mkfat/mkfat.c	(revision 914c69344bd47cd9bdd70ec10555f3ab28b3c5ab)
+++ uspace/app/mkfat/mkfat.c	(revision 87337dc52aa5f13830c6e760d834e32ad660f9e8)
@@ -48,4 +48,5 @@
 #include <inttypes.h>
 #include <errno.h>
+#include <rndgen.h>
 #include <str.h>
 #include "fat.h"
@@ -89,5 +90,5 @@
 static errno_t fat_params_compute(struct fat_cfg *cfg);
 static errno_t fat_blocks_write(struct fat_cfg const *cfg, service_id_t service_id);
-static void fat_bootsec_create(struct fat_cfg const *cfg, struct fat_bs *bs);
+static errno_t fat_bootsec_create(struct fat_cfg const *cfg, struct fat_bs *bs);
 
 int main(int argc, char **argv)
@@ -376,5 +377,7 @@
 	fat_dentry_t *de;
 
-	fat_bootsec_create(cfg, &bs);
+	rc = fat_bootsec_create(cfg, &bs);
+	if (rc != EOK)
+		return rc;
 
 	rc = block_write_direct(service_id, BS_BLOCK, 1, &bs);
@@ -442,6 +445,6 @@
 			(void) fat_label_encode(&de->name, cfg->label);
 			de->attr = FAT_ATTR_VOLLABEL;
-			de->mtime = 0x1234;
-			de->mdate = 0x1234;
+			de->mtime = 0x1234; // XXX Proper time
+			de->mdate = 0x1234; // XXX Proper date
 		} else if (idx == 1) {
 			/* Clear volume label entry */
@@ -462,7 +465,23 @@
 
 /** Construct boot sector with the given parameters. */
-static void fat_bootsec_create(struct fat_cfg const *cfg, struct fat_bs *bs)
+static errno_t fat_bootsec_create(struct fat_cfg const *cfg, struct fat_bs *bs)
 {
 	const char *bs_label;
+	rndgen_t *rndgen;
+	uint32_t vsn;
+	errno_t rc;
+
+	/* Generate a volume serial number */
+	rc = rndgen_create(&rndgen);
+	if (rc != EOK)
+		return rc;
+
+	rc = rndgen_uint32(rndgen, &vsn);
+	if (rc != EOK) {
+		rndgen_destroy(rndgen);
+		return rc;
+	}
+
+	rndgen_destroy(rndgen);
 
 	/*
@@ -503,4 +522,5 @@
 	bs->hidden_sec = host2uint32_t_le(0);
 
+
 	if (cfg->fat_type == FAT32) {
 		bs->sec_per_fat = 0;
@@ -509,5 +529,5 @@
 		bs->fat32.pdn = 0x80;
 		bs->fat32.ebs = 0x29;
-		bs->fat32.id = host2uint32_t_be(0x12345678);
+		bs->fat32.id = host2uint32_t_be(vsn);
 		bs->fat32.root_cluster = 2;
 
@@ -518,5 +538,5 @@
 		bs->pdn = 0x80;
 		bs->ebs = 0x29;
-		bs->id = host2uint32_t_be(0x12345678);
+		bs->id = host2uint32_t_be(vsn);
 
 		(void) fat_label_encode(&bs->label, bs_label);
@@ -526,4 +546,6 @@
 			memcpy(bs->type, "FAT16   ", 8);
 	}
+
+	return EOK;
 }
 
Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision 914c69344bd47cd9bdd70ec10555f3ab28b3c5ab)
+++ uspace/lib/c/Makefile	(revision 87337dc52aa5f13830c6e760d834e32ad660f9e8)
@@ -133,4 +133,5 @@
 	generic/double_to_str.c \
 	generic/malloc.c \
+	generic/rndgen.c \
 	generic/stdio/scanf.c \
 	generic/stdio/sprintf.c \
Index: uspace/lib/c/generic/rndgen.c
===================================================================
--- uspace/lib/c/generic/rndgen.c	(revision 87337dc52aa5f13830c6e760d834e32ad660f9e8)
+++ uspace/lib/c/generic/rndgen.c	(revision 87337dc52aa5f13830c6e760d834e32ad660f9e8)
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2018 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
+ * @brief Random number generator.
+ *
+ * Generate random (as opposed to pseudorandom) numbers. This should be
+ * used sparingly (e.g. to seed a pseudorandom number generator).
+ */
+
+#include <errno.h>
+#include <rndgen.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <time.h>
+
+/** Create random number generator.
+ *
+ * @param rrndgen Place to store new random number generator
+ * @return EOK on success or error code
+ */
+errno_t rndgen_create(rndgen_t **rrndgen)
+{
+	rndgen_t *rndgen;
+	struct timeval tv;
+
+	rndgen = calloc(1, sizeof(rndgen_t));
+	if (rndgen == NULL)
+		return ENOMEM;
+
+	/* XXX This is a rather poor way of generating random numbers */
+	gettimeofday(&tv, NULL);
+	rndgen->seed = tv.tv_sec ^ tv.tv_usec;
+
+	*rrndgen = rndgen;
+	return EOK;
+}
+
+/** Destroy random number generator.
+ *
+ * @param rndgen Random number generator or @c NULL
+ */
+void rndgen_destroy(rndgen_t *rndgen)
+{
+	if (rndgen == NULL)
+		return;
+
+	free(rndgen);
+}
+
+/** Generate random 8-bit integer.
+ *
+ * @param rndgen Random number generator
+ * @param rb Place to store random 8-bit integer
+ * @return EOK on success or error code
+ */
+errno_t rndgen_uint8(rndgen_t *rndgen, uint8_t *rb)
+{
+	rndgen->seed = (1366 * rndgen->seed + 150889) % 714025;
+
+	*rb = rndgen->seed & 0xff;
+	return EOK;
+}
+
+/** Generate random 32-bit integer.
+ *
+ * @param rndgen Random number generator
+ * @param rw Place to store random 32-bit integer
+ * @return EOK on success or error code
+ */
+errno_t rndgen_uint32(rndgen_t *rndgen, uint32_t *rw)
+{
+	int i;
+	uint8_t b;
+	uint32_t w;
+	errno_t rc;
+
+	w = 0;
+	for (i = 0; i < 4; i++) {
+		rc = rndgen_uint8(rndgen, &b);
+		if (rc != EOK)
+			return rc;
+
+		w = (w << 8) | b;
+	}
+
+	*rw = w;
+	return EOK;
+}
+
+/** @}
+ */
Index: uspace/lib/c/generic/uuid.c
===================================================================
--- uspace/lib/c/generic/uuid.c	(revision 914c69344bd47cd9bdd70ec10555f3ab28b3c5ab)
+++ uspace/lib/c/generic/uuid.c	(revision 87337dc52aa5f13830c6e760d834e32ad660f9e8)
@@ -35,7 +35,7 @@
 #include <errno.h>
 #include <uuid.h>
+#include <rndgen.h>
 #include <stdlib.h>
 #include <stddef.h>
-#include <time.h>
 #include <str.h>
 
@@ -48,12 +48,18 @@
 {
 	int i;
-	struct timeval tv;
+	rndgen_t *rndgen;
+	errno_t rc;
 
-	/* XXX This is a rather poor way of generating random numbers */
-	gettimeofday(&tv, NULL);
-	srand(tv.tv_sec ^ tv.tv_usec);
+	rc = rndgen_create(&rndgen);
+	if (rc != EOK)
+		return EIO;
 
-	for (i = 0; i < uuid_bytes; i++)
-		uuid->b[i] = rand();
+	for (i = 0; i < uuid_bytes; i++) {
+		rc = rndgen_uint8(rndgen, &uuid->b[i]);
+		if (rc != EOK) {
+			rc = EIO;
+			goto error;
+		}
+	}
 
 	/* Version 4 UUID from random or pseudo-random numbers */
@@ -62,4 +68,7 @@
 
 	return EOK;
+error:
+	rndgen_destroy(rndgen);
+	return rc;
 }
 
Index: uspace/lib/c/include/rndgen.h
===================================================================
--- uspace/lib/c/include/rndgen.h	(revision 87337dc52aa5f13830c6e760d834e32ad660f9e8)
+++ uspace/lib/c/include/rndgen.h	(revision 87337dc52aa5f13830c6e760d834e32ad660f9e8)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2018 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 Random number generator
+ */
+
+#ifndef LIBC_RNDGEN_H_
+#define LIBC_RNDGEN_H_
+
+#include <errno.h>
+#include <stdint.h>
+#include <stdio.h>
+
+typedef struct {
+	unsigned int seed;
+} rndgen_t;
+
+extern errno_t rndgen_create(rndgen_t **);
+extern void rndgen_destroy(rndgen_t *);
+extern errno_t rndgen_uint8(rndgen_t *, uint8_t *);
+extern errno_t rndgen_uint32(rndgen_t *, uint32_t *);
+
+#endif
+
+/** @}
+ */
