6

Recently my server started to behave weird and I have two issues which I believe to be related.

  • In Vi :

    • When I try to save a file I get :

      E509: Cannot create backup file
      

      and I need to save using :x! - if I don't force, it does not save.

    • When I open a file I get:

      E303: Unable to open swap file for "filename", recovery impossible
      
    • And any time I quit, I get:

      E138: Can't write viminfo file /root/.viminfo!
      
  • WordPress

It started to happen at the same time as the problem with Vi, all my installations of WordPress have a similar problem: every time I try to upload anything : image, theme, plugin, I get :

Missing a temporary folder. 

and I cannot upload the file.

  • Some element of solution:

I have tried to to fsck at reboot, it worked and the problem was fixed for a while, then it got corrupted again (a few hours later).

Any idea what's the problem? Any idea how to fix it?

I am running Ubuntu 12.04 on Amazon EC2

11
  • 2
    Are you out of storage space? Commented Dec 30, 2013 at 23:37
  • 1
    Please provide the output for df -h (storage space), cat /etc/fstab (to see your /tmp mounting), and stat -c%a / /tmp (permissions for / and /tmp). Commented Dec 30, 2013 at 23:47
  • # df -h df: cannot read table of mounted file systems Commented Dec 30, 2013 at 23:53
  • 1
    @Johann Savalle, edit these into your question for readability. Commented Dec 31, 2013 at 1:27
  • 1
    This question should be referenced next time someone asks why you'd want separate partitions for /var and others instead of a single partition. Commented Dec 31, 2013 at 1:29

1 Answer 1

8

When ever you run into an issue where you think you're out of diskspace or you're running out of diskspace there are 2 commands you can run to confirm this.

NOTE: Be aware that in addition to running out of diskspace, you might also be running out of inodes.

df

The command df is the venerable tool for reporting on filesystem usage.

Example

It has 2 switches that you'll likely use most of the time. Either -h or -k. I always opt for -h since this shows the disk space in human readable units.

$ df -h
Filesystem                         Size  Used Avail Use% Mounted on
/dev/mapper/fedora_greeneggs-root   50G   11G   36G  23% /
devtmpfs                           3.8G     0  3.8G   0% /dev
tmpfs                              3.9G  2.3M  3.8G   1% /dev/shm
tmpfs                              3.9G 1016K  3.8G   1% /run
tmpfs                              3.9G     0  3.9G   0% /sys/fs/cgroup
tmpfs                              3.9G  1.1G  2.8G  27% /tmp
/dev/sda1                          477M  101M  348M  23% /boot
/dev/mapper/fedora_greeneggs-home  402G  146G  236G  39% /home

Notice that my /tmp is configured with 3.9GB or which 1.1GB is used.

tune2fs

This command is a bit more obscure but is useful when you want to confirm if your system if running out of inodes. Believe it or not, but inodes is a limited resource that you allocate during the creation phase of your filesystem. Once allocated it cannot be changed.

I'd check to see if your system has run out of inodes.

Example

$ sudo tune2fs -l /dev/mapper/fedora_greeneggs-root | grep -i "inode"
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Inode count:              3276800
Free inodes:              3060507
Inodes per group:         8192
Inode blocks per group:   512
First inode:              11
Inode size:           256
Journal inode:            8
First orphan inode:       1321314
Journal backup:           inode blocks

So with the above you'll notice that we have 3276800 inode of which 3060507 are available.

Alternative inode method

There are several other ways you can do this. Certain versions of the df command can also report inodes.

$ df -i
Filesystem                          Inodes  IUsed    IFree IUse% Mounted on
/dev/mapper/fedora_greeneggs-root  3276800 226065  3050735    7% /
devtmpfs                            994457    480   993977    1% /dev
tmpfs                               996186     19   996167    1% /dev/shm
tmpfs                               996186    623   995563    1% /run
tmpfs                               996186     12   996174    1% /sys/fs/cgroup
tmpfs                               996186    230   995956    1% /tmp
/dev/sda1                           128016    320   127696    1% /boot
/dev/mapper/fedora_greeneggs-home 26722304 908502 25813802    4% /home
7
  • tune2fs will only work if OP is running a ext* filesystem. I believe some distros are starting to experimentally ship with btrfs roots by default nowadays. Commented Dec 31, 2013 at 2:58
  • @strugee - thanks for clarifying that. I hadn't heard of this. Know which distros this might be? BTW, he's on a VPS on Amazon so I highly doubt this will be an issue there. Commented Dec 31, 2013 at 3:02
  • true. I thought it was Red Hat, but that didn't seem right so I Googled. looks like I was remembering wrong; I must have been thinking of the option for btrfs being included, not being set as the default. Commented Dec 31, 2013 at 3:06
  • @strugee - that makes more sense, I could see it being offered as an option, but making it a default, seems like a few years off, until btrfs has aged a bit more. Commented Dec 31, 2013 at 3:07
  • yeah, I was a bit skeptical writing that comment... Commented Dec 31, 2013 at 3:10

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.