Cyber Deals - Get up to 65% off on CKA, CKAD, CKS, KCNA, KCSA exams and courses!

How To Add Or Change GitLab Data Storage Path

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
Gineesh Madapparambath

Gineesh Madapparambath

Gineesh Madapparambath is the founder of techbeatly. He is the co-author of The Kubernetes Bible, Second Edition and the author of Ansible for Real Life Automation. 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). (Read more: iamgini.com)


Disclaimer: Views expressed in articles are those of the respective authors and do not necessarily reflect the views of their employers or this site. While we aim for accuracy, please verify information before relying on it, and let us know if you spot an error.
Share:

Related Posts

How to Create a FREE Ansible Lab in Public Cloud (AWS, GCP, Azure)

How to Create a FREE Ansible Lab in Public Cloud (AWS, GCP, Azure)

Introduction As we all know, learning Ansible is not just a reading process and you really need to do a lot of hands-on and practice...

How to open WinRM ports in the Windows firewall

How to open WinRM ports in the Windows firewall

We need to make sure, ports 5985 and 5986 (HTTPS) are open in firewall (both OS as well as network side) for Ansible to connect to Windows machine.

How to set up and use Python virtual environments for Ansible

How to set up and use Python virtual environments for Ansible

You can have different versions of Ansible and other important Python modules in a dedicated test directory with a virtual environment.

Ansible Convert List to String

Ansible Convert List to String

I noticed many users are using different and wrong methods to convert a list data to string format. You can use existing filters and functions...