summaryrefslogtreecommitdiffstats
path: root/roles/mount/README.md
blob: c82c777ae2e12bba3dfc349e06ca326464e4e2a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Mount Role

Mounts a drive on the target host.

## Overview

Prepares a storage device as a mount point (e.g. local backup destination for S3-compatible object store like Garage).

## Configuration

### Required Variables

```yaml
mount_device: "PARTLABEL=backup"  # no default — must set in host_vars
```

### Optional Variables

```yaml
mount_point: "/backup"
mount_fstype: "ext4"
mount_options: "defaults,noatime"
```

## Preparing the Drive

### 1. Install parted

```bash
sudo apt install parted
```

### 2. Partition with a named label

```bash
# check device name
lsblk

# create GPT partition table + single labeled partition
sudo parted /dev/sdX --script mklabel gpt mkpart backup ext4 0% 100%
sudo parted /dev/nvme0nX --script mklabel gpt mkpart backup ext4 0% 100%

# verify label
sudo parted /dev/sdX print
sudo parted /dev/nvme0nX print
```

### 3. Format as ext4

```bash
sudo mkfs.ext4 /dev/sdX1
sudo mkfs.ext4 /dev/nvme0nXp1

# verify
sudo blkid /dev/sdX1
sudo blkid /dev/nvme0nXp1

ls /dev/disk/by-partlabel/
```

### 4. Set host variable

In `host_vars/rpi5.local.yml`:

```yaml
mount_device: "PARTLABEL=backup"
```

`PARTLABEL` is stable across reboots regardless of device enumeration order (`/dev/sda` vs `/dev/sdb`).
`ansible.posix.mount` handles `PARTLABEL=` values natively.

## Notes

- `noatime` mount option reduces unnecessary write cycles on the drive
- Role adds a persistent fstab entry — drive auto-mounts on reboot