Index: uspace/app/bdwrite/bdwrite.c
===================================================================
--- uspace/app/bdwrite/bdwrite.c	(revision fad91b9136cd9298b086bc69a485e7c2d5cb822d)
+++ uspace/app/bdwrite/bdwrite.c	(revision 76cd345cd72977703548c1feb838664ee5b146ab)
@@ -40,4 +40,5 @@
 #include <stdlib.h>
 #include <stdio.h>
+#include <abi/ipc/ipc.h>
 
 static void usage(void);
@@ -106,19 +107,29 @@
 	}
 
-	uint8_t *buf = calloc(1, bsize);
-	for (size_t i = 0; i < blkcnt; i++) {
-		memset(buf, (i + 1) % 0x100, bsize);
-		rc = block_write_direct(dev, i + off, 1, buf);
+	uint64_t to_alloc = min(DATA_XFER_LIMIT, bsize * blkcnt);
+	uint8_t *buf = calloc(to_alloc / bsize, bsize);
+	if (buf == NULL) {
+		rc = ENOMEM;
+		goto end;
+	}
+	uint64_t left = blkcnt;
+	while (left > 0) {
+		uint64_t blks_to_write = min(to_alloc / bsize, left);
+		uint8_t *ptr = buf;
+		for (size_t i = 0; i < blks_to_write; i++) {
+			memset(ptr, (i + 1) % 0x100, bsize);
+			ptr = (uint8_t *)((uintptr_t) ptr + bsize);
+		}
+		rc = block_write_direct(dev, off, blks_to_write, buf);
 		if (rc != EOK) {
 			printf("bdwrite: error writing to \"%s\"\n", name);
-			free(buf);
-			block_fini(dev);
-			return 1;
+			goto end;
 		}
+		left -= blks_to_write;
 	}
-
+end:
 	free(buf);
 	block_fini(dev);
-	return 0;
+	return rc;
 bad:
 	usage();
