--- e2fsck/e2fsck.h
+++ e2fsck/e2fsck.h
@@ -67,7 +67,9 @@
 #define E2FSCK_ATTR(x)
 #endif
 
+#ifdef CONFIG_QUOTA
 #include "quota/mkquota.h"
+#endif
 
 /*
  * Exit codes used by fsck-type programs
@@ -317,10 +319,12 @@
 	io_channel	journal_io;
 	char	*journal_name;
 
+#ifdef CONFIG_QUOTA
 	/*
 	 * Ext4 quota support
 	 */
 	quota_ctx_t qctx;
+#endif
 #ifdef RESOURCE_TRACK
 	/*
 	 * For timing purposes
@@ -460,8 +464,10 @@
 /* logfile.c */
 extern void set_up_logging(e2fsck_t ctx);
 
+#ifdef CONFIG_QUOTA
 /* quota.c */
 extern void e2fsck_hide_quota(e2fsck_t ctx);
+#endif
 
 /* pass1.c */
 extern void e2fsck_setup_tdb_icount(e2fsck_t ctx, int flags,
--- e2fsck/Makefile.in
+++ e2fsck/Makefile.in
@@ -11,6 +11,13 @@
 
 @MCONFIG@
 
+DEPLIBQUOTA:=
+DEPPROFILED_LIBQUOTA:=
+DEPSTATIC_LIBQUOTA:=
+LIBQUOTA:=
+PROFILED_LIBQUOTA:=
+STATIC_LIBQUOTA:=
+
 PROGS=		e2fsck
 MANPAGES=	e2fsck.8
 FMANPAGES=	e2fsck.conf.5
--- e2fsck/pass1b.c
+++ e2fsck/pass1b.c
@@ -644,8 +644,10 @@
 	if (ctx->inode_bad_map)
 		ext2fs_unmark_inode_bitmap2(ctx->inode_bad_map, ino);
 	ext2fs_inode_alloc_stats2(fs, ino, -1, LINUX_S_ISDIR(inode.i_mode));
+#ifdef CONFIG_QUOTA
 	quota_data_sub(ctx->qctx, &inode, ino, pb.dup_blocks * fs->blocksize);
 	quota_data_inodes(ctx->qctx, &inode, ino, -1);
+#endif
 
 	/* Inode may have changed by block_iterate, so reread it */
 	e2fsck_read_inode(ctx, ino, &inode, "delete_file");
@@ -677,7 +679,9 @@
 			delete_file_block(fs, &blk,
 					  BLOCK_COUNT_EXTATTR, 0, 0, &pb);
 			ext2fs_file_acl_block_set(fs, &inode, blk);
+#ifdef CONFIG_QUOTA
 			quota_data_sub(ctx->qctx, &inode, ino, fs->blocksize);
+#endif
 		}
 	}
 }
--- e2fsck/pass1.c
+++ e2fsck/pass1.c
@@ -922,6 +922,7 @@
 				e2fsck_write_inode_full(ctx, ino, inode,
 							inode_size, "pass1");
 			}
+#ifdef CONFIG_QUOTA
 		} else if ((ino == EXT4_USR_QUOTA_INO) ||
 			   (ino == EXT4_GRP_QUOTA_INO)) {
 			ext2fs_mark_inode_bitmap2(ctx->inode_used_map, ino);
@@ -949,6 +950,7 @@
 				e2fsck_write_inode_full(ctx, ino, inode,
 							inode_size, "pass1");
 			}
