# copy the files in /var/db/mysql to a separate zfs filesystem ?



## wonslung (Jun 12, 2009)

I recently discovered that in order to tune mysql to run properly on zfs i should set the recordsize to match the block size in mysql.

My question is, can i safely stop the database server, copy the data out of /var/db/mysql to another location, then do 

```
zfs create tank/var/db/mysql
zfs set recordsize 8k tank/var/db/mysql
zfs set compression=on tank/var/db/mysql
zfs create tank/var/db/mysql/DATABASE1
zfs create tank/var/db/mysql/DATABASE2
zfs create tank/var/db/mysql/DATABASE3
```
then copy the data back in?

i'm guessing as long as the permissions are set correctly this will work, right?
(of course i'd use the actual database names instead of database1, database2)


----------



## phoenix (Jun 12, 2009)

You forgot the *-o mountpoint=/var/db/mysql* in the first zfs create command.  Alternatively, you can set it after creating the filesystem:
`# zfs set mountpoint=/var/db/mysql tank/var/db/mysql`

Otherwise, it will be mounted onto /tank/var/db/mysql and MySQL won't use it.

Other than that, in theory, that's all that should be needed.


----------



## graudeejs (Jun 12, 2009)

other method is to create snapshot, clone it, and then promote it.
check zfs manpage]

this might depend on disk setup (perhaps it's not possible to so so easy in your setup, but i doubt it)

there's also zfs rename


----------

