Index: uspace/lib/ext4/src/ialloc.c
===================================================================
--- uspace/lib/ext4/src/ialloc.c	(revision 91fc2dae15616d58352348782bb0b784ca33f418)
+++ uspace/lib/ext4/src/ialloc.c	(revision 91fcbabcd33526a02f89ea5b6a4bcaf487965b5c)
@@ -176,10 +176,16 @@
 errno_t ext4_ialloc_alloc_inode(ext4_filesystem_t *fs, uint32_t *index, bool is_dir)
 {
+	int pick_first_free = 0;
 	ext4_superblock_t *sb = fs->superblock;
-
-	uint32_t bgid = 0;
-	uint32_t bg_count = ext4_superblock_get_block_group_count(sb);
-	uint32_t sb_free_inodes = ext4_superblock_get_free_inodes_count(sb);
-	uint32_t avg_free_inodes = sb_free_inodes / bg_count;
+	uint32_t bgid;
+	uint32_t sb_free_inodes;
+	uint32_t avg_free_inodes;
+	uint32_t const bg_count = ext4_superblock_get_block_group_count(sb);
+
+retry:
+
+	bgid = 0;
+	sb_free_inodes = ext4_superblock_get_free_inodes_count(sb);
+	avg_free_inodes = sb_free_inodes / bg_count;
 
 	/* Try to find free i-node in all block groups */
@@ -210,6 +216,6 @@
 		 * blocks.
 		 */
-		if (((free_inodes >= avg_free_inodes) || (bgid == bg_count - 1)) &&
-		    (free_blocks > 0)) {
+		if (((free_inodes >= avg_free_inodes) || (bgid == bg_count - 1)
+		    || pick_first_free) && (free_blocks > 0)) {
 			/* Load block with bitmap */
 			uint32_t bitmap_block_addr = ext4_block_group_get_inode_bitmap(
@@ -307,4 +313,10 @@
 	}
 
+	/* Try again with less strict conditions */
+	if (pick_first_free == 0) {
+		pick_first_free = 1;
+		goto retry;
+	}
+
 	return ENOSPC;
 }
