Skip to content

Commit

Permalink
storage
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Dec 26, 2024
1 parent 81326a2 commit 7ca6ab6
Show file tree
Hide file tree
Showing 11 changed files with 1,835 additions and 1,259 deletions.
16 changes: 13 additions & 3 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ export default withMermaid({
text: 'Install Scrypted', link: '/installation',
collapsed: true,
items: [
{ text: 'Mac/Windows Desktop', link: '/install/desktop-app' },
{ text: 'macOS/Windows Desktop', link: '/install/desktop-app' },
{ text: 'Proxmox VE', link: '/install/proxmox-ve' },
{ text: 'Linux - Docker', link: '/install/linux-docker' },
{ text: 'Unraid - Docker', link: '/install/unraid-docker' },
{ text: 'Mac - Terminal', link: '/install/mac-terminal' },
{ text: 'macOS - Terminal', link: '/install/mac-terminal' },
{ text: 'Windows - PowerShell', link: '/install/windows-powershell' },
{ text: 'All Installation Options', link: '/installation#all-installation-options' },
]
Expand Down Expand Up @@ -81,7 +81,17 @@ export default withMermaid({
{ text: 'What is Scrypted NVR?', link: '/scrypted-nvr/' },
{ text: 'Features', link: '/scrypted-nvr/features' },
{ text: 'Install Scrypted NVR', link: '/scrypted-nvr/installation' },
{ text: 'Storage Setup', link: '/scrypted-nvr/recording-storage' },
{
text: 'Storage Setup',
link: '/scrypted-nvr/recording-storage',
collapsed: true,
items: [
{ text: 'Proxmox VE', link: '/scrypted-nvr/storage/proxmox' },
{ text: 'Windows', link: '/scrypted-nvr/storage/windows' },
{ text: 'macOS', link: '/scrypted-nvr/storage/mac' },
{ text: 'Docker', link: '/scrypted-nvr/storage/docker' },
]
},
{ text: 'Record Cameras', link: '/scrypted-nvr/camera-recording' },
{ text: 'Apps and Remote Access', link: '/scrypted-nvr/apps' },
{ text: 'Onboard Camera AI', link: '/scrypted-nvr/camera-ai' },
Expand Down
2,557 changes: 1,563 additions & 994 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"docs:preview": "vitepress preview"
},
"devDependencies": {
"mermaid": "^10.9.1",
"vitepress": "^1.3.1",
"vitepress-plugin-mermaid": "^2.0.16"
"mermaid": "^11.4.1",
"vitepress": "^1.5.0",
"vitepress-plugin-mermaid": "^2.0.17"
},
"dependencies": {
"medium-zoom": "^1.1.0"
Expand Down
Binary file added public/img/scrypted-nvr/storage/mac.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/scrypted-nvr/storage/windows.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
269 changes: 10 additions & 259 deletions scrypted-nvr/recording-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

Scrypted NVR requires a disk that can store at least 3 days of video for the cameras in the system. The storage requirement will vary based on the camera count and camera resolution. The following table provides a rough estimate for one week retention with a given number of cameras.

| Resolution | 4 Cameras | 6 Cameras | 10 Cameras | 16 Cameras |
|------------|-----------|-----------|------------|------------|
| 1080P | 1TB | 1TB | 1.5TB | 2.4TB |
| 2K | 1.2TB | 1.8TB | 3TB | 4.8TB |
| 4K | 2.4TB | 3.6TB | 6TB | 9.6TB |

::: warning
All storage disks must be 1TB minimum in size.
:::
Expand All @@ -20,264 +14,21 @@ When the storage device is a NAS Share, ensure that the NAS `Recycle Bin` featur
Scrypted NVR will not work with filesystem quota features. Use a separate filesystem partition to restrict how much space is available.
:::

| Resolution | 4 Cameras | 6 Cameras | 10 Cameras | 16 Cameras |
|------------|-----------|-----------|------------|------------|
| 1080P | 1TB | 1TB | 1.5TB | 2.4TB |
| 2K | 1.2TB | 1.8TB | 3TB | 4.8TB |
| 4K | 2.4TB | 3.6TB | 6TB | 9.6TB |

## Disk Setup

Use an appropriate filesystem for your OS. The storage disk **must not be MS-DOS/FAT** formatted. For best performance, provide an entire disk or partition to Scrypted NVR. Volumes that share disk space other is not recommended as it may cause issues with recording retention periods.

|OS|Filesystem|
|-|-|
|macOS|HFS or APFS|
|Windows|NTFS|
|Linux|ext4|

::: warning
When the storage device is a NAS Share, ensure that the NAS `Recycle Bin` feature is disabled, or the old recordings can not be properly deleted by Scrypted NVR and the disk will fill up.
:::

::: warning
Scrypted NVR will not work with filesystem quota features. Use a separate filesystem partition to restrict how much space is available.
:::

## OS Setup
## Storage Setup

To configure storage, select the server installation platform below:

* [Proxmox](#proxmox-ve-volume)
* [Windows](#windows-storage)
* [Mac](#mac-storage)
* [Docker](#docker-volume)

## Mac Storage

1. The storage disk must be formatted as `HFS` or `AFPS`.
2. The recordings storage directory can be configured within the `Scrypted NVR Plugin` Settings. [Multiple Storage Devices](#multiple-storage-devices) can also be added.
3. Continue on to [Enable Camera Recording](/scrypted-nvr/camera-recording).

## Windows Storage

1. The storage disk must be formatted as `NTFS`.
2. The recordings storage directory can be configured within the `Scrypted NVR Plugin` Settings. [Multiple Storage Devices](#multiple-storage-devices) can also be added.

## Proxmox VE Volume

Proxmox VE can add a storage device to Scrypted through the Proxmox VE web interface. There are a few steps: adding the storage to Proxmox VE and passing the storage through to Scrypted.

::: tip
The Recordings Directory should **not** be manually configured in the NVR plugin when using the process described below. Clear any manual Recordings Directory configuration inside the NVR plugin prior to usage of this script.
:::

::: warning
If adding multiple storage devices beyond the first, see the [Proxmox VE Disk Setup Notes](#proxmox-ve-disk-setup-notes) for additional notes on the script.
:::

### Add Storage to Proxmox

1. Open the Proxmox VE web interface.
2. Select the server (aka `node`) from the `Datacenter` drawer on the left.
3. Select the `Disks` section in the secondary drawer.
4. Find the Device in the list. The disk's Device will typically be something like `/dev/sda` or `/dev/sdb`.
5. Click `Wipe Disk`.
6. Select the `Directory` section in the secondary drawer.
7. Click `Create: Directory`.
* For `Filesystem` select `ext4`.
* Name the new storage something recognizable like `nvr-storage` (remember this for later).


### Add Storage to Scrypted

1. Select the server (aka `node`) from the `Datacenter` drawer on the left.
2. Select the `Shell` section in the secondary drawer.
3. Enter the following to download the storage setup script:

```sh
cd /tmp
curl -s https://raw.githubusercontent.com/koush/scrypted/main/install/proxmox/setup-scrypted-nvr-volume.sh > setup-scrypted-nvr-volume.sh
```

Adjust the the previously named `nvr-storage` if necessary, and run the script:

```sh
bash setup-scrypted-nvr-volume.sh nvr-storage
```

This command will stop Scrypted, add the storage, and start the Scrypted.

Continue on to [Enable Camera Recording](/scrypted-nvr/camera-recording).

<br/>
<br/>
<br/>

::: info
Reference: [Proxmox VE Disk Setup Notes](#proxmox-ve-disk-setup-notes) has information about the script.

Reference: [Proxmove VE Mount Point](#proxmox-ve-mount-point) has information about using standard Proxmox Mount points, which are not recommended due to issues with backup and snapshots.
:::

---

#### Proxmox VE Mount Point

For example, as seen in the screenshot below, inside the container `Resources`:

1. Click `Add` and select `Mount Point`.
2. Set the size to 1000GB (adjust accordingly).
3. Set the mount to `/mnt/crucial` (the name can be any preference in place of "crucial").
4. The `/mnt/crucial` path can then be provided to the NVR Plugin after restarting the container.

::: warning
The Proxmox VE Mount Points **MUST** set the path to be inside `/mnt` in the container.
:::

![](/img/scrypted-nvr/proxmox-mount-point.png)

#### Proxmox VE Disk Setup Notes

The disk setup adds the disk as a directory on the host system. The setup script modifies the lxc conf file (`/etc/pve/lxc/10443.conf`) to mount the directory into the container. It also creates a hidden `.nvr` file to the storage folder to earmark it for NVR usage. This method allows for fast snapshots, replications, and backups.

Environment variables can be set to change the setup script behavior:

::: warning
Read more about [Multiple Storage Devices](#multiple-storage-devices) before running these advanced commands.
:::

Additional disks can be added by setting the `ADD_DISK=true` environment variable:

```sh
ADD_DISK=true bash setup-scrypted-nvr-volume.sh another-nvr-storage
```

A `Fast Disk` can be added by setting the `FAST_DISK=true` environment variable:

```sh
FAST_DISK=true bash setup-scrypted-nvr-volume.sh fast-nvr-storage
```

## Docker Volume

Use the [Quick Setup](#quick-setup) script to format a disk or use an existing directory in Scrypted NVR. [Manual Docker Setup](#manual-docker-setup) steps are also available.

### Quick Setup

Run the following to download the [script](https://github.com/koush/scrypted/blob/main/install/docker/setup-scrypted-nvr-volume.sh):

```sh
mkdir -p ~/.scrypted
curl -s https://raw.githubusercontent.com/koush/scrypted/main/install/docker/setup-scrypted-nvr-volume.sh > ~/.scrypted/setup-scrypted-nvr-volume.sh
```

If a recording directory is already formatted and mounted, follow the steps at [Existing Storage Directory](#existing-storage-directory). Otherwise continue on to formatting a [New Disk](#new-disk).

#### Existing Storage Directory

```sh
sudo SERVICE_USER=$USER bash ~/.scrypted/setup-scrypted-nvr-volume.sh /path/to/existing/directory
```

The docker container will be updated and restarted with the new Recordings Directory.

#### New Disk

Run the following to list available disks:

```sh
lsblk
```

The output will be similar to below:

```
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 63.4M 1 loop /snap/core20/1974
loop1 7:1 0 63.9M 1 loop /snap/core20/2105
loop2 7:2 0 111.9M 1 loop /snap/lxd/24322
loop3 7:3 0 53.3M 1 loop /snap/snapd/19457
loop4 7:4 0 40.4M 1 loop /snap/snapd/20671
sda 8:0 0 128G 0 disk
├─sda1 8:1 0 1M 0 part
└─sda2 8:2 0 128G 0 part /
sdx 8:16 0 4096G 0 disk
sr0 11:0 1 1024M 0 rom
```

In the example above the 4TB storage disk is listed as `sdx`. To format and use `sdx`, run:

```sh
sudo SERVICE_USER=$USER bash ~/.scrypted/setup-scrypted-nvr-volume.sh sdx
```

The docker container will be updated and restarted with the new disk.

Continue on to [Enable Camera Recording](/scrypted-nvr/camera-recording).

### Manual Docker Setup

1. The storage disk must be formatted as `ext4` or `xfs`.
1. Edit `~/.scrypted/docker-compose.yaml`.
2. Make the highlighted changes in the yaml block below, adjust the storage directory as appropriate.
3. Restart the container by running the following:

```sh
cd ~/.scrypted && docker compose down && docker compose up -d
```

#### docker-compose.yaml

```yaml{13,36}
services:
scrypted:
environment:
# Scrypted NVR Storage (Part 2 of 3)
# Uncomment this line to configure the NVR plugin to store
# recordings within the /nvr directory inside the container.
# DO NOT MODIFY /nvr.
# The Recordings Directory in the NVR Plugin will autopopulate
# with /nvr (unless it was manually changed earlier).
# The disk or network share will ALSO need to be configured in
# Part 3.
- SCRYPTED_NVR_VOLUME=/nvr
- SCRYPTED_WEBHOOK_UPDATE_AUTHORIZATION=Bearer SET_THIS_TO_SOME_RANDOM_TEXT
- SCRYPTED_WEBHOOK_UPDATE=http://localhost:10444/v1/update
# Uncomment next 3 lines for Nvidia GPU support.
# - NVIDIA_VISIBLE_DEVICES=all
# - NVIDIA_DRIVER_CAPABILITIES=all
# Uncomment next line to run avahi-daemon inside the container
# Don't use if dbus and avahi run on the host and are bind-mounted
# (see below under "volumes")
# - SCRYPTED_DOCKER_AVAHI=true
# runtime: nvidia
volumes:
# Scrypted NVR Storage (Part 3 of 3)
# Modify to add the add a Recordings Directory for Scrypted NVR.
# The following example would mount the /mnt/media/video path on
# the host to the /nvr path inside the docker container.
# Modify /mnt/media/video according to the server path.
# DO NOT MODIFY /nvr.
- /mnt/media/video:/nvr
# Or use a network mount from one of the CIFS/NFS examples at the top of this file.
# - type: volume
# source: nvr
# target: /nvr
# volume:
# nocopy: true
# uncomment the following lines to expose Avahi, an mDNS advertiser.
# make sure Avahi is running on the host machine, otherwise this will not work.
# not compatible with Avahi enabled via SCRYPTED_DOCKER_AVAHI=true
# - /var/run/dbus:/var/run/dbus
# - /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket
# Default volume for the Scrypted database. Typically should not be changed.
- ~/.scrypted/volume:/server/volume
```
* [Proxmox VE](/scrypted-nvr/storage/proxmox.md)
* [Windows](/scrypted-nvr/storage/windows.md)
* [Mac](/scrypted-nvr/storage/mac.md)
* [Docker](/scrypted-nvr/storage/docker.md)

## Multiple Storage Devices

Expand Down
Loading

0 comments on commit 7ca6ab6

Please sign in to comment.