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.

  "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 Madapparambath is the founder of techbeatly and he is the author of the book - ๐—”๐—ป๐˜€๐—ถ๐—ฏ๐—น๐—ฒ ๐—ณ๐—ผ๐—ฟ ๐—ฅ๐—ฒ๐—ฎ๐—น-๐—Ÿ๐—ถ๐—ณ๐—ฒ ๐—”๐˜‚๐˜๐—ผ๐—บ๐—ฎ๐˜๐—ถ๐—ผ๐—ป. He 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 -


Leave a Reply

Your email address will not be published. Required fields are marked *

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