Skip to content

Instantly share code, notes, and snippets.

@adriancb
Last active October 26, 2018 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save adriancb/394075c21f0e5a5ff624 to your computer and use it in GitHub Desktop.
Save adriancb/394075c21f0e5a5ff624 to your computer and use it in GitHub Desktop.
Create separate partition for Postgres
# create a separate partition and initialize with ext4
sudo mkfs.ext4 /dev/xvdb
# turn off journaling
sudo tune2fs -o journal_data_writeback /dev/xvdb
sudo tune2fs -O ^has_journal /dev/xvdb
# add to fstab
echo '/dev/xvdb /mnt/databases ext4 defaults,auto,noatime,nodiratime,noexec 0 0' | sudo tee -a /etc/fstab
# create the db mount point
sudo mkdir /mnt/databases
# mount the db with settings from fstab
sudo mount /mnt/databases
# move your existing postgres onto the new mount (as of the time of this gist we're using 9.3)
sudo mkdir -p /mnt/databases/postgresql/9.3
sudo chown -R postgres:postgres /mnt/databases/postgresql
sudo service postgresql stop
sudo mv /var/lib/postgresql/9.3/main /mnt/databases/postgresql/9.3
# tweak postgres settings
# change fsync = on -> fsync = off
# change full_page_writes = on -> full_page_writes = off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment