Compare commits
2 Commits
e3e85a68c7
...
9b0a56345d
| Author | SHA1 | Date | |
|---|---|---|---|
| 9b0a56345d | |||
| 5cd92e10c8 |
@ -52,6 +52,7 @@ Most `btrfs` subcommands accept shortened aliases. The table below lists the com
|
|||||||
| `btrfs filesystem resize` | `btrfs fi resize` |
|
| `btrfs filesystem resize` | `btrfs fi resize` |
|
||||||
| `btrfs filesystem defragment` | `btrfs fi defrag` |
|
| `btrfs filesystem defragment` | `btrfs fi defrag` |
|
||||||
| `btrfs subvolume` | `btrfs sub` |
|
| `btrfs subvolume` | `btrfs sub` |
|
||||||
|
| `btrfs subvolume create` | `btrfs sub create` |
|
||||||
| `btrfs subvolume list` | `btrfs sub list` |
|
| `btrfs subvolume list` | `btrfs sub list` |
|
||||||
| `btrfs subvolume snapshot` | `btrfs sub snap` |
|
| `btrfs subvolume snapshot` | `btrfs sub snap` |
|
||||||
| `btrfs subvolume delete` | `btrfs sub del` |
|
| `btrfs subvolume delete` | `btrfs sub del` |
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
This setup provides a redundant Debian root drive using BTRFS RAID1 across two disks, with a synced EFI partition on both so the machine can boot from either. The script `update-efi-mirror` keeps the backup EFI in sync and re-installs GRUB on both physical disks. It is triggered automatically after every `apt` operation.
|
This setup provides a redundant Debian root drive using BTRFS RAID1 across two disks, with a synced EFI partition on both so the machine can boot from either. The script `efi-update-mirror` keeps the backup EFI in sync and re-installs GRUB on both physical disks. It is triggered automatically after every `apt` operation.
|
||||||
|
|
||||||
## Placeholders
|
## Placeholders
|
||||||
|
|
||||||
@ -46,15 +46,15 @@ Replace the placeholders below with the appropriate values for your setup:
|
|||||||
|
|
||||||
- The root filesystem is BTRFS RAID1 across two partitions. Either disk alone can serve reads and writes.
|
- The root filesystem is BTRFS RAID1 across two partitions. Either disk alone can serve reads and writes.
|
||||||
- Each disk has its own EFI partition. GRUB is installed on both physical disks.
|
- Each disk has its own EFI partition. GRUB is installed on both physical disks.
|
||||||
- After every `apt` install or upgrade, an apt hook calls `update-efi-mirror`, which:
|
- After every `apt` install or upgrade, an apt hook calls `efi-update-mirror`, which:
|
||||||
1. Rsyncs the live `/boot/efi` to the backup EFI partition.
|
1. Rsyncs the live `/boot/efi` to the backup EFI partition.
|
||||||
2. Runs `grub-install` on both physical disks.
|
2. Runs `grub-install` on both physical disks.
|
||||||
- Either disk can be removed and the system will still boot and run.
|
- Either disk can be removed and the system will still boot and run.
|
||||||
|
|
||||||
## Paths
|
## Paths
|
||||||
|
|
||||||
- **Sync script**: `/usr/local/sbin/update-efi-mirror`
|
- **Sync script**: `/usr/local/sbin/efi-update-mirror`
|
||||||
- **Apt hook**: `/etc/apt/apt.conf.d/99-update-efi-mirror`
|
- **Apt hook**: `/etc/apt/apt.conf.d/99-efi-update-mirror`
|
||||||
- **fstab**: `/etc/fstab`
|
- **fstab**: `/etc/fstab`
|
||||||
|
|
||||||
## Setup Procedure
|
## Setup Procedure
|
||||||
@ -176,7 +176,7 @@ The fstab should contain:
|
|||||||
# Primary EFI — mounted at boot
|
# Primary EFI — mounted at boot
|
||||||
UUID=<primary-efi-uuid> /boot/efi vfat umask=0077 0 1
|
UUID=<primary-efi-uuid> /boot/efi vfat umask=0077 0 1
|
||||||
|
|
||||||
# Backup EFI — not auto-mounted, used by update-efi-mirror
|
# Backup EFI — not auto-mounted, used by efi-update-mirror
|
||||||
#UUID=<backup-efi-uuid> /boot/efi vfat umask=0077 0 1
|
#UUID=<backup-efi-uuid> /boot/efi vfat umask=0077 0 1
|
||||||
|
|
||||||
# Root — BTRFS RAID1 (both partitions share the same UUID)
|
# Root — BTRFS RAID1 (both partitions share the same UUID)
|
||||||
@ -204,16 +204,16 @@ systemctl daemon-reload
|
|||||||
**Create the script**
|
**Create the script**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
nano /usr/local/sbin/update-efi-mirror
|
nano /usr/local/sbin/efi-update-mirror
|
||||||
```
|
```
|
||||||
|
|
||||||
Paste the contents of `update-efi-mirror.sh`.
|
Paste the contents of `efi-update-mirror.sh`.
|
||||||
|
|
||||||
**Set ownership and permissions**
|
**Set ownership and permissions**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
chown root:root /usr/local/sbin/update-efi-mirror
|
chown root:root /usr/local/sbin/efi-update-mirror
|
||||||
chmod 755 /usr/local/sbin/update-efi-mirror
|
chmod 755 /usr/local/sbin/efi-update-mirror
|
||||||
```
|
```
|
||||||
|
|
||||||
The script will:
|
The script will:
|
||||||
@ -228,13 +228,13 @@ The script will:
|
|||||||
**Create the apt hook**
|
**Create the apt hook**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
nano /etc/apt/apt.conf.d/99-update-efi-mirror
|
nano /etc/apt/apt.conf.d/99-efi-update-mirror
|
||||||
```
|
```
|
||||||
|
|
||||||
Add:
|
Add:
|
||||||
|
|
||||||
```
|
```
|
||||||
DPkg::Post-Invoke {"if [ -x /usr/local/sbin/update-efi-mirror ]; then /usr/local/sbin/update-efi-mirror; fi";};
|
DPkg::Post-Invoke {"if [ -x /usr/local/sbin/efi-update-mirror ]; then /usr/local/sbin/efi-update-mirror; fi";};
|
||||||
```
|
```
|
||||||
|
|
||||||
This runs the sync script after every `apt` operation that invokes `dpkg` — including kernel upgrades, which update `/boot/efi` with new initramfs and GRUB config.
|
This runs the sync script after every `apt` operation that invokes `dpkg` — including kernel upgrades, which update `/boot/efi` with new initramfs and GRUB config.
|
||||||
@ -244,7 +244,7 @@ This runs the sync script after every `apt` operation that invokes `dpkg` — in
|
|||||||
**Run the script manually**
|
**Run the script manually**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
/usr/local/sbin/update-efi-mirror
|
/usr/local/sbin/efi-update-mirror
|
||||||
```
|
```
|
||||||
|
|
||||||
Expected output:
|
Expected output:
|
||||||
@ -328,7 +328,7 @@ systemctl daemon-reload
|
|||||||
**7. Run the sync script** to install GRUB on the new disk and populate its EFI partition:
|
**7. Run the sync script** to install GRUB on the new disk and populate its EFI partition:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
/usr/local/sbin/update-efi-mirror
|
/usr/local/sbin/efi-update-mirror
|
||||||
```
|
```
|
||||||
|
|
||||||
**8. Verify** following [Step 6](#6-test).
|
**8. Verify** following [Step 6](#6-test).
|
||||||
|
|||||||
@ -285,6 +285,12 @@ ln -s /usr/share/zoneinfo/<timezone> /etc/localtime
|
|||||||
systemctl list-units --type=service | grep <service-name>
|
systemctl list-units --type=service | grep <service-name>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Mount drive by UUID**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mount -U "UUID" /mnt/path
|
||||||
|
```
|
||||||
|
|
||||||
**Bind mount a directory**
|
**Bind mount a directory**
|
||||||
|
|
||||||
Make a directory available at another path, useful during chroot recovery or container setup:
|
Make a directory available at another path, useful during chroot recovery or container setup:
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
- [PDF](#pdf)
|
- [PDF](#pdf)
|
||||||
- [Table of Contents](#table-of-contents)
|
- [Table of Contents](#table-of-contents)
|
||||||
- [OCR](#ocr)
|
- [OCR](#ocr)
|
||||||
|
- [ocrmypdf](#ocrmypdf)
|
||||||
|
|
||||||
## OCR
|
## OCR
|
||||||
|
|
||||||
@ -102,3 +103,9 @@ Replace `convert` with `magick` for newer versions.
|
|||||||
|
|
||||||
**Verify language codes for Tesseract**:
|
**Verify language codes for Tesseract**:
|
||||||
You can find a list of supported languages on the [Tesseract GitHub page](https://github.com/tesseract-ocr/tesseract).
|
You can find a list of supported languages on the [Tesseract GitHub page](https://github.com/tesseract-ocr/tesseract).
|
||||||
|
|
||||||
|
## ocrmypdf
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ocrmypdf "input.pdf" "output.ocr.pdf" --force-ocr
|
||||||
|
```
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
|
||||||
from argparse import ArgumentParser, Namespace
|
from argparse import ArgumentParser, Namespace
|
||||||
|
|
||||||
# Allow importing from scripts/library even when run directly
|
# Allow importing from scripts/library even when run directly
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user