+#endif
 		} else if (ino < EXT2_FIRST_INODE(fs->super)) {
 			int	problem = 0;
 
@@ -2089,9 +2091,11 @@
 	}
 
 	if (ino == EXT2_ROOT_INO || ino >= EXT2_FIRST_INODE(ctx->fs->super)) {
+#ifdef CONFIG_QUOTA
 		quota_data_add(ctx->qctx, inode, ino,
 			       pb.num_blocks * fs->blocksize);
 		quota_data_inodes(ctx->qctx, inode, ino, +1);
+#endif
 	}
 
 	if (!(fs->super->s_feature_ro_compat &
--- e2fsck/pass3.c
+++ e2fsck/pass3.c
@@ -490,8 +490,10 @@
 	ext2fs_icount_store(ctx->inode_count, ino, 2);
 	ext2fs_icount_store(ctx->inode_link_info, ino, 2);
 	ctx->lost_and_found = ino;
+#ifdef CONFIG_QUOTA
 	quota_data_add(ctx->qctx, &inode, ino, fs->blocksize);
 	quota_data_inodes(ctx->qctx, &inode, ino, +1);
+#endif
 #if 0
 	printf("/lost+found created; inode #%lu\n", ino);
 #endif
@@ -794,7 +796,9 @@
 
 	inode.i_size = (es.last_block + 1) * fs->blocksize;
 	ext2fs_iblk_add_blocks(fs, &inode, es.newblocks);
+#ifdef CONFIG_QUOTA
 	quota_data_add(ctx->qctx, &inode, dir, es.newblocks * fs->blocksize);
+#endif
 
 	e2fsck_write_inode(ctx, dir, &inode, "expand_directory");
 
--- e2fsck/pass4.c
+++ e2fsck/pass4.c
@@ -64,7 +64,9 @@
 			e2fsck_read_bitmaps(ctx);
 			ext2fs_inode_alloc_stats2(fs, i, -1,
 						  LINUX_S_ISDIR(inode->i_mode));
+#ifdef CONFIG_QUOTA
 			quota_data_inodes(ctx->qctx, inode, i, -1);
+#endif
 			return 0;
 		}
 	}
--- e2fsck/problem.c
+++ e2fsck/problem.c
@@ -408,10 +408,12 @@
 	  N_("Setting free @bs count to %c (was %b)\n"),
 	  PROMPT_NONE, PR_PREEN_NOMSG },
 
+#ifdef CONFIG_QUOTA
 	/* Making quota file hidden */
 	{ PR_0_HIDE_QUOTA,
 	  N_("Making @q @i %i (%Q) hidden.\n"),
 	  PROMPT_NONE, PR_PREEN_OK },
+#endif
 
 	/* Superblock has invalid MMP block. */
 	{ PR_0_MMP_INVALID_BLK,
@@ -921,20 +923,26 @@
 	  N_("Error converting subcluster @b @B: %m\n"),
 	  PROMPT_NONE, PR_FATAL },
 
+#ifdef CONFIG_QUOTA
 	/* Quota inode has bad mode */
 	{ PR_1_QUOTA_BAD_MODE,
 	  N_("@q @i is not regular file.  "),
 	  PROMPT_CLEAR, PR_PREEN_OK },
+#endif
 
+#ifdef CONFIG_QUOTA
 	/* Quota inode is not in use, but contains data */
 	{ PR_1_QUOTA_INODE_NOT_CLEAR,
 	  N_("@q @i is not in use, but contains data.  "),
 	  PROMPT_CLEAR, PR_PREEN_OK },
+#endif
 
+#ifdef CONFIG_QUOTA
 	/* Quota inode is user visible */
 	{ PR_1_QUOTA_INODE_NOT_HIDDEN,
 	  N_("@q @i is visible to the user.  "),
 	  PROMPT_CLEAR, PR_PREEN_OK },
+#endif
 
 	/* Invalid bad inode */
 	{ PR_1_INVALID_BAD_INODE,
@@ -1699,10 +1707,12 @@
 	  N_("Recreate @j"),
 	  PROMPT_NULL, PR_PREEN_OK | PR_NO_OK },
 
+#ifdef CONFIG_QUOTA
 	/* Update quota information if it is inconsistent */
 	{ PR_6_UPDATE_QUOTAS,
 	  N_("Update quota info for quota type %N"),
 	  PROMPT_NULL, PR_PREEN_OK },
+#endif
 
 	{ 0 }
 };
--- e2fsck/problem.h
+++ e2fsck/problem.h
@@ -234,8 +234,10 @@
 /* Free blocks count wrong */
 #define PR_0_FREE_BLOCK_COUNT			0x000040
 
+#ifdef CONFIG_QUOTA
 /* Make quota file hidden */
 #define	PR_0_HIDE_QUOTA				0x000041
+#endif
 
 /* Superblock has invalid MMP block. */
 #define PR_0_MMP_INVALID_BLK			0x000042
@@ -543,14 +545,20 @@
 /* Failed to convert subcluster bitmap */
 #define PR_1_CONVERT_SUBCLUSTER		0x010061
 
+#ifdef CONFIG_QUOTA
 /* Quota inode has wrong mode */
 #define PR_1_QUOTA_BAD_MODE		0x010062
+#endif
 
+#ifdef CONFIG_QUOTA
 /* Quota inode is not in use, but contains data */
 #define PR_1_QUOTA_INODE_NOT_CLEAR	0x010063
+#endif
 
