diff --git a/lib/private/util.php b/lib/private/util.php
index 04f00f42447e2434de0ec16b7a30d34008359eaa..a9c4cc70a0ea2dbd3b3b73371714afcb4336f60e 100755
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -463,26 +463,28 @@ class OC_Util {
 				);
 			}
 		}
-
-		if (!is_dir($CONFIG_DATADIRECTORY)) {
-			$success = @mkdir($CONFIG_DATADIRECTORY);
-			if ($success) {
-				$errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY));
-			} else {
+		// Create root dir.
+		if ($config->getSystemValue('installed', false)) {
+			if (!is_dir($CONFIG_DATADIRECTORY)) {
+				$success = @mkdir($CONFIG_DATADIRECTORY);
+				if ($success) {
+					$errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY));
+				} else {
+					$errors[] = array(
+						'error' => $l->t('Cannot create "data" directory (%s)', array($CONFIG_DATADIRECTORY)),
+						'hint' => $l->t('This can usually be fixed by '
+							. '<a href="%s" target="_blank">giving the webserver write access to the root directory</a>.',
+							array(OC_Helper::linkToDocs('admin-dir_permissions')))
+					);
+				}
+			} else if (!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) {
 				$errors[] = array(
-					'error' => $l->t('Cannot create "data" directory (%s)', array($CONFIG_DATADIRECTORY)),
-					'hint' => $l->t('This can usually be fixed by '
-						. '<a href="%s" target="_blank">giving the webserver write access to the root directory</a>.',
-						array(OC_Helper::linkToDocs('admin-dir_permissions')))
+					'error' => 'Data directory (' . $CONFIG_DATADIRECTORY . ') not writable by ownCloud',
+					'hint' => $permissionsHint
 				);
+			} else {
+				$errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY));
 			}
-		} else if (!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) {
-			$errors[] = array(
-				'error' => 'Data directory (' . $CONFIG_DATADIRECTORY . ') not writable by ownCloud',
-				'hint' => $permissionsHint
-			);
-		} else {
-			$errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY));
 		}
 
 		if (!OC_Util::isSetLocaleWorking()) {
diff --git a/tests/lib/utilcheckserver.php b/tests/lib/utilcheckserver.php
index 78888bd909d8051e3015d09d50d377d847293db8..be5596c1900a0b6ab433c80dffb7b9a0938b768f 100644
--- a/tests/lib/utilcheckserver.php
+++ b/tests/lib/utilcheckserver.php
@@ -19,6 +19,7 @@ class Test_Util_CheckServer extends PHPUnit_Framework_TestCase {
 	 */
 	protected function getConfig($systemOptions) {
 		$systemOptions['datadirectory'] = $this->datadir;
+		$systemOptions['appstoreenabled'] = false; //it's likely that there is no app folder we can write in
 		$config = $this->getMockBuilder('\OCP\IConfig')
 			->disableOriginalConstructor()
 			->getMock();
@@ -35,6 +36,7 @@ class Test_Util_CheckServer extends PHPUnit_Framework_TestCase {
 		$this->datadir = \OC_Helper::tmpFolder();
 
 		file_put_contents($this->datadir . '/.ocdata', '');
+		\OC::$server->getSession()->set('checkServer_succeeded', false);
 	}
 
 	public function tearDown() {
@@ -121,4 +123,39 @@ class Test_Util_CheckServer extends PHPUnit_Framework_TestCase {
 		$this->assertCount(1, $result);
 	}
 
+	/**
+	 * Tests that no error is given when the datadir is writable
+	 */
+	public function testDataDirWritable() {
+		$result = \OC_Util::checkServer($this->getConfig(array(
+			'installed' => true,
+			'version' => implode('.', OC_Util::getVersion())
+		)));
+		$this->assertEmpty($result);
+	}
+
+	/**
+	 * Tests an error is given when the datadir is not writable
+	 */
+	public function testDataDirNotWritable() {
+		chmod($this->datadir, 0300);
+		$result = \OC_Util::checkServer($this->getConfig(array(
+			'installed' => true,
+			'version' => implode('.', OC_Util::getVersion())
+		)));
+		$this->assertCount(1, $result);
+	}
+
+	/**
+	 * Tests no error is given when the datadir is not writable during setup
+	 */
+	public function testDataDirNotWritableSetup() {
+		chmod($this->datadir, 0300);
+		$result = \OC_Util::checkServer($this->getConfig(array(
+			'installed' => false,
+			'version' => implode('.', OC_Util::getVersion())
+		)));
+		chmod($this->datadir, 0700); //needed for cleanup
+		$this->assertEmpty($result);
+	}
 }