“Could not stat /dev/sda1” when installing Citrix XenServer

By Alasdair Lumsden on 20 Oct 2010

If you get this error when installing Citrix XenServer…

Could not stat /dev/sda1 --- No such file or directory

… then I have a solution for you! Basically it’s caused by a race condition – the installer creates the partition table, but then immediately attempts to create a filesystem on /dev/sda1 before the Kernel has caught up with the partition table change.

You can fix the issue by:

1. Hit “Alt-F2” to get a console

2. Use “ps -ef” to get the pid of the installer, and “kill -9” it

3. Type “vi /etc/inittab”

4. Change the line under “# Start the installer on the console” to read:

tty1::respawn:/opt/xensource/installer/preinit


(This causes the installer to be respawned upon death – useful for debugging if things go wrong without requiring a reboot)

5. Type “vi /opt/xensource/installer/backend.py”

6. Near the top add “from time import sleep” under one of the import statements.

7. Near line 565, under the “def createDom0DiskFilesystems(…” bit, add a new line with “sleep(10)” in it:

def createDom0DiskFilesystems(disk, primary_partnum):
    sleep(10)
    rc, err = util.runCmd2....

Be sure to match the indentation of the lines below, as Python uses indentation as a part of its syntax.

8. Type “kill -HUP 1” to reload the inittab. The installer should respawn on tty1 – simply press “Alt-F1” to get to it. Perform the install.

This simple fix works by adding a sleep statement before the bit that creates a filesystem. Yay!