title: How to use Linux hugetlbfs for shared memory maps of files?
body: <p>I have a program which uses <code>mmap()</code> and shared memory to efficiently access a large database file. I would like to experiment with huge pages to see if it speeds things up.</p>
  <p>I thought that a quick and easy way would be to copy the database file into Linux's <em>hugetlbfs</em> directory and make a <em>symlink</em> to it in the old location.</p>
  <p>However, this does not work because the <code>cp</code> command cannot write to the file. I suspect that files can only be created by calling the <code>ftrunc()</code> and <code>mmap()</code> system calls to write into it. I will probably try writing a copy tool that does this, unless I get an answer describing an existing tool.</p>
  <p>I'm looking for any other good methods to do shared memory maps using huge pages in Linux.</p>