Skip to content

How To Add Or Change GitLab Data Storage Path


I have explained How to Install GitLab in a Disconnected Environment in a past article. In this article you will learn how to configure custom storage path for your GitLab servers.

By default GitLab will use some locations (eg: /var/opt/gitlab/git-data etc) to store the repositories and other data. But when you have more and more repositories and users are doing a lot of transactions, the default size will not be enough to hold your data. The recommended practice is to add or change the storage path of GitHub data as explained below.

Create dedicated volume for GitLab Data

For this demo, I will use a separate disk volume (eg: /dev/sdb1) and LVM on top of that. You can use any mount location or NAS/SAN storage as well.

# create PV
$ pvcreate /dev/sdb1

# create vg
$ vgcreate gitvg /dev/sdb1

# create lv
$ lvcreate -n gitlab -l 100%FREE gitvg

Create a directory to mount the volume

$ sudo mkdir /gitlab

Add entry to /etc/fstab for permanent mount.

/dev/mapper/gitvg-gitlab   /gitlab      xfs     defaults        0 0

Mount the volume

$ sudo mount /gitlab

# or 

$ sudo mount -a

Configure /etc/gitlab/gitlab.rb

Now we need to add the storage details in the GitLab configuration; find the git_data_dirs block and amend as needed.

git_data_dirs({
  "default" => {
    "path" => "/gitlab"
   }
})

Reconfigure the GitLab and wait for re-configuration to complete.

$ sudo gitlab-ctl reconfigure

Restart GitLab to use the latest configuration

$ sudo gitlab-ctl restart

Verify configuration

$ sudo gitlab-ctl show-config

Disclaimer: The views expressed and the content shared are those of the author and do not reflect the views of the author's employer or techbeatly platform.


Gineesh has worked as a Systems Engineer, Automation Specialist, and content author. His primary focus is on Ansible Automation, Containerisation (OpenShift & Kubernetes), and Infrastructure as Code (Terraform). (aka Gini Gangadharan - iamgini.com)

Comments

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.