home-network/pi-storage.org

187 lines
8.5 KiB
Org Mode
Raw Normal View History

2025-04-09 08:53:53 +03:00
#+title: Raspberry Pi & Storage Setup
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="_share/media/css/computer.css" />
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="_share/media/css/org-media-sass/content-overview.css" />
#+OPTIONS: H:6
* links
- [[./toc.org][TOC - Home Computer]]
* Raspberry Pi Information
** network
| Category | Value |
|------------+--------------|
| IP address | 192.168.0.63 |
| Hostname | ronberrypi |
*** To Be Able to Ping the Raspberry Pi
#+begin_src bash
ping ronberrypi.local
#+end_src
** users
| username | password | groups | /mnt/storage |
|-----------+--------------+----------------+-------------------------|
| ronny | 2reishit2ara | sudo | |
| website | 2reishit2ara | www-data, sudo | /var/www, /home/website |
| ftpuser | 2reishit2ara | www-data, sudo | /home/ftpuser |
| librarian | 2reishit2ara | | librarian |
2025-07-29 02:46:43 +03:00
| scribe | 2reishit2ara | | /home/scribe |
2025-04-09 08:53:53 +03:00
* connect with a vnc
- [[https://www.youtube.com/watch?v=9fEnvDgxwbI][Raspberry Pi Headless Setup]]
** install
using the video you should be able to connect directly without doing anything special
** connect tiger vnc
- hostname: ronberrypi.local
- then enter the username and password
** connect realvnc
even easier
* External Hard Drive Info
2025-04-17 01:57:40 +03:00
** fstab
[[#id-fstab-file][see fstab entry for more details]]
#+INCLUDE: "pi-storage.org::*current fstab" :only-contents t
** main storage drive
2025-04-09 08:53:53 +03:00
This table keeps track of the Raspberry Pi's external storage setup.
| category | value |
|---------------+--------------------------------------|
2025-04-17 01:57:40 +03:00
| device | /dev/sdb1 |
2025-04-09 08:53:53 +03:00
| filesystem | ext4 |
| label | storage |
| mount point | /mnt/storage |
| mount options | defaults,relatime,commit=600 |
2025-04-17 01:57:40 +03:00
| UUID | 86ba0735-df14-425c-a037-1e397e89f9aa |
*** Bind-Mount Information
**** directory layout
#+begin_src
├── home
│ ├── librarian
│ └── website
├── lost+found
├── srv
│ ├── calibre-library
│ ├── ftp
│ └── n8n
└── var
└── www
#+end_src
2025-04-09 08:53:53 +03:00
2025-04-17 01:57:40 +03:00
**** layout binding details
2025-04-09 08:53:53 +03:00
2025-04-17 01:57:40 +03:00
| Mounted From /mnt/storage | Mounted To |
|---------------------------+----------------------|
| home/website | /home/website |
| home/librarian | /home/librarian |
| var/www | /var/www |
| srv/n8n | /srv/n8n |
| srv/ftp | /srv/ftp |
| srv/calibre-library | /srv/calibre-library |
2025-04-09 08:53:53 +03:00
2025-04-17 01:57:40 +03:00
* commands used
** bind target directory to mount point
2025-04-09 08:53:53 +03:00
#+begin_src sh
sudo mount --bind /mnt/storage/<target_mount> /<bind directory>
#+end_src
*** example
- *target mount:* /mnt/storage/www
- *bind directory:* /var/www
2025-04-17 01:57:40 +03:00
*** making bind mounts persistent
2025-04-09 08:53:53 +03:00
To ensure the mounts persist after a reboot, add the following lines to `/etc/fstab`:
#+begin_src sh
2025-04-17 01:57:40 +03:00
/mnt/storage/home/website /home/website none bind 0 0
/mnt/storage/home/librarian /home/librarian none bind 0 0
/mnt/storage/var/www /var/www none bind 0 0
/mnt/storage/srv/n8n /srv/n8n none bind 0 0
2025-04-09 08:53:53 +03:00
#+end_src
** Setup Commands
These commands ensure everything is correctly prepared before binding.
| Step | Command |
|----------------------------------+----------------------------------------------------------------------------------------|
| Ensure storage directories exist | `sudo mkdir -p /mnt/storage/website /mnt/storage/calibre /mnt/storage/www` |
| Move existing data (if needed) | `sudo mv /home/website/* /mnt/storage/website/` |
| Create bind directories | `sudo mkdir -p /home/website /home/calibre /var/www` |
| Bind-mount directories | `sudo mount --bind /mnt/storage/website /home/website` |
| Add to `/etc/fstab` | `echo "/mnt/storage/website /home/website none bind 0 0" \vert sudo tee -a /etc/fstab` |
| Apply changes | `sudo mount -a` |
| Verify mount status | `df -h \vert grep storage` |
2025-04-17 01:57:40 +03:00
2025-04-09 08:53:53 +03:00
** generally useful hard drive commands
| Purpose | Command |
|----------------------------------+------------------------------------|
| Find the UUID | lsblk -f |
| Check filesystem type | sudo blkid /dev/sda2 |
| Remount drive without rebooting | sudo mount -o remount /mnt/storage |
| Check if new options are applied | mount \vert grep storage |
| Verify changes | cat /etc/fstab \vert grep storage |
2025-04-17 01:57:40 +03:00
* fstab
** current fstab
:PROPERTIES:
:ID: id-fstab-file
:END:
#+begin_src conf
proc /proc proc defaults 0 0
PARTUUID=a587d185-01 /boot/firmware vfat defaults 0 2
PARTUUID=a587d185-02 / ext4 defaults,noatime 0 1
UUID=86ba0735-df14-425c-a037-1e397e89f9aa /mnt/storage ext4 defaults,relatime,commit=600 0 2
UUID=649f82e9-cfc0-4725-b260-d40f413bd0c3 /mnt/git ext4 defaults,noatime 0 2
/mnt/storage/home/website /home/website none bind 0 0
/mnt/storage/var/www /var/www none bind 0 0
/mnt/storage/srv/ftp /srv/ftp none bind 0 0
/srv/ftp /home/ftpuser/ftp none bind 0 0
/mnt/storage/home/librarian /home/librarian none bind 0 0
/mnt/storage/srv/calibre-library /srv/calibre-library none bind 0 0
/mnt/storage/srv/n8n /srv/n8n none bind 0 0
/mnt/git /srv/git none bind 0 0
#+end_src
2025-04-09 08:53:53 +03:00
** Mount Options Available
| Option | Description |
|-------------------+------------------------------------------------------------------------------|
| defaults | Uses the default options: `rw, suid, dev, exec, auto, nouser, async`. |
| rw | Mounts the filesystem as **read/write** (default). |
| ro | Mounts the filesystem as **read-only**. |
| noexec | Prevents execution of binaries on the mounted filesystem. |
| exec | Allows execution of binaries (default). |
| nosuid | Blocks `setuid`/`setgid` binaries from running. |
| nodev | Ignores device files (e.g., `/dev/null`) on this filesystem. |
| noatime | **Disables access time updates** to improve performance. |
| nodiratime | Disables directory access time updates (for performance). |
| relatime | **Updates access time only if the file is modified**, balancing performance. |
| strictatime | **Always updates access time** (not recommended for performance reasons). |
| sync | Writes changes to disk **immediately** instead of caching them. |
| async | Writes changes to disk **asynchronously** (default, better performance). |
| commit=600 | Delays disk writes for **600 seconds (10 minutes)**, reducing wear. |
| nofail | Allows booting even if the mount fails (useful for external drives). |
| errors=remount-ro | If an error occurs, remounts the filesystem as **read-only**. |
** Performance Options
| Performance Status | Mount Options |
|---------------------------------------+-------------------------------------------|
| Maximum Performance | defaults, noatime, nodiratime, commit=600 |
| Accurate File Access Times | defaults, relatime, commit=600 |
| Extra Safety in Case of Drive Failure | errors=remount-ro, nofail |