Note: At the beginning, it was not considered to divide the storage directory of GitLab and occupy the system disk. Since GitLab is installed by default, the space of the data directory of GitLab is insufficient with the increasing number of company codes. Gitlab is stored in /var/opt/gitlab/git-data/repositories by default.

Disk space:

[root@bogon soft]# df -hTFilesystem Type Size Used Avail Use% Mounted on /dev/mapper/volgroup-lv_root ext4 50G 47G 492M 99% / TMPFS TMPFS 2.9g 784K 2.9GB 1% /dev/shm /dev/sda1 ext4 477M 41M 411M 9% /boot /dev/mapper/volgroup-lv_home ext4 144G 1.3g 135G 1% /homeCopy the code

As you can see, /home is a large disk and will be migrated to /home later

Set up the warehouse data

By default, omnibus-gitlab stores the repository data in the /var/opt/gitlab/git-data directory, which is located in a subdirectory repositories. So you can customize the parent directory of git-data by modifying the line /etc/gitlab/gitlab.rb

[root@gitlab ~]# mkdir /home/data.gitlab/gitlab/git-data // create directory
[root@gitlab ~]# vim /etc/gitlab/gitlab.rb // change the default path
Uncomment and specify a new repository location
git_data_dirs({ "default"= > {"path"= >"/home/data/gitlab/git-data"}})Copy the code

/home/data/gitlab/git-data /gitlab/git-data

Put Settings into effect

1. In the absence of data

[root@gitlab ~]# gitlab-ctl stop // Use sudo gitlab-ctl stop
[root@gitlab ~]# gitlab-ctl reconfigure # gitlab-ctl reconfigure
Copy the code

2. In the case of data

If the /var/opt/gitlab/git-data directory already contains git repository data, you can use the following command to migrate the data to the new location:

Stop the GitLab service before preparing for the migration to prevent users from writing data.
[root@gitlab ~]# gitlab-ctl stop
 
# Notice 'repositories' without slash, and
# '/home/gitlab-data' is followed by a slash.
[root@gitlab ~]# rsync -av /var/opt/gitlab/git-data/repositories /home/data/gitlab/git-data
 
# If you need to fix permissions,
You can run the following command to fix it.
[root@gitlab ~]# gitlab-ctl reconfigure
 
Check the /home/gitlab-data directory again. Normally there should be the following subdirectory:
# repositories
[root@gitlab git-data]# ls /home/data/gitlab/git-data
repositories


Put the newly migrated package @hashed under Repositories
[root@gitlab git-data]#mv @hashed repositories 
 
# completed! Start GitLab, see if it works
Git repository via the Web.
[root@gitlab ~]# gitlab-ctl start
Copy the code

Set up an alternate directory for storing warehouse data

Note that starting with GitLab 8.10, you can add multiple Git data storage directories by adding the following configuration lines to the /etc/gitlab/gitlab.rb file.

git_data_dirs({
  "default"= > {"path"= >"/var/opt/gitlab/git-data"}, // Default storage directory"alternative"= > {"path"= >" /home/gitlab-data"} // Standby storage directory})Copy the code