I was working on my Pi when suddenly it stuck. I attempted to restart but upon entering startx I got the error "Could not write pid to lock file in /tmp/xtX0-lock'

I've looked around and many people advised running the df -h Command. I have done that and nothing has changed for me.

Looking at the error screen it seems to be out of space, but placing it on my windows computer it shows me space. But even if it really is out of space. How do I clear up some items or what can I delete as I really have scripts I need. Thank you

Error SCreen

  • 1
    Windows does not show that full partion (which is mounted as root), windows shows you only the fat-partition (mounted as /boot) - which is not full. You'll need to get rid of some files, your package managers cache is a good point to start with.
    – Ghanima
    Mar 16, 2016 at 18:19

2 Answers 2


This is usually caused by a stale lock file from a crashed previous session. As root, look for an existing /tmp/xtX0-lock and delete it, then try starting X again.

Being out of drive space will also do it. Try deleting everything under /var/log, then use sudo apt-get erase <packages...> to perhaps remove some packages you don't actually need.

NOTE: Don't delete the directory structure under /var/log...just delete files; otherwise some services that expect certain log directories to exist will fail to start.

Realistically, 4GB is much too small a root device on a system which runs X. Image the SD card onto a larger one and expand the fs.

  • 1
    Could be, but nonetheless the root partition shows 100% usage, which is not a good thing.
    – Ghanima
    Mar 16, 2016 at 18:20
  • @Ghanima Agreed. As noted in my edit (which I was typing as you commented) I answered before I had fully read the question... Mar 16, 2016 at 18:22
  • sudo apt-get erase?
    – Grace
    Mar 16, 2016 at 18:25
  • @Grace see edits... yes use sudo (we old-school linux users still talk about doing things "as root" which is equivalent to putting sudo in front of whatever) Mar 16, 2016 at 19:52
  • Meh...I deleted the /var/log folder...it wouldnt start, had to reformat my SD card. Lost everytthing :( but thanks
    – Grace
    Mar 16, 2016 at 19:59

I had the same situation after installing opencv from source files. even erasing of files was only hardly possible - sometimes with crazy error msgs.

i uninstalled the gimp package. i deleted the source files of opencv. after deleting the whole opencv the strange effects were gone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.