+#ifdef CONFIG_QUOTA
 /* Quota inode is user visible */
 #define PR_1_QUOTA_INODE_NOT_HIDDEN	0x010064
+#endif
 
 /* Invalid bad inode */
 #define PR_1_INVALID_BAD_INODE		0x010065
@@ -1030,8 +1038,10 @@
 /* Recreate the journal if E2F_FLAG_JOURNAL_INODE flag is set */
 #define PR_6_RECREATE_JOURNAL		0x060001
 
+#ifdef CONFIG_QUOTA
 /* Update quota information if it is inconsistent */
 #define PR_6_UPDATE_QUOTAS		0x060002
+#endif
 
 /*
  * Function declarations
--- e2fsck/quota.c
+++ e2fsck/quota.c
@@ -4,6 +4,7 @@
  */
 
 #include "config.h"
+#ifdef CONFIG_QUOTA
 #ifdef HAVE_SYS_MOUNT_H
 #include <sys/param.h>
 #include <sys/mount.h>
@@ -80,3 +81,4 @@
 
 	return;
 }
+#endif
--- e2fsck/super.c
+++ e2fsck/super.c
@@ -855,10 +855,12 @@
 	 */
 	e2fsck_fix_dirhash_hint(ctx);
 
+#ifdef CONFIG_QUOTA
 	/*
 	 * Hide quota inodes if necessary.
 	 */
 	e2fsck_hide_quota(ctx);
+#endif
 
 	return;
 }
--- e2fsck/unix.c
+++ e2fsck/unix.c
@@ -1609,6 +1609,7 @@
 	else
 		journal_size = -1;
 
+#ifdef CONFIG_QUOTA
 	if (sb->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_QUOTA) {
 		/* Quotas were enabled. Do quota accounting during fsck. */
 		if ((sb->s_usr_quota_inum && sb->s_grp_quota_inum) ||
@@ -1619,6 +1620,7 @@
 
 		quota_init_context(&ctx->qctx, ctx->fs, qtype);
 	}
+#endif
 
 	run_result = e2fsck_run(ctx);
 	e2fsck_clear_progbar(ctx);
@@ -1652,6 +1654,7 @@
 	}
 no_journal:
 
+#ifdef CONFIG_QUOTA
 	if (ctx->qctx) {
 		int i, needs_writeout;
 		for (i = 0; i < MAXQUOTAS; i++) {
@@ -1667,6 +1670,7 @@
 		}
 		quota_release_context(&ctx->qctx);
 	}
+#endif
 
 	if (run_result == E2F_FLAG_RESTART) {
 		log_out(ctx, _("Restarting e2fsck from the beginning...\n"));
--- misc/Makefile.in
+++ misc/Makefile.in
@@ -11,6 +11,13 @@
 
 @MCONFIG@
 
+DEPLIBQUOTA:=
+DEPPROFILED_LIBQUOTA:=
+DEPSTATIC_LIBQUOTA:=
+LIBQUOTA:=
+PROFILED_LIBQUOTA:=
+STATIC_LIBQUOTA:=
+
 @DEFRAG_CMT@@LINUX_CMT@E4DEFRAG_PROG= e4defrag
 @DEFRAG_CMT@@LINUX_CMT@E4DEFRAG_MAN= e4defrag.8
 
--- misc/mke2fs.c
+++ misc/mke2fs.c
@@ -61,7 +61,9 @@
 #include "prof_err.h"
 #include "../version.h"
 #include "nls-enable.h"
+#ifdef CONFIG_QUOTA
 #include "quota/mkquota.h"
+#endif
 
 #define STRIDE_LENGTH 8
 
@@ -93,7 +95,9 @@
 int	lazy_itable_init;
 char	*bad_blocks_filename;
 __u32	fs_stride;
+#ifdef CONFIG_QUOTA
 int	quotatype = -1;  /* Initialize both user and group quotas by default */
+#endif
 
 struct ext2_super_block fs_param;
 char *fs_uuid = NULL;
@@ -795,6 +799,7 @@
 			discard = 1;
 		} else if (!strcmp(token, "nodiscard")) {
 			discard = 0;
+#ifdef CONFIG_QUOTA
 		} else if (!strcmp(token, "quotatype")) {
 			if (!arg) {
 				r_usage++;
@@ -812,6 +817,7 @@
 				r_usage++;
 				continue;
 			}
+#endif
 		} else {
 			r_usage++;
 			badopt = token;
@@ -831,7 +837,11 @@
 			"\ttest_fs\n"
 			"\tdiscard\n"
 			"\tnodiscard\n"
-			"\tquotatype=<usr OR grp>\n\n"),
+#ifdef CONFIG_QUOTA
+			"\tquotatype=<usr OR grp>\n"
+#endif
+			"\n"
+			),
 			badopt ? badopt : "");
 		free(buf);
 		exit(1);
