title: Black screen in QEmu for ARM-Ubuntu (how to get GUI?)
body: <p>I am hosting Ubuntu 16.04 on Virtual Box from Windows 10. Inside that Ubuntu 16.04, there is QEmu emulating ARM processor, running Ubuntu Trusty (14.04).</p>
  
  <p>When I start QEmu as follows, it shows a window with title <code>QEMU</code>, but completely black client area:</p>
  
  <pre><code>qemu-system-arm -smp 2 --drive format=raw,if=sd,file=vexpress-8G.img -kernel vmlinuz-3.13.0-24-generic-lpae -initrd initrd.img-3.13.0-24-generic-lpae -M vexpress-a15 -serial stdio -m 2048 -append 'root=/dev/mmcblk0 rw mem=2048M raid=noautodetect rootwait console=ttyAMA0,38400n8 devtmpfs.mount=0' -dtb ./vexpress-v2p-ca15-tc1.dtb
  </code></pre>
  
  <p>The console of the guest OS (ARM-Ubuntu) works, boot messages are displayed in the same terminal where <code>qemu-system-arm</code> command has been run. But when I type <code>startx</code> command, it shows errors:</p>
  
  <pre><code>Loading extension GLX
  (EE) 
  Fatal server error:
  (EE) no screens found(EE) 
  (EE) 
  Please consult the The X.Org Foundation support 
       at http://wiki.x.org
   for help. 
  (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
  (EE) 
  (EE) Server terminated with error (1). Closing log file.
  xinit: giving up
  xinit: unable to connect to X server: Connection refused
  xinit: server error
  </code></pre>
  
  <p>/var/log/Xorg.0.log contains the following:</p>
  
  <pre><code>[   214.406] 
  X.Org X Server 1.15.1
  Release Date: 2014-04-13
  [   214.411] X Protocol Version 11, Revision 0
  [   214.411] Build Operating System: Linux 3.2.0-58-highbank armv7l Ubuntu
  [   214.412] Current Operating System: Linux VM-Ubuntu1 3.13.0-24-generic-lpae #46-Ubuntu SMP Thu Apr 10 21:01:14 UTC 2014 armv7l
  [   214.413] Kernel command line: root=/dev/mmcblk0 rw mem=2048M raid=noautodetect rootwait console=ttyAMA0,38400n8 devtmpfs.mount=0
  [   214.416] Build Date: 16 April 2014  01:41:53PM
  [   214.417] xorg-server 2:1.15.1-0ubuntu2 (For technical support please see http://www.ubuntu.com/support) 
  [   214.418] Current version of pixman: 0.30.2
  [   214.418]    Before reporting problems, check http://wiki.x.org
      to make sure that you have the latest version.
  [   214.419] Markers: (--) probed, (**) from config file, (==) default setting,
      (++) from command line, (!!) notice, (II) informational,
      (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
  [   214.431] (==) Log file: "/var/log/Xorg.0.log", Time: Fri Aug 19 16:21:42 2016
  [   214.446] (==) Using system config directory "/usr/share/X11/xorg.conf.d"
  [   214.461] (==) No Layout section.  Using the first Screen section.
  [   214.462] (==) No screen section available. Using defaults.
  [   214.463] (**) |--&gt;Screen "Default Screen Section" (0)
  [   214.463] (**) |   |--&gt;Monitor "&lt;default monitor&gt;"
  [   214.468] (==) No monitor specified for screen "Default Screen Section".
      Using a default monitor configuration.
  [   214.470] (==) Automatically adding devices
  [   214.471] (==) Automatically enabling devices
  [   214.471] (==) Automatically adding GPU devices
  [   214.475] (WW) The directory "/usr/share/fonts/X11/cyrillic" does not exist.
  [   214.476]    Entry deleted from font path.
  [   214.476] (WW) The directory "/usr/share/fonts/X11/100dpi/" does not exist.
  [   214.477]    Entry deleted from font path.
  [   214.478] (WW) The directory "/usr/share/fonts/X11/75dpi/" does not exist.
  [   214.478]    Entry deleted from font path.
  [   214.479] (WW) The directory "/usr/share/fonts/X11/100dpi" does not exist.
  [   214.479]    Entry deleted from font path.
  [   214.480] (WW) The directory "/usr/share/fonts/X11/75dpi" does not exist.
  [   214.480]    Entry deleted from font path.
  [   214.481] (==) FontPath set to:
      /usr/share/fonts/X11/misc,
      /usr/share/fonts/X11/Type1,
      built-ins
  [   214.482] (==) ModulePath set to "/usr/lib/arm-linux-gnueabihf/xorg/extra-modules,/usr/lib/xorg/extra-modules,/usr/lib/xorg/modules"
  [   214.484] (II) The server relies on udev to provide the list of input devices.
      If no devices become available, reconfigure udev or disable AutoAddDevices.
  [   214.485] (II) Loader magic: 0xb7008f18
  [   214.486] (II) Module ABI versions:
  [   214.486]    X.Org ANSI C Emulation: 0.4
  [   214.487]    X.Org Video Driver: 15.0
  [   214.487]    X.Org XInput driver : 20.0
  [   214.489]    X.Org Server Extension : 8.0
  [   214.495] Initializing built-in extension Generic Event Extension
  [   214.496] Initializing built-in extension SHAPE
  [   214.497] Initializing built-in extension MIT-SHM
  [   214.497] Initializing built-in extension XInputExtension
  [   214.498] Initializing built-in extension XTEST
  [   214.498] Initializing built-in extension BIG-REQUESTS
  [   214.499] Initializing built-in extension SYNC
  [   214.500] Initializing built-in extension XKEYBOARD
  [   214.500] Initializing built-in extension XC-MISC
  [   214.501] Initializing built-in extension SECURITY
  [   214.501] Initializing built-in extension XINERAMA
  [   214.503] Initializing built-in extension XFIXES
  [   214.503] Initializing built-in extension RENDER
  [   214.504] Initializing built-in extension RANDR
  [   214.505] Initializing built-in extension COMPOSITE
  [   214.505] Initializing built-in extension DAMAGE
  [   214.506] Initializing built-in extension MIT-SCREEN-SAVER
  [   214.506] Initializing built-in extension DOUBLE-BUFFER
  [   214.507] Initializing built-in extension RECORD
  [   214.507] Initializing built-in extension DPMS
  [   214.508] Initializing built-in extension Present
  [   214.508] Initializing built-in extension DRI3
  [   214.509] Initializing built-in extension X-Resource
  [   214.509] Initializing built-in extension XVideo
  [   214.510] Initializing built-in extension XVideo-MotionCompensation
  [   214.512] Initializing built-in extension SELinux
  [   214.513] Initializing built-in extension XFree86-VidModeExtension
  [   214.514] Initializing built-in extension XFree86-DGA
  [   214.514] Initializing built-in extension XFree86-DRI
  [   214.515] Initializing built-in extension DRI2
  [   214.516] (II) LoadModule: "glx"
  [   214.537] (II) Loading /usr/lib/xorg/modules/extensions/libglx.so
  [   214.612] (II) Module glx: vendor="X.Org Foundation"
  [   214.613]    compiled for 1.15.1, module version = 1.0.0
  [   214.614]    ABI class: X.Org Server Extension, version 8.0
  [   214.615] (==) AIGLX enabled
  [   214.616] Loading extension GLX
  [   214.619] (==) Matched modesetting as autoconfigured driver 0
  [   214.619] (==) Matched fbdev as autoconfigured driver 1
  [   214.620] (==) Assigned the driver to the xf86ConfigLayout
  [   214.621] (II) LoadModule: "modesetting"
  [   214.625] (II) Loading /usr/lib/xorg/modules/drivers/modesetting_drv.so
  [   214.628] (II) Module modesetting: vendor="X.Org Foundation"
  [   214.629]    compiled for 1.15.0, module version = 0.8.1
  [   214.630]    Module class: X.Org Video Driver
  [   214.630]    ABI class: X.Org Video Driver, version 15.0
  [   214.631] (II) LoadModule: "fbdev"
  [   214.635] (II) Loading /usr/lib/xorg/modules/drivers/fbdev_drv.so
  [   214.638] (II) Module fbdev: vendor="X.Org Foundation"
  [   214.639]    compiled for 1.15.0, module version = 0.4.4
  [   214.639]    Module class: X.Org Video Driver
  [   214.640]    ABI class: X.Org Video Driver, version 15.0
  [   214.642] (II) modesetting: Driver for Modesetting Kernel Drivers: kms
  [   214.644] (II) FBDEV: driver for framebuffer: fbdev
  [   214.647] (--) using VT number 7
  
  [   214.652] (WW) Falling back to old probe method for modesetting
  [   214.656] (EE) open /dev/dri/card0: No such file or directory
  [   214.657] (WW) Falling back to old probe method for fbdev
  [   214.658] (II) Loading sub module "fbdevhw"
  [   214.658] (II) LoadModule: "fbdevhw"
  [   214.663] (II) Loading /usr/lib/xorg/modules/libfbdevhw.so
  [   214.666] (II) Module fbdevhw: vendor="X.Org Foundation"
  [   214.669]    compiled for 1.15.1, module version = 0.0.2
  [   214.669]    ABI class: X.Org Video Driver, version 15.0
  [   214.671] (EE) open /dev/fb0: No such file or directory
  [   214.672] (EE) No devices detected.
  [   214.674] (==) Matched modesetting as autoconfigured driver 0
  [   214.674] (==) Matched fbdev as autoconfigured driver 1
  [   214.675] (==) Assigned the driver to the xf86ConfigLayout
  [   214.675] (II) LoadModule: "modesetting"
  [   214.679] (II) Loading /usr/lib/xorg/modules/drivers/modesetting_drv.so
  [   214.680] (II) Module modesetting: vendor="X.Org Foundation"
  [   214.681]    compiled for 1.15.0, module version = 0.8.1
  [   214.681]    Module class: X.Org Video Driver
  [   214.682]    ABI class: X.Org Video Driver, version 15.0
  [   214.682] (II) UnloadModule: "modesetting"
  [   214.683] (II) Unloading modesetting
  [   214.685] (II) Failed to load module "modesetting" (already loaded, -1205831248)
  [   214.686] (II) LoadModule: "fbdev"
  [   214.689] (II) Loading /usr/lib/xorg/modules/drivers/fbdev_drv.so
  [   214.690] (II) Module fbdev: vendor="X.Org Foundation"
  [   214.691]    compiled for 1.15.0, module version = 0.4.4
  [   214.691]    Module class: X.Org Video Driver
  [   214.692]    ABI class: X.Org Video Driver, version 15.0
  [   214.692] (II) UnloadModule: "fbdev"
  [   214.694] (II) Unloading fbdev
  [   214.695] (II) Failed to load module "fbdev" (already loaded, -1205831248)
  [   214.695] (II) modesetting: Driver for Modesetting Kernel Drivers: kms
  [   214.696] (II) FBDEV: driver for framebuffer: fbdev
  [   214.699] (++) using VT number 7
  
  [   214.699] (WW) xf86OpenConsole: setpgid failed: Operation not permitted
  [   214.700] (WW) xf86OpenConsole: setsid failed: Operation not permitted
  [   214.701] (WW) Falling back to old probe method for modesetting
  [   214.702] (EE) open /dev/dri/card0: No such file or directory
  [   214.702] (WW) Falling back to old probe method for fbdev
  [   214.703] (II) Loading sub module "fbdevhw"
  [   214.703] (II) LoadModule: "fbdevhw"
  [   214.708] (II) Loading /usr/lib/xorg/modules/libfbdevhw.so
  [   214.708] (II) Module fbdevhw: vendor="X.Org Foundation"
  [   214.709]    compiled for 1.15.1, module version = 0.0.2
  [   214.710]    ABI class: X.Org Video Driver, version 15.0
  [   214.710] (EE) open /dev/fb0: No such file or directory
  [   214.711] (EE) No devices detected.
  [   214.711] (EE) 
  Fatal server error:
  [   214.714] (EE) no screens found(EE) 
  [   214.716] (EE) 
  Please consult the The X.Org Foundation support 
       at http://wiki.x.org
   for help. 
  [   214.717] (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
  [   214.718] (EE) 
  [   214.723] (EE) Server terminated with error (1). Closing log file.
  </code></pre>
  
  <p>The complete steps it took me to create and boot an ARM-Ubuntu image are below (based on <a href="https://wiki.ubuntu.com/Kernel/Dev/QemuARMVexpress">https://wiki.ubuntu.com/Kernel/Dev/QemuARMVexpress</a> ):</p>
  
  <pre><code># 1) setup the rootfs
  
  sudo apt-get install qemu-user-static qemu-system-arm
  
  mkdir vexpress
  cd vexpress
  mkdir qemu-img
  
  # Create 8-GB image
  dd if=/dev/zero of=./vexpress-8G.img bs=8M count=1024
  sudo losetup -f ./vexpress-8G.img
  sudo mkfs.ext4 /dev/loop0
  sudo mount /dev/loop0 qemu-img
  
  # Bootstrap Ubuntu Trusty armhf rootfs in the qemu-img directory
  # For Ubuntu versions later than Trusty some commands fail
  # For Ubuntu versions before Saucy there is no port to ARM
  # Ubuntu Saucy is not supported anymore
  sudo qemu-debootstrap --arch=armhf trusty qemu-img
  sudo cp `which qemu-arm-static` qemu-img/usr/bin/
  
  # setup serial console, apt repositories and network
  sudo chroot qemu-img
  sed 's/tty1/ttyAMA0/g' /etc/init/tty1.conf &gt; /etc/init/ttyAMA0.conf
  echo "deb  http://ports.ubuntu.com trusty main restricted multiverse universe" &gt; /etc/apt/sources.list
  apt-get update
  echo -e "\nauto eth0\niface eth0 inet dhcp" &gt;&gt; /etc/network/interfaces
  
  # root password
  passwd
  
  
  # 2) pick and install a kernel
  
  # Fix locale problems http://askubuntu.com/questions/162391/how-do-i-fix-my-locale-issue
  locale
  sudo locale-gen "be_BY.UTF-8"
  sudo locale-gen "en_US"
  sudo locale-gen "en_US.UTF-8"
  sudo dpkg-reconfigure locales
  
  apt-get install wget ca-certificates
  wget https://launchpad.net/ubuntu/+archive/primary/+files/linux-image-3.13.0-24-generic-lpae_3.13.0-24.46_armhf.deb
  dpkg -i linux-image-3.13.0-24-generic-lpae_3.13.0-24.46_armhf.deb
  
  # So far I'm getting the following warnings:
  #   Warning: cannot read table of mounted file systems: No such file or directory
  #   warning: failed to read mtab
  
  # !!! press CTRL+D to exit the chroot
  ^D
  
  
  # 3) Boot it up
  
  
  # copy kernel, initrd and dtb files
  sudo cp qemu-img/boot/vmlinuz-3.13.0-24-generic-lpae .
  sudo cp qemu-img/boot/initrd.img-3.13.0-24-generic-lpae .
  sudo cp qemu-img/lib/firmware/3.13.0-24-generic-lpae/device-tree/vexpress-v2p-ca15-tc1.dtb .
  
  # umount the rootfs img
  sudo umount qemu-img
  
  sudo chmod 777 vmlinuz-3.13.0-24-generic-lpae
  sudo chmod 777 initrd.img-3.13.0-24-generic-lpae
  sudo chmod 777 vexpress-v2p-ca15-tc1.dtb
  sudo chmod 777 vexpress-8G.img
  
  # http://unix.stackexchange.com/questions/167165/how-to-pass-ctrl-c-in-qemu
  # Allow Ctrl+C and Ctrl+Z on guest, changing them on host to Ctrl+] and Ctrl+[
  stty intr ^]
  stty susp ^j
  
  qemu-system-arm -smp 2 --drive format=raw,if=sd,file=vexpress-8G.img -kernel vmlinuz-3.13.0-24-generic-lpae -initrd initrd.img-3.13.0-24-generic-lpae -M vexpress-a15 -serial stdio -m 2048 -append 'root=/dev/mmcblk0 rw mem=2048M raid=noautodetect rootwait console=ttyAMA0,38400n8 devtmpfs.mount=0' -dtb ./vexpress-v2p-ca15-tc1.dtb
  </code></pre>
  
  <p>I don't know if it's an Ubuntu (software) or QEmu (emulated hardware) problem.</p>