Skip to content

How To Add Or Change GitLab Data Storage Path

Avatar photo

https://www.linkedin.com/in/gineesh/ https://twitter.com/GiniGangadharan

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 in all published articles on this website are solely those of the respective authors, and they do not necessarily reflect the views of the author’s employer or the techbeatly platform. We strive to ensure the accuracy and validity of the content published on our website. However, we cannot guarantee the absolute correctness or completeness of the information provided. It is the responsibility of the readers and users of this website to verify the accuracy and appropriateness of any information or opinions expressed within the articles. If you come across any content that you believe to be incorrect or invalid, please contact us immediately so that we can address the issue promptly.

Avatar photo


https://www.linkedin.com/in/gineesh/ https://twitter.com/GiniGangadharan
Gineesh Madapparambath is the founder of techbeatly and he is the co-author of The Kubernetes Bible, Second Edition. and the author of 𝗔𝗻𝘀𝗶𝗯𝗹𝗲 𝗳𝗼𝗿 𝗥𝗲𝗮𝗹-𝗟𝗶𝗳𝗲 𝗔𝘂𝘁𝗼𝗺𝗮𝘁𝗶𝗼𝗻. 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 - iamgini.com)

Comments

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.