@@ -2256,6 +2266,7 @@
 	ext2fs_free_blocks_count_set(fs->super, EXT2FS_C2B(fs, tot_free));
 }
 
+#ifdef CONFIG_QUOTA
 static int create_quota_inodes(ext2_filsys fs)
 {
 	quota_ctx_t qctx;
@@ -2267,6 +2278,7 @@
 
 	return 0;
 }
+#endif
 
 int main (int argc, char *argv[])
 {
@@ -2626,9 +2638,11 @@
 	if (EXT2_HAS_RO_COMPAT_FEATURE(&fs_param,
 				       EXT4_FEATURE_RO_COMPAT_BIGALLOC))
 		fix_cluster_bg_counts(fs);
+#ifdef CONFIG_QUOTA
 	if (EXT2_HAS_RO_COMPAT_FEATURE(&fs_param,
 				       EXT4_FEATURE_RO_COMPAT_QUOTA))
 		create_quota_inodes(fs);
+#endif
 
 	if (!quiet)
 		printf(_("Writing superblocks and "
--- misc/tune2fs.c
+++ misc/tune2fs.c
@@ -56,7 +56,9 @@
 #include "jfs_user.h"
 #include "util.h"
 #include "blkid/blkid.h"
+#ifdef CONFIG_QUOTA
 #include "quota/mkquota.h"
+#endif
 
 #include "../version.h"
 #include "nls-enable.h"
@@ -71,7 +73,11 @@
 char *new_label, *new_last_mounted, *new_UUID;
 char *io_options;
 static int c_flag, C_flag, e_flag, f_flag, g_flag, i_flag, l_flag, L_flag;
-static int m_flag, M_flag, Q_flag, r_flag, s_flag = -1, u_flag, U_flag, T_flag;
+static int m_flag, M_flag,
+#ifdef CONFIG_QUOTA
+Q_flag,
+#endif
+r_flag, s_flag = -1, u_flag, U_flag, T_flag;
 static int I_flag;
 static int clear_mmp;
 static time_t last_check_time;
@@ -90,7 +96,9 @@
 static char *extended_cmd;
 static unsigned long new_inode_size;
 static char *ext_mount_opts;
+#ifdef CONFIG_QUOTA
 static int usrquota, grpquota;
+#endif
 
 int journal_size, journal_flags;
 char *journal_device;
@@ -569,6 +577,7 @@
 		fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
 	}
 
+#ifdef CONFIG_QUOTA
 	if (FEATURE_ON(E2P_FEATURE_RO_INCOMPAT,
 				EXT4_FEATURE_RO_COMPAT_QUOTA)) {
 		/*
@@ -598,6 +607,7 @@
 		usrquota = QOPT_DISABLE;
 		grpquota = QOPT_DISABLE;
 	}
+#endif
 
 	if (sb->s_rev_level == EXT2_GOOD_OLD_REV &&
 	    (sb->s_feature_compat || sb->s_feature_ro_compat ||
@@ -701,6 +711,7 @@
 	return 1;
 }
 
+#ifdef CONFIG_QUOTA
 void handle_quota_options(ext2_filsys fs)
 {
 	quota_ctx_t qctx;
@@ -793,6 +804,7 @@
 	}
 	free(buf);
 }
+#endif
 
 
 
@@ -1014,11 +1026,13 @@
 			features_cmd = optarg;
 			open_flag = EXT2_FLAG_RW;
 			break;
+#ifdef CONFIG_QUOTA
 		case 'Q':
 			Q_flag = 1;
 			parse_quota_opts(optarg);
 			open_flag = EXT2_FLAG_RW;
 			break;
+#endif
 		case 'r':
 			reserved_blocks = strtoul(optarg, &tmp, 0);
 			if (*tmp) {
@@ -2114,6 +2128,7 @@
 			goto closefs;
 	}
 
+#ifdef CONFIG_QUOTA
 	if (Q_flag) {
 		if (mount_flags & EXT2_MF_MOUNTED) {
 			fputs(_("The quota feature may only be changed when "
@@ -2123,6 +2138,7 @@
 		}
 		handle_quota_options(fs);
 	}
+#endif
 
 	if (U_flag) {
 		int set_csum = 0;
