Can't create/write to file '/tmp/#sql_b9c_0.MYI' (Errcode: 30)

10 posts / 0 new
Last post
#1 Sat, 12/04/2010 - 19:23
08a4210
08a4210's picture

Can't create/write to file '/tmp/#sql_b9c_0.MYI' (Errcode: 30)

when I try to create database this is what I get.

Failed to create database : SQL desc db failed : Can't create/write to file '/tmp/#sql_b9c_0.MYI' (Errcode: 30)

Sat, 12/04/2010 - 19:39
andreychek

Well, looking up that error code on Google -- MySQL generates an "Errcode 30" if it's unable to write to /tmp.

Is anything odd going on with your /tmp directory? I recall you had some special permissions setup on there... your setup may be coming back to bite you here :-)

You first may want to run an "ls -ld /tmp", and make sure the permissions look correct.

Then, take a look at the "mount" command again. Is there anything in that output that suggests it's mounted read-only?

-Eric

Sun, 12/05/2010 - 06:41 (Reply to #2)
08a4210
08a4210's picture

Hi Eric thanks

this is what I get

drwxrwxrwt 5 root root 4096 12ì›” 4 22:07

Sorry I am newbie in linux that is wrong with the above and how can I correct that?

and this is mount

/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw,grpquota,usrquo proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) /dev/xvda1 on /boot type ext3 (rw) tmpfs on /dev/shm type tmpfs (rw) /var/tempFS on /tmp type ext3 (rw,noexec,nosuid,loop=/dev/loop0) none on /dev/shm type tmpfs (rw,noexec,nosuid) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

can you please tell me how to correct this ? need just the command I can run in ssh to get this solved Thanks a lot Eric

Sun, 12/05/2010 - 06:57
Locutus

Can you please put texts you paste from shell outputs in   tags? They are much better readable then, and I also think your ls output became somewhat garbled.

Sun, 12/05/2010 - 07:23
08a4210
08a4210's picture

Yes sure

/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw,grpquota,usrquo proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) /dev/xvda1 on /boot type ext3 (rw) tmpfs on /dev/shm type tmpfs (rw) /var/tempFS on /tmp type ext3 (rw,noexec,nosuid,loop=/dev/loop0) none on /dev/shm type tmpfs (rw,noexec,nosuid) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

Sun, 12/05/2010 - 08:59
Locutus

There still are no linebreaks in your output. Please make sure those stay intact. Otherwise it's very hard to tell where new lines start.

Also, as I said, the output from the ls command you posted seems to have been corrupted. You should post it again, in   tags.

Mon, 12/06/2010 - 13:20
andreychek

I have a hunch that the problems you're seeing are due to the "noexec" mount flag in /tmp.

My recommendation would be to (at least temporarily) remove the noexec mount flag, and to try that all again. I suspect it'll all begin working at that point :-)

If you really want to use "noexec" on /tmp, you may need to configure some services to use an alternate temp dir without that restriction.

-Eric

Mon, 12/06/2010 - 19:16
08a4210
08a4210's picture

Hi Eric let me explain : It all started when I tried to secure my server doing this manual somebody gave me. I do not know about linux so what in the following instruction got wrong? and can you please give me a simple command to resolve it Thanks in advance

==================

Secure /tmp
 
This will cover securing /tmp /var/tmp and /dev/shm
Secure /tmp:
 
Step 1: Backup your /etc/fstab file
cp /etc/fstab /etc/fstab.bak
Step 2: Make a 3GB file for /tmp parition and an ext3 filesystem for tmp:
dd if=/dev/zero of=/var/tempFS bs=1024 count=3072000
/sbin/mkfs.ext3 /var/tempFS
*Change the count= to something higher if you need more space*
Step 3: Create a backup copy of your current /tmp drive:
cp -Rpf /tmp /tmpbackup
Step 4: Mount our new tmp parition and change permissions:
mount -o loop,noexec,nosuid,rw /var/tempFS /tmp
chmod 1777 /tmp
Step 5: Copy the old data:
cp -Rpf /tmpbackup/* /tmp/
* If your /tmp was empty earlier, you might get this error :
 
 cp: cannot stat `/tmp.bak/*’: No such file or directory
 
 
Step 6: Edit /etc/fstab and add this:
 
nano -w /etc/fstab
And ADD this line:
/var/tempFS /tmp ext3 loop,nosuid,noexec,rw 0 0
Step 7: Test your fstab entry:
mount -o remount /tmp
Step 8: Verify that your /tmp mount is working:
 
df -h
Should look something like this:
/var/tempFS           962M   18M  896M   2% /tmp
 
Secure /var/tmp:
 
Step 1: Use /tmp as /var/tmp. 
mv /var/tmp /var/vartmp
ln -s /tmp /var/tmp
Step 2: Copy the old data back
cp /var/vartmp/* /tmp/
* If your /var/tmp was empty 
earlier, you might get this error 
: cp: cannot stat `/var/vartmp/*’: No such file or directory
Secure /dev/shm:
 
Step 1: Edit your /etc/fstab:
nano -w /etc/fstab
Locate:
none /dev/shm tmpfs defaults,rw 0 0
Change it to:
none /dev/shm tmpfs defaults,nosuid,noexec,rw 0 0
Step 2: Remount /dev/shm:
mount -o remount /dev/shm
Mon, 12/06/2010 - 19:43
andreychek

While those instructions aren't necessarily "incorrect", they don't seem to take your situation into account :-)

I'd caution against setting up non-standard things on your server if you don't understand what they're doing; if your Linux distribution doesn't do it for you by default, it may be because doing so tends to break things :-)

You can try one of two things to resolve the problems you're having.

One, you could simply revert to your previous /etc/fstab file (you did keep a backup, right? :-). If you have your previous fstab, if you revert to it, then reboot, you partitions should go back to the previous mount options they had.

Option two would be to just remove the "noexec" flag from /tmp. To do that, edit your /etc/fstab file, go to the /tmp line, and remove the "noexec" option listed in the options section.

Then, run this command:

mount -o remount,loop,nosuid,rw /var/tempFS /tmp

Tue, 12/07/2010 - 05:15
Locutus

This here quite reminds me of the movie "Contact". Build a gadget based on blueprints received in a transmission from a alleged alien race, not having the slightest idea what it actually becomes. It might be a transportation device, or it might be a doomsday device, blowing the world to smithereens. :-)

So I quite agree with Eric here: Never fiddle with stuff on your system that you have no idea what it does or what its side-effects might be! Especially following "manuals somebody gave you". Except you make a backup of your system first and are ready to retrace your steps or restore the backup afterwards.

Otherwise you might end up executing commands that break stuff really thoroughly (which is - trust me on that - very easy to do with root access under Linux) and are not remedied by a simple mount -o remount.

Topic locked