diff --git a/content/20240204184839 Raspi4 家サーバー 作業ログ.md b/content/20240204184839 Raspi 4 5 家サーバー 作業ログ.md similarity index 74% rename from content/20240204184839 Raspi4 家サーバー 作業ログ.md rename to content/20240204184839 Raspi 4 5 家サーバー 作業ログ.md index 821f811..556e00b 100644 --- a/content/20240204184839 Raspi4 家サーバー 作業ログ.md +++ b/content/20240204184839 Raspi 4 5 家サーバー 作業ログ.md @@ -1,14 +1,19 @@ -# 20240204184839 Raspi4 家サーバー 作業ログ +# 20240204184839 Raspi 4 5 家サーバー 作業ログ #tech #raspi #server -## 買ったもの +## 買ったもの(raspi4) - 【国内正規代理店品】Raspberry Pi4 ModelB 4GB ラズベリーパイ4 技適対応品【RS・OKdo版】 https://amazon.co.jp/dp/B081YD3VL5 - Smraza Raspberry Pi 4 USB-C (Type C)電源、5V 3A ラズベリーACアダプター RPi 4b Model B 1GB / 2GB / 4GB/ 8GB適用 https://amazon.co.jp/dp/B07DN5V3VN - Flirc ラズベリーパイ4ケース シルバー https://amazon.co.jp/dp/B07WG4DW52 - Ediloca EN760 SSD ヒートシンク付き 1TB PCIe Gen4x4 NVMe M.2 2280 PS5動作確認済み 最大読込: 5000MB/s 最大書き:4500MB/s 3D NAND TLC 内蔵SSD ダイナミック SLC キャッシュ メーカー5年保証 https://amazon.co.jp/dp/B0C9TD1FM4 - ORICO M.2 SSDケース USB-C to NVMe M-Key / B&M Key(Nvmeのみ)に対応 USB 3.1 Gen2 10Gbps 外付けケース ABS+アルミ材質 UASPサポート2230/2242/2260/2280 SSD対応 M.2 SSD 変換アダプタ エンクロージャ ケース 黑 M2PV-BK https://amazon.co.jp/dp/B08GC326LL +- +## 買ったもの(raspi5) +- [Raspberry Pi 5 / 8GB — スイッチサイエンス](https://www.switch-science.com/products/9250) +- [NVMe Base for Raspberry Pi 5 – NVMe Base](https://shop.pimoroni.com/products/nvme-base?variant=41219587178579) +- ↑で動作確認されているSSD "Drive compatibility "の中から KIOXIA EXCERIA G2 1TB https://www.amazon.co.jp/dp/B09KZG6PQV ファイルサーバーでも使っている ## セットアップ色々 - [[20240204221756 raspberry Pi Imagerを使ってSDカードを作成|raspberry Pi Imagerを使ってSDカードを作成]] @@ -22,7 +27,7 @@ wsl2上のubuntuから、sshで接続確認。(名前とパスワード。後で ここまでできたら、SSD bootの設定をする。 -- [[20240204221948 raspberry pi4をSSD bootに設定|raspberry piをSSD bootに設定]] +- [[20240204221948 raspberry pi4 5 をSSD bootに設定|raspberry piをSSD bootに設定]] - [[20240204222141 sshを公開鍵認証にする|sshを公開鍵認証にする]] - [[20240211171220 sshのポートを変更する|sshのポートを変更する]] @@ -32,9 +37,18 @@ $ sudo apt install fail2ban $ sudo vim /etc/fail2ban/jail.conf ``` + 設定 `/etc/fail2ban/jail.conf` sshdのところを設定 ``` [sshd] + +# To use more aggressive sshd modes set filter parameter "mode" in jail.local: +# normal (default), ddos, extra or aggressive (combines all). +# See "tests/files/logs/sshd" or "filter.d/sshd.conf" for usage example and details. +#mode = normal enabled = true +backend = systemd +port = ssh +logpath = %(sshd_log)s ``` ``` @@ -71,7 +85,7 @@ $ watch -n 1 vcgencmd measure_clock arm ``` でCPUの周波数が表示される。ダイナミックに変わるので一定しないが、1800MHzくらい。 - +#### Raspi4: `/boot/firmware/config.txt `の `#arm-freq=800` を2000に変更、#を外す @@ -85,18 +99,22 @@ After: $ watch -n 1 vcgencmd measure_clock arm ``` 2000MHzくらいになった。 -### Ref. + +#### Raspi5: +うまくいかなかった(起動しなかった)ので実施していない +#### Ref. - [「Raspberry Pi」をオーバークロックしてみた - ZDNET Japan](https://japan.zdnet.com/article/35201090/) - [Raspberry Pi 4+Bullseyeのオーバークロックの設定 | ラズパイダ](https://raspida.com/overclock-rpi4-bullseye) -### WEBサーバー -- [[20240212183719 Raspi4でnginxを設定する|Raspi4でnginxを設定する]] +- Raspi5の場合(この通りやったらうごかなくなった注意) [Overclocking and \*Underclocking\* the Raspberry Pi 5 | Jeff Geerling](https://www.jeffgeerling.com/blog/2023/overclocking-and-underclocking-raspberry-pi-5) + ### Raspi4 Cloudflareでトンネルを作る - [[20240211141946 Raspi4 Cloudflareでトンネルを作る|Raspi4 Cloudflareでトンネルを作る]] - [[20240211202623 Raspi4 Cloudflare tunnel経由でhttpsサーバーを公開する|Raspi4 Cloudflareでhttpsサーバーを公開する]] - [[20240211185359 Raspi4 Cloudflareでsshアクセスできるようにする|Raspi4 Cloudflareでsshアクセスできるようにする]] - +### WEBサーバー +- [[20240212183719 Raspi4でnginxを設定する|Raspi4でnginxを設定する]] ### Gitea/Forgejo -- [[20240215215031 Raspi4にGiteaをインストール|Raspi4にGiteaをインストール]] +- [[20240215215031 Raspi 4 5 にGitea Forgejoをインストール|Raspi4にGiteaをインストール]] - [[20240312115855 Raspi4 GiteaからForgejoに変更してみる|GiteaからForgejoに変更してみる]] ### Node.js @@ -110,7 +128,7 @@ $ sudo n latest ### Dropbox -- rcloneを使う方法 [[20240222192025 Raspi4でrcloneを使う|Raspi4でrcloneを使う]] こっちのほうが良い。おすすめ。 +- rcloneを使う方法 [[20240222192025 Raspi4 5でrcloneを使う|Raspi4でrcloneを使う]] こっちのほうが良い。おすすめ。 - Dropbox Uploaderを使う方法 [[20240222190405 Raspi4でDropboxを使う|Raspi4でDropboxを使う]] 遅いしsyncではなくdownloadなので、dropbox側で消したことを反映させるためには全消しが必要。いまいち。 diff --git a/content/20240204221756 raspberry Pi Imagerを使ってSDカードを作成.md b/content/20240204221756 raspberry Pi Imagerを使ってSDカードを作成.md index 101c466..4033302 100644 --- a/content/20240204221756 raspberry Pi Imagerを使ってSDカードを作成.md +++ b/content/20240204221756 raspberry Pi Imagerを使ってSDカードを作成.md @@ -3,7 +3,7 @@ [Install Raspberry Pi OS using Raspberry Pi Imager](https://www.raspberrypi.com/software/) のDownload for * で自分の環境用のRaspberry Pi Imagerをダウンロード、インストール 起動したら、 -- Raspberry PIデバイス: RASPBERRY PI4 +- Raspberry PIデバイス: RASPBERRY PI4 or 5 - OS: Raspberry Pi OS(other) -> Raspberry Pi OS Lite(64-bit) - ストレージ: マイクロSDカードをPCに接続して、それを選ぶ `Would you like to apply OS customization settings?` @@ -16,4 +16,5 @@ SSDブートにしたい場合 完全に同じことを、USBのSSDで実施する。 -microSDはブートの設定を変更する目的で作って、設定を変更してSSDからブートできるようになった後には使用しない。 cf. [[20240204221948 raspberry pi4をSSD bootに設定]] \ No newline at end of file +microSDはブートの設定を変更する目的で作って、設定を変更してSSDからブートできるようになった後には使用しない。 +cf. [[20240204221948 raspberry pi4 5 をSSD bootに設定| raspberry pi4をSSD bootに設定]] \ No newline at end of file diff --git a/content/20240204221948 raspberry pi4をSSD bootに設定.md b/content/20240204221948 raspberry pi4 5 をSSD bootに設定.md similarity index 88% rename from content/20240204221948 raspberry pi4をSSD bootに設定.md rename to content/20240204221948 raspberry pi4 5 をSSD bootに設定.md index cdaa0cc..7a87473 100644 --- a/content/20240204221948 raspberry pi4をSSD bootに設定.md +++ b/content/20240204221948 raspberry pi4 5 をSSD bootに設定.md @@ -1,4 +1,4 @@ -# 20240204221948 raspberry pi4をSSD bootに設定 +# 20240204221948 raspberry pi 4 5 をSSD bootに設定 #raspi #ssd ## 概要 @@ -6,6 +6,7 @@ 1. SSDにRaspberry Pi Imagerで必要なOSを書きこむ。やり方はこちら(SSDドライブを選択) [[20240204221756 raspberry Pi Imagerを使ってSDカードを作成|raspberry Pi Imagerを使ってSDカードを作成]] (20240204 時点ではraspi-cloneではうまくいかなかった) 2. microSDでブート、bootloaderを最新にする 3. raspi-configで起動をSSDに設定、これ以降はmicroSD無しでも起動可能になる +4. (raspi5の場合) 起動確認後にPCIをGen3にする という手順が確実そう。 @@ -71,7 +72,7 @@ capabilities 0x0000007f ここまでできたら、USBブートにする。最初の手順で作ったSSDをraspi4に接続。microSDは外して起動。 -どのくらい速度違うか、簡単に調べてみた。 +どのくらい速度違うか、簡単に調べてみた。 これはraspi4 ``` $ sudo hdparm -tT /dev/mmcblk0 # マイクロSD @@ -86,6 +87,19 @@ $ sudo hdparm -tT /dev/sda # SSD ``` 約 7.6倍くらい高速になっている。素晴しい。 +raspi5でPCI Gen3接続するとどうなったかというと + + +``` +$ sudo hdparm -tT /dev/nvme0n1p2 + +/dev/nvme0n1p2: + Timing cached reads: 6416 MB in 2.00 seconds = 3209.38 MB/sec + Timing buffered disk reads: 2556 MB in 3.00 seconds = 851.35 MB/sec +``` +さらに高速化。 + + もっと詳しく調べたい場合は [[20240213160416 PiBenchmark|PiBenchmark]] を使う。 ### Refs. diff --git a/content/20240205152229 raspi4にgoをインストールする.md b/content/20240205152229 raspi 4 5にgoをインストールする.md similarity index 92% rename from content/20240205152229 raspi4にgoをインストールする.md rename to content/20240205152229 raspi 4 5にgoをインストールする.md index 92e7719..572b170 100644 --- a/content/20240205152229 raspi4にgoをインストールする.md +++ b/content/20240205152229 raspi 4 5にgoをインストールする.md @@ -1,4 +1,4 @@ -# 20240205152229 raspi4にgoをインストールする +# 20240205152229 raspi 4 5にgoをインストールする #raspi #go [All releases - The Go Programming Language](https://go.dev/dl/) ここからバイナリをダウンロード。 raspi4の場合は、linux-arm64。 diff --git a/content/20240211141946 Raspi4 Cloudflareでトンネルを作る.md b/content/20240211141946 Raspi4 Cloudflareでトンネルを作る.md index efac94d..46d80e3 100644 --- a/content/20240211141946 Raspi4 Cloudflareでトンネルを作る.md +++ b/content/20240211141946 Raspi4 Cloudflareでトンネルを作る.md @@ -1,5 +1,5 @@ -# 20240211141946 Raspi4 Cloudflareでトンネルを作る -#raspi #cloudflare #server +# 20240211141946 Raspi 4 5 Cloudflareでトンネルを作る +#raspi4 #raspi5 #cloudflare #server ## 注意 色々なサイトを参考にしたけど、変化が激しいので100%参考になることは無かった。おそらくこのメモもすぐに陳腐化すると思う。私はこの分野の専門ではないので、全然わからないで適当にやっている。 diff --git a/content/20240211185359 Raspi4 Cloudflareでsshアクセスできるようにする.md b/content/20240211185359 Raspi4 Cloudflareでsshアクセスできるようにする.md index 93518d8..e3f3c6c 100644 --- a/content/20240211185359 Raspi4 Cloudflareでsshアクセスできるようにする.md +++ b/content/20240211185359 Raspi4 Cloudflareでsshアクセスできるようにする.md @@ -13,7 +13,7 @@ ### サーバー(raspi)側 CNAME recordの追加 ``` -$ cloudflared tunnel route dns **** pi4.kinoshita-lab.org(ここは好きな名前にする) +cloudflare@saipi5$ cloudflared tunnel route dns **** pi4.kinoshita-lab.org(ここは好きな名前にする) 2024-02-12T11:33:59Z INF Added CNAME pi4.kinoshita-lab.org which will route to this tunnel tunnelID=**** ``` diff --git a/content/20240211202623 Raspi4 Cloudflare tunnel経由でhttpsサーバーを公開する.md b/content/20240211202623 Raspi4 Cloudflare tunnel経由でhttpsサーバーを公開する.md index 86ebea3..d7d10c0 100644 --- a/content/20240211202623 Raspi4 Cloudflare tunnel経由でhttpsサーバーを公開する.md +++ b/content/20240211202623 Raspi4 Cloudflare tunnel経由でhttpsサーバーを公開する.md @@ -38,7 +38,7 @@ cloudflare@saipi4:~ $ cloudflared tunnel --config ~/.cloudflared/config.yaml run ### service化 うまくいっていたらserviceとして登録。 ``` -cloudflare@saipi4:~ $ vim sudo vim /etc/systemd/system/cloudflared.service\ +cloudflare@saipi4:~ $ vim sudo vim /etc/systemd/system/cloudflared.service ``` 中身は ``` @@ -59,7 +59,12 @@ WantedBy=multi-user.target ``` - +``` +$ sudo systemctl daemon-reload +$ sudo systemctl enable cloudflared +$ sudo systemctl start cloudflared +$ sudo systemctl status cloudflared +``` ## cf. - [Cloudflare Tunnel を使って自宅サーバを公開する - hoge な blog](https://akkyorz.hatenablog.com/entry/2022/12/15/012728) \ No newline at end of file diff --git a/content/20240215215031 Raspi4にGiteaをインストール.md b/content/20240215215031 Raspi 4 5 にGitea Forgejoをインストール.md similarity index 89% rename from content/20240215215031 Raspi4にGiteaをインストール.md rename to content/20240215215031 Raspi 4 5 にGitea Forgejoをインストール.md index 985156e..752abc7 100644 --- a/content/20240215215031 Raspi4にGiteaをインストール.md +++ b/content/20240215215031 Raspi 4 5 にGitea Forgejoをインストール.md @@ -1,4 +1,4 @@ -# 20240215215031 Raspi4にGiteaをインストール +# 20240215215031 Raspi 4 5にGitea Forgejoをインストール #raspi #gitea #cloudflare #### Giteaとは @@ -6,13 +6,20 @@ Git+いろいろでgithubのような便利な機能があるやつ。 > Gitea is a painless self-hosted all-in-one software development service, it includes Git hosting, code review, team collaboration, package registry and CI/CD. It is similar to GitHub, Bitbucket and GitLab. Gitea was forked from [Gogs](http://gogs.io/) originally and almost all the code has been changed. See the [Gitea Announcement](https://blog.gitea.com/welcome-to-gitea/) blog post to read about the justification for a fork. +#### Forgejoとは +Giteaのfork +[Forgejo – Beyond coding. We forge.](https://forgejo.org/) #### インストール -goが必要。 [[20240205152229 raspi4にgoをインストールする |raspi4にgoをインストールする]] +- goが必要。 [[20240205152229 raspi 4 5にgoをインストールする|raspi4にgoをインストールする]] +- MySQL、PostgreSQL、MSSQL、SQLite3、またはTiDB(MySQL プロトコル) が必要です。 sqlite3をインストールした + + +[Installation from binary | Gitea Documentation](https://docs.gitea.com/installation/install-from-binary) を見ながらやる。20240407 時点では、Forgejoのインストールドキュメントは未完成っぽい。下記giteaの手順を適宜forgejoに置きかえて実施。 -[Installation from binary | Gitea Documentation](https://docs.gitea.com/installation/install-from-binary) を見ながらやる。 Binary installをする。バイナリは [Gitea | gitea](https://dl.gitea.com/gitea/) から、あたらし目のやつをダウンロード。 -raspi4なので linux-arm64 を選ぶ。20240215 時点では、 +Forgejoの場合は [リリース - forgejo/forgejo - Codeberg.org](https://codeberg.org/forgejo/forgejo/releases) +raspi4、5なので linux-arm64 を選ぶ。20240215 時点では、 `gitea-1.21.5-linux-arm64` が最新だった。 ``` @@ -21,7 +28,7 @@ $ wget https://dl.gitea.com/gitea/1.21.5/gitea-1.21.5-linux-arm64.asc $ chmod a+x ./gitea-1.21.5-linux-arm64 ``` -##### GPG +###### GPG(giteaの場合のみ) ``` $ gpg --keyserver keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2 gpg: directory '/home/kazbo/.gnupg' created @@ -46,7 +53,9 @@ Primary key fingerprint: 7C9E 6815 2594 6888 62D6 2AF6 2D9A E806 EC15 92E2 ##### git(入ってなかったら入れる) ``` -gitea@saipi4:~ $ sudo apt install git +$ sudo apt install git +$ git config --global user.email "自分のメール" +$ git config --global user.name "自分の名前" ``` ##### ユーザー git を作成 diff --git a/content/20240222190405 Raspi4でDropboxを使う.md b/content/20240222190405 Raspi4でDropboxを使う.md index aabb1d2..35c8939 100644 --- a/content/20240222190405 Raspi4でDropboxを使う.md +++ b/content/20240222190405 Raspi4でDropboxを使う.md @@ -1,6 +1,6 @@ # 20240222190405 Raspi4でDropboxを使う -[[20240222192025 Raspi4でrcloneを使う|Raspi4でrcloneを使う]]の方法を推奨。こっちは遅いしイマイチ。 +[[20240222192025 Raspi4 5でrcloneを使う|Raspi4でrcloneを使う]]の方法を推奨。こっちは遅いしイマイチ。 Arm64 linuxは公式には対応していない。 [Dropbox-Uploader](https://github.com/andreafabrizi/Dropbox-Uploader/) というbash scriptを使う。 diff --git a/content/20240222192025 Raspi4でrcloneを使う.md b/content/20240222192025 Raspi4 5でrcloneを使う.md similarity index 93% rename from content/20240222192025 Raspi4でrcloneを使う.md rename to content/20240222192025 Raspi4 5でrcloneを使う.md index c6fffb4..f41fb64 100644 --- a/content/20240222192025 Raspi4でrcloneを使う.md +++ b/content/20240222192025 Raspi4 5でrcloneを使う.md @@ -1,4 +1,4 @@ -# 20240222192025 Raspi4でrcloneを使いdropboxと同期 +# 20240222192025 Raspi4 5でrcloneを使いdropboxと同期 #rclone #raspi ## rclone何? @@ -7,7 +7,9 @@ > Rclone is a command-line program to manage files on cloud storage. It is a feature-rich alternative to cloud vendors' web storage interfaces. [Over 70 cloud storage products](https://rclone.org/#providers) support rclone including S3 object stores, business & consumer file storage services, as well as standard transfer protocols. ## インストール -goが必要かも。 [[20240205152229 raspi4にgoをインストールする|raspi4にgoをインストールする]] を参照。 +20240407 `sudo apt install rclone` でインストールできた。下記で手動でやってもOK + +goが必要かも。 [[20240205152229 raspi 4 5にgoをインストールする|raspi4にgoをインストールする]] を参照。 [Rclone downloads](https://rclone.org/downloads/) から、該当のものをダウンロードする。 Raspi4の場合、 ARM - 64 Bit。 Raspberry Pi OS の場合は.debが該当。 @@ -81,7 +83,7 @@ client_secret> [ENTER] Edit advanced config? y) Yes n) No (default) -y/n> [ENTER] +y/n> n [ENTER] Use web browser to automatically authenticate rclone with remote? * Say Y if the machine running rclone has a web browser you can use @@ -90,7 +92,7 @@ If not sure try Y. If Y failed, try N. y) Yes (default) n) No -y/n> n +y/n> n [ENTER] Option config_token. For this to work, you will need rclone available on a machine that has diff --git a/content/20240312115855 Raspi4 GiteaからForgejoに変更してみる.md b/content/20240312115855 Raspi4 GiteaからForgejoに変更してみる.md index fe2367b..dc78827 100644 --- a/content/20240312115855 Raspi4 GiteaからForgejoに変更してみる.md +++ b/content/20240312115855 Raspi4 GiteaからForgejoに変更してみる.md @@ -4,7 +4,7 @@ ## インストール [Forgejo](https://forgejo.org/download/) "Upgrade from Gitea" に、「バイナリを入れかえればOK」みたいなことが書いてあるので、そのようにしてみる。自分がインストールしていたバージョンは 1.21.5 なので、それに対応したバージョンをインストール -giteaが動いている前提。 cf. [[20240215215031 Raspi4にGiteaをインストール|Raspi4にGiteaをインストール]] +giteaが動いている前提。 cf. [[20240215215031 Raspi 4 5 にGitea Forgejoをインストール|Raspi4にGiteaをインストール]] download: @@ -47,7 +47,7 @@ $ su cloudflare Password: cloudflare@saipi4:~ $ vim ~/.cloudflared/config.yaml # gitea と書いてあるところを gitに変更 -cloudflare@saipi4:~ $ cloudflared tunnel route dns c7e5dcd4-1cfe-4e6f-b8f0-d8d1d1c0c146 git.kinoshita-lab.org +cloudflare@saipi4:~ $ cloudflared tunnel route dns **** git.kinoshita-lab.org ``` cloudflaredコマンドでCNAMEを消す方法が不明だったので、 webインターフェースから gitea を消去。 ``` @@ -92,4 +92,4 @@ lrwxrwxrwx 1 root root 28 Mar 14 22:29 /usr/local/bin/forgejo -> forgejo-1.21.7- ``` ## Ref. - [Forgejo](https://forgejo.org/download/) -- [[20240215215031 Raspi4にGiteaをインストール|Raspi4にGiteaをインストール]] \ No newline at end of file +- [[20240215215031 Raspi 4 5 にGitea Forgejoをインストール|Raspi4にGiteaをインストール]] \ No newline at end of file