Index: uspace/app/mkexfat/mkexfat.c
===================================================================
--- uspace/app/mkexfat/mkexfat.c	(revision 392bd67c1151f1a025981c245cc77581ebdc228b)
+++ uspace/app/mkexfat/mkexfat.c	(revision da34d61d7eccd2945a3eebc8b57e4d22e01e27f2)
@@ -47,4 +47,5 @@
 #include <sys/typefmt.h>
 #include <bool.h>
+#include <str.h>
 #include "exfat.h"
 #include "upcase.h"
@@ -88,4 +89,5 @@
 	unsigned long rootdir_cluster;
 	unsigned long upcase_table_cluster;
+	unsigned long bitmap_cluster;
 	unsigned long total_clusters;
 	unsigned long allocated_clusters;
@@ -111,4 +113,7 @@
 bitmap_write(service_id_t service_id, exfat_cfg_t *cfg);
 
+static uint32_t
+upcase_table_checksum(void const *data, size_t nbytes);
+
 static void usage(void)
 {
@@ -168,4 +173,7 @@
 	/* Will be set later */
 	cfg->rootdir_cluster = 0;
+
+	/* Bitmap always starts at the first free cluster */
+	cfg->bitmap_cluster = FIRST_FREE_CLUSTER;
 
 	/* The first sector of the partition is zero */
@@ -524,4 +532,58 @@
 }
 
+/** Initialize and write the root directory entries to disk.
+ *
+ * @param service_id   The service id.
+ * @param cfg   Pointer to the exFAT configuration structure.
+ * @return   EOK on success or a negative error code.
+ */
+static int
+root_dentries_write(service_id_t service_id, exfat_cfg_t *cfg)
+{
+	exfat_dentry_t *d;
+	aoff64_t rootdir_sec;
+	int rc;
+	uint8_t *data;
+
+	data = calloc(cfg->sector_size, 1);
+	if (!data)
+		return ENOMEM;
+
+	d = (exfat_dentry_t *) data;
+
+	/* Initialize the volume label dentry */
+	d->type = EXFAT_TYPE_VOLLABEL;
+	str_to_utf16(d->vollabel.label, 7, "HELENOS");
+	d->vollabel.size = 7;
+
+	d++;
+
+	/* Initialize the allocation bitmap dentry */
+	d->type = EXFAT_TYPE_BITMAP;
+	d->bitmap.flags = 0; /* First FAT */
+	d->bitmap.firstc = host2uint32_t_le(cfg->bitmap_cluster);
+	d->bitmap.size = host2uint64_t_le(cfg->bitmap_size);
+
+	d++;
+
+	/* Initialize the upcase table dentry */
+	d->type = EXFAT_TYPE_UCTABLE;
+	d->uctable.checksum = host2uint32_t_le(upcase_table_checksum(
+	    upcase_table, sizeof(upcase_table)));
+	d->uctable.firstc = host2uint32_t_le(cfg->upcase_table_cluster);
+	d->uctable.size = host2uint64_t_le(sizeof(upcase_table));
+
+	/* Compute the number of the sector where the rootdir resides */
+
+	rootdir_sec = cfg->data_start_sector;
+	rootdir_sec += ((cfg->rootdir_cluster - 2) * cfg->cluster_size) /
+	    cfg->sector_size;
+
+	rc = block_write_direct(service_id, rootdir_sec, 1, data);
+
+	free(data);
+	return rc;
+}
+
 /** Given a number (n), returns the result of log2(n).
  *
@@ -655,5 +717,5 @@
 
 	/* Allocate clusters for the bitmap */
-	rc = fat_allocate_clusters(service_id, &cfg, FIRST_FREE_CLUSTER,
+	rc = fat_allocate_clusters(service_id, &cfg, cfg.bitmap_cluster,
 	    div_round_up(cfg.bitmap_size, cfg.cluster_size));
 	if (rc != EOK) {
@@ -662,5 +724,5 @@
 	}
 
-	next_cls = FIRST_FREE_CLUSTER +
+	next_cls = cfg.bitmap_cluster +
 	    div_round_up(cfg.bitmap_size, cfg.cluster_size);
 	cfg.upcase_table_cluster = next_cls;
@@ -699,4 +761,11 @@
 	}
 
+	rc = root_dentries_write(service_id, &cfg);
+	if (rc != EOK) {
+		printf(NAME ": Error, failed to write the root directory" \
+		    " entries to disk.\n");
+		return 2;
+	}
+
 	rc = bootsec_write(service_id, &cfg);
 	if (rc != EOK) {
