update from sparkleup

This commit is contained in:
Madison Scott-Clary 2022-06-26 21:50:05 -07:00
parent db61b8ba4a
commit 45d866424d
1 changed files with 80 additions and 5 deletions

View File

@ -16,7 +16,51 @@ Before you get started, you will need the following:
A volume can take many different forms. It could be an NFS volume, which is storage available on the network provided via a file share. Another possibility is that it takes the form of block storage via a service such as DigitalOcean's Volumes or Amazon's EBS. In both cases, storage is mounted on a system using the `mount` command. A volume can take many different forms. It could be an NFS volume, which is storage available on the network provided via a file share. Another possibility is that it takes the form of block storage via a service such as DigitalOcean's Volumes or Amazon's EBS. In both cases, storage is mounted on a system using the `mount` command.
These volumes will be visible as a device, files which live in `/dev`. These volumes will be visible as a device, files which live in `/dev`. These files are how the kernel communicates with the storage devices themselves, not actually used for storage. In order to be able to store files on the storage device, you will need to **mount** them using the `mount` command.
First, you will need to create a **mount point** --- that is, a folder which will be associated with the device, such that data stored within it winds up stored on that device. Mount points for storage devices such as this typically live in the `/mnt` directory.
Create a mount point named `gitea` as you would create a normal directory using the `mkdir` command:
```command
sudo mkdir /mnt/gitea
```
From here, we can mount the device to that directory in order to use it to access that storage space. Use the `mount` command to mount the device:
```command
sudo mount -o defaults,noatime /dev/disk/by-id/<^>your_disk_id<^> /mnt/gitea
```
This command mounts the device specified by its ID to `/mnt/gitea`. The `-o` option specifies the options used when mounting. In this case, you are using the default options which allow for mounting a read/write file system, and the `noatime` option specifies that the kernel shouldn't update the last access time for files and directories on the device in order to be more efficient.
Now that you've mounted your device, it will stay mounted as long as the system is up and running. However, as soon as the system restarts, it will no longer be mounted (though the data will remain on the volume), so you will need to tell the system to mount the volume as soon as it starts using the `/etc/fstab` ('file systems table') file, which lists the available file systems and their mount points in a simple tab-delimited format.
Using `echo` and `tee`, add a new line to the end of `/etc/fstab`:
```command
echo '/dev/disk/by-id/<^>your_disk_id<^> /mnt/gitea ext4 defaults,nofail,noatime 0 0' | sudo tee /etc/fstab
```
This command appends the string `/dev/disk/by-uid/<^>your_disk_id<^>` to the fstab file and to your screen. As with the `mount` command above, it mounts the device onto the mount point using the `defaults`, `nofail`, and `noatime` options. The string `ext4` between the mount point and options specifies the file system type, ext4 in this case, though depending on your volume's file system type, it may be something like xfs or nfs; to check which type your volume uses, run the `mount` command with no options:
```command
mount
```
This will provide you with a line of output for every mounted file system. Since you just mounted yours, it will likely be the last on the list, and look something like this:
```
/dev/sda on /mnt/gitea type ext4 (rw,noatime,discard)
```
which shows that the file system type is `ext4`.
Once your changes have been made to `/etc/fstab`, the kernel will mount your Linux volume on boot.
<$>[note]
**Note:** Storage devices on Linux are very flexible and come in all different types, from a networked file system (NFS) to a plain old hard drive. To learn more about block storage and devices in Linux, you can read up more about storage concepts [here](https://www.digitalocean.com/community/tutorials/an-introduction-to-storage-terminology-and-concepts-in-linux).
<$>
## Step 2 — Configuring Gitea to Store Data on a Linux Volume ## Step 2 — Configuring Gitea to Store Data on a Linux Volume
@ -43,21 +87,22 @@ drwx------ 2 root root 4096 Jun 23 22:34 ssh/
Let's break down the output of this command. It lists one file or directory per line. In this case, it lists five directories. The entry for `.` is a special entry that just means the current directory, and `..` stands for the directory one level up. You can see that the current directory is owned by the `root` user, which is the case in this instance because Docker runs as a privileged user, and the directory one level up is owned by `sammy`. Let's break down the output of this command. It lists one file or directory per line. In this case, it lists five directories. The entry for `.` is a special entry that just means the current directory, and `..` stands for the directory one level up. You can see that the current directory is owned by the `root` user, which is the case in this instance because Docker runs as a privileged user, and the directory one level up is owned by `sammy`.
The `git` directory is important to us because it contains all of the repositories that we might want to store on a separate volume. Within it are two directories of note: the `repositories` directory contains the git repositories managed by Gitea sorted by user/organization, and the `lfs` directory contains data for Git's Large File Storage functionality. The `gitea` directory contains plenty of information that Gitea uses in the background, including archives of repositories that it creates during its normal usage, as well the database that contains information such as users and repository information used by the web service. The `ssh` directory contains various SSH keypairs that are used in Gitea's operation. The `git` directory is important to us because it contains all of the repositories that we might want to store on a separate volume. Within it are two directories of note: the `repositories` directory contains the git repositories managed by Gitea sorted by user/organization, and the `lfs` directory contains data for Git's Large File Storage functionality. The `gitea` directory contains plenty of information that Gitea uses in the background, including archives of old repositories, as well the database that contains information such as users and repository information used by the web service. The `ssh` directory contains various SSH keypairs that are used in Gitea's operation.
Given that all of the information stored in this directory is important to us, we will want to include the entire directory's contents on our attached volume. Given that all of the information stored in this directory is important to us, we will want to include the entire directory's contents on our attached volume.
### Using a new installation of Gitea ### Setting Up a New Installation of Gitea
If you are starting with a brand new installation of Gitea, you can specify where all of your information is stored during the configuration process. For example, if you are setting Gitea up using Docker Compose, you can map the volumes to your attached volume. If you are starting with a brand new installation of Gitea, you can specify where all of your information is stored during the configuration process. For example, if you are setting Gitea up using Docker Compose, you can map the volumes to your attached volume.
Open up the `docker-compose.yml` file with your preferred text editor. The following example uses `nano`. Search for the `volumes` entry in the compose file and modify the mapping on the left side of the `:` to point to appropriate locations on your Linux volume for the Gitea data directory: Open up the `docker-compose.yml` file with your preferred text editor. The following example uses `nano`. Search for the `volumes` entry in the compose file and modify the mapping on the left side of the `:` to point to appropriate locations on your Linux volume for the Gitea data directory:
```yaml ```yaml
[label docker-compose.yml]
... ...
volumes: volumes:
- <^>/media/gitea<^>:/data - <^>/mnt/gitea<^>:/data
- /home/git/.ssh/:/data/git/.ssh - /home/git/.ssh/:/data/git/.ssh
- /etc/timezone:/etc/timezone:ro - /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro - /etc/localtime:/etc/localtime:ro
@ -71,10 +116,40 @@ Open up the `docker-compose.yml` file with your preferred text editor. The follo
When you run `docker-compose` and Gitea installs, it will use your Linux volume to store its data. When you run `docker-compose` and Gitea installs, it will use your Linux volume to store its data.
If you are not using Docker volumes to manage the locations of your data --- for example, if you are installing Gitea on your server via the binary releases per [these instructions from Gitea](https://docs.gitea.io/en-us/install-from-binary/) --- then you will need to modify the locations within the configuration file (usually `/etc/gitea/app.ini`) when you are setting all of the values. For instance, you might set them as follows:
```ini
[label app.ini]
...
# If you are using SQLite for your database, you will need to change the PATH
# variable in this section
[database]
...
PATH = <^>/mnt/gitea<^>/gitea.db
[server]
...
LFS_CONTENT_PATH = <^>/mnt/gitea<^>/lfs
[repository]
ROOT = <^>/mnt/gitea<^>/gitea-repositories
...
```
<$>[note] <$>[note]
**Note:** Ensure that your git user has write access to this location. You can read up on Linux permissions [here](https://www.digitalocean.com/community/tutorials/an-introduction-to-linux-permissions). **Note:** Ensure that your git user has write access to this location. You can read up on Linux permissions [here](https://www.digitalocean.com/community/tutorials/an-introduction-to-linux-permissions).
<$> <$>
### Using an existing installation of Gitea ### Moving an Existing Installation of Gitea
If you already have an instance of Gitea installed and running, you will still be able to store your data on a separate Linux volume, but it will require some care in ensuring that all of your data remains both safe and accessible to Gitea.
As with any operation involving your data, it is important to ensure that you have an up-to-date backup of everything. In this case, this means a back up of all of the files in your data directory (the SSH files, the `gitea-repositories` and `lfs` directories, the database, and so on) to a safe location.
## Step 3 — Creating Snapshots of Volumes (optional) ## Step 3 — Creating Snapshots of Volumes (optional)
## Conclusion