linux - Moving /tmp to a different mounted drive
2014-07
I've mapped my MySQL datadir to a different (and bigger) disk with 900GB
[root@web ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 40G 24G 14G 64% /
tmpfs 7.4G 0 7.4G 0% /dev/shm
/dev/xvdb1 886G 658G 184G 79% /mnt/cbsvolume1
The /tmp is located in the smaller 40GB disk
[root@web ~]# df -h /tmp
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 40G 24G 14G 64% /
It appears MySQL is using the /tmp directory and because of that I'm running sometimes out of disk space when trying to perform big MySQL operations.
How can I change the /tmp
to also use the bigger disk?
As far as I know, the contents of /tmp
are deleted on reboot.
However, in your case, you could try changing/adding TMPDIR
environment variable in:
/etc/mysql/conf.d/local.cnf
Change the TMPDIR environmental variable to a filesystem/directory with more disk space.
Edit the local configuration file /etc/mysql/conf.d/local.cnf
. This file contains your local changes - and will not be overwritten if you upgrade mysql. Note the config files may be stored in a different location - use find to locate the default config file my.cnf. Usually local.cnf would be kept in the same directory.
sudo find / -name my.cnf # look for path of config files
Edit local.cnf e.g. sudo vi /etc/mysql/conf.d/local.cnf
Add these lines to local.cnf:
[mysqld]
tmpdir = /your/newpath
Then re-start mysql.
From the MySQL documentation:
B.5.4.4 Where MySQL Stores Temporary Files
On Unix, MySQL uses the value of the TMPDIR environment variable as the path name of the directory in which to store temporary files. If TMPDIR is not set, MySQL uses the system default, which is usually /tmp, /var/tmp, or /usr/tmp.
I just installed a Sata WD 500GB hard drive, shows up in BIOS as secondary master drive, but do not see it after boot. What gives?
tone@homeserver:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda1 9.2G 3.3G 5.5G 38% /
tmpfs 881M 0 881M 0% /lib/init/rw
udev 10M 740K 9.3M 8% /dev
tmpfs 881M 0 881M 0% /dev/shm
/dev/hda2 65G 197M 61G 1% /srv
df -h just shows the current mount points and stats.
use fdisk
-l to make sure the machine is seeing the drive.
Next partition the drive:
cfdisk /dev/hdc
cfdisk will load, then create your partition:
- New >> Primary >> Size in MB
- Once done select Write
- Select Quit
Next format the disk
mkfs.ext3 /dev/hdc1
and lastly mount the drive:
mkdir /new-disk
mount -t ext3 /dev/hdc1 /new-disk
To check to make sure the drive is mounted:
ls -lsa /new-disk
df
lists all the current mount points and stats. As root or using sudo and running fdisk -l
will list all the block devices and partitions that it finds. From there you'll need to partition and format your new drive and then determine where you want to mount those partitions.
I think df only shows mounted filesystems. Check to see if a /dev/sda is present. If so try mounting it. You could also run parted and then run a print command to see if the drive shows up there as well.
ls /dev | grep hd
you will see there for example hda hda1 hda2 hda3 hdb hdb1 hdb2
hda and hdb - are hard drives. you need to make partitions using fdisk hdb (for example) and then mount it manualy or define it in /etc/fstab