sync notes(auto)
This commit is contained in:
parent
27961136dc
commit
abc1d238c1
2 changed files with 236 additions and 0 deletions
32
content/20240324131038 家サーバー.md
Normal file
32
content/20240324131038 家サーバー.md
Normal file
|
@ -0,0 +1,32 @@
|
|||
# 20240324131038 家サーバー 作業ログ
|
||||
#tech #server #nas #todo
|
||||
|
||||
## 用途
|
||||
- NAS
|
||||
- Dropboxとかの代わり
|
||||
- proxmoxとその学習、コンテナとかで色々あそぶ
|
||||
## ハード構成
|
||||
|
||||
- 本体 [NucBox G3--Most Cost-Effective Mini PC With Intel N100 Processor](https://www.gmktec.com/products/nucbox-g3-most-cost-effective-mini-pc-with-intel-n100-processor)
|
||||
- RAM 32GB DDR4 https://www.amazon.co.jp/dp/B0B47X2KNT
|
||||
- OS用SSD キオクシア KIOXIA 内蔵 SSD 1TB NVMe M.2 https://www.amazon.co.jp/dp/B09KZG6PQV
|
||||
|
||||
|
||||
## proxmoxのインストール
|
||||
[Download Proxmox software, datasheets, agreements](https://www.proxmox.com/en/downloads) 公式サイトかららダウンロード。
|
||||
8.1のISOをダウンロードした。 [Proxmox VE 8.1 ISO Installer](https://www.proxmox.com/en/downloads/proxmox-virtual-environment/iso/proxmox-ve-8-1-iso-installer)
|
||||
[Raspberry pi imager](https://www.raspberrypi.com/software/) を使ってUSBメモリーに書いて、それをPCに挿して起動、インストール。
|
||||
インストール完了すると、 https://IPアドレス:8006 でアクセスできるようになる。 hostnameは kinorr にした。
|
||||
|
||||
|
||||
WEBアプリで、 データセンター -> アクセス権限 -> 2要素 追加で root@pamを totpにしておいた。
|
||||
やる必要があったか謎。
|
||||
|
||||
|
||||
|
||||
kinorr(ホスト名) -> アップデート -> リポジトリ
|
||||
からサブスクリプションが必要なものを削除。
|
||||
|
||||
cf. [Proxmox VEで無償版リポジトリを設定する | Nishiの独り言](https://blog.nishi.network/2023/02/12/proxmox7-3-repository/)
|
||||
|
||||
[[20240409145451 USB HDDをRAID5にする]]
|
204
content/20240409145451 USB HDDをRAID5にする.md
Normal file
204
content/20240409145451 USB HDDをRAID5にする.md
Normal file
|
@ -0,0 +1,204 @@
|
|||
# 20240409145451 USB HDDをRAID5にする
|
||||
|
||||
- [WD60EZAZ-RT | WD60EZAZ-RT | WesternDigital WD Blue SATA3 6Gbps(SATA6G) 3.5型ハードディスク 6TB | CFD販売株式会社 CFD Sales INC.](https://www.cfd.co.jp/biz/product/detail/wd60ezaz-rt.html) このHDDを中古で3台購入。
|
||||
- HDDケース https://www.amazon.co.jp/dp/B08MBPZBBV
|
||||
- USBハブ https://www.amazon.co.jp/dp/B0BWH9DZRV
|
||||
|
||||
gdiskでパーティーションを作成。 USBなので起動するときに最初設定した場合と `/dev/sda` などの表示が異なることもありえるので、 後でGUIDを使って指定する。最初はとりあえず1つずつ挿してgdiskをすればよい。
|
||||
|
||||
中古だからかもしれないが、 MBRが書きこまれていたので削除する作業が必要だった。
|
||||
```
|
||||
# gdisk /dev/sda
|
||||
GPT fdisk (gdisk) version 1.0.9
|
||||
|
||||
Partition table scan:
|
||||
MBR: MBR only
|
||||
BSD: not present
|
||||
APM: not present
|
||||
GPT: not present
|
||||
|
||||
|
||||
***************************************************************
|
||||
Found invalid GPT and valid MBR; converting MBR to GPT format
|
||||
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
|
||||
typing 'q' if you don't want to convert your MBR partitions
|
||||
to GPT format!
|
||||
***************************************************************
|
||||
|
||||
|
||||
Command (? for help): o
|
||||
This option deletes all partitions and creates a new protective MBR.
|
||||
Proceed? (Y/N): Y
|
||||
Command (? for help): w
|
||||
|
||||
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
|
||||
PARTITIONS!!
|
||||
|
||||
Do you want to proceed? (Y/N): Y
|
||||
OK; writing new GUID partition table (GPT) to /dev/sdc.
|
||||
Warning: The kernel is still using the old partition table.
|
||||
The new table will be used at the next reboot or after you
|
||||
run partprobe(8) or kpartx(8)
|
||||
The operation has completed successfully.
|
||||
```
|
||||
上記終了後にpartition情報を書いた。
|
||||
```
|
||||
# gdisk /dev/sda
|
||||
GPT fdisk (gdisk) version 1.0.9
|
||||
|
||||
Partition table scan:
|
||||
MBR: not present
|
||||
BSD: not present
|
||||
APM: not present
|
||||
GPT: not present
|
||||
|
||||
Creating new GPT entries in memory.
|
||||
|
||||
Command (? for help): p
|
||||
Disk /dev/sda: 11721045168 sectors, 5.5 TiB
|
||||
Model: EZAZ-00ZGHB0
|
||||
Sector size (logical/physical): 512/4096 bytes
|
||||
Disk identifier (GUID): 0578B29F-51A1-49C0-BE65-6956FBA95417
|
||||
Partition table holds up to 128 entries
|
||||
Main partition table begins at sector 2 and ends at sector 33
|
||||
First usable sector is 34, last usable sector is 11721045134
|
||||
Partitions will be aligned on 2048-sector boundaries
|
||||
Total free space is 11721045101 sectors (5.5 TiB)
|
||||
|
||||
Number Start (sector) End (sector) Size Code Name
|
||||
|
||||
Command (? for help): n
|
||||
Partition number (1-128, default 1): [ENTER]
|
||||
First sector (34-11721045134, default = 2048) or {+-}size{KMGTP}: [ENTER]
|
||||
Last sector (2048-11721045134, default = 11721043967) or {+-}size{KMGTP}: [ENTER]
|
||||
Current type is 8300 (Linux filesystem)
|
||||
Hex code or GUID (L to show codes, Enter = 8300): fd00 <- linux raidを指定
|
||||
Changed type of partition to 'Linux RAID'
|
||||
|
||||
Command (? for help): w
|
||||
|
||||
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
|
||||
PARTITIONS!!
|
||||
|
||||
Do you want to proceed? (Y/N): Y
|
||||
OK; writing new GUID partition table (GPT) to /dev/sda.
|
||||
The operation has completed successfully.
|
||||
```
|
||||
以上を3回くりかえす。
|
||||
|
||||
↓こんな感じになればOK。
|
||||
```
|
||||
# tree /dev/disk
|
||||
...
|
||||
├── by-partuuid
|
||||
│ ├── 3fa55707-567f-4fcb-b391-1ad9ffbffab8 -> ../../sda1
|
||||
│ ├── 6963ee24-45c4-410d-945a-32b611006e50 -> ../../sdb1
|
||||
│ ├── 8649367f-4390-49e1-b389-a09c9033fdcb -> ../../nvme0n1p1
|
||||
│ ├── bacd35fa-dfe7-43d1-8906-09069ae7b3e0 -> ../../sdc1
|
||||
│ ├── e3d4c4c2-2e9d-49ad-859e-5824909a40fc -> ../../nvme0n1p2
|
||||
│ └── f79f3a27-e396-4820-bc02-fd51e7e54bff -> ../../nvme0n1p3
|
||||
...
|
||||
```
|
||||
この時点でうまくいかなくて再起動しようとしたら、インストール直後でUEFIの起動オーダーがUSBデバイスからになっていたため起動しなくなるという問題が発生。UEFIの設定を bootをnvmeにした。
|
||||
|
||||
```
|
||||
# apt install mdadm
|
||||
```
|
||||
|
||||
```
|
||||
# mdadm --create /dev/md1 --level=5 --raid-devices=3 /dev/disk/by-partuuid/3fa55707-567f-4fcb-b391-1ad9ffbffab8 /dev/disk/by-partuuid/6963ee24-45c4-410d-945a-32b611006e50 /dev/disk/by-partuuid/bacd35fa-dfe7-43d1-8906-09069ae7b3e0
|
||||
mdadm: Defaulting to version 1.2 metadata
|
||||
mdadm: array /dev/md1 started.
|
||||
```
|
||||
|
||||
```
|
||||
# mdadm --detail /dev/md1
|
||||
/dev/md1:
|
||||
Version : 1.2
|
||||
Creation Time : Tue Apr 9 13:34:16 2024
|
||||
Raid Level : raid5
|
||||
Array Size : 11720777728 (10.92 TiB 12.00 TB)
|
||||
Used Dev Size : 5860388864 (5.46 TiB 6.00 TB)
|
||||
Raid Devices : 3
|
||||
Total Devices : 3
|
||||
Persistence : Superblock is persistent
|
||||
|
||||
Intent Bitmap : Internal
|
||||
|
||||
Update Time : Tue Apr 9 13:35:03 2024
|
||||
State : clean, degraded, recovering
|
||||
Active Devices : 2
|
||||
Working Devices : 3
|
||||
Failed Devices : 0
|
||||
Spare Devices : 1
|
||||
|
||||
Layout : left-symmetric
|
||||
Chunk Size : 512K
|
||||
|
||||
Consistency Policy : bitmap
|
||||
|
||||
Rebuild Status : 0% complete
|
||||
|
||||
Name : kinorr:1 (local to host kinorr)
|
||||
UUID : 40475448:83c77036:4a8b1907:85cab891
|
||||
Events : 10
|
||||
|
||||
Number Major Minor RaidDevice State
|
||||
0 8 1 0 active sync /dev/sda1
|
||||
1 8 17 1 active sync /dev/sdb1
|
||||
3 8 33 2 spare rebuilding /dev/sdc1
|
||||
```
|
||||
|
||||
できたっぽい。
|
||||
この後、再起動しないと、`mkfs.ext4`が `device or resource busy`をなってしまったので再起動した。
|
||||
|
||||
|
||||
```
|
||||
# mkfs.ext4 -L kinoraid5 /dev/md1
|
||||
mke2fs 1.47.0 (5-Feb-2023)
|
||||
Creating filesystem with 2930194432 4k blocks and 366276608 inodes
|
||||
Filesystem UUID: fcf8ecc4-59bc-4510-b0c0-adfde0cda386
|
||||
Superblock backups stored on blocks:
|
||||
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
|
||||
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
|
||||
102400000, 214990848, 512000000, 550731776, 644972544, 1934917632,
|
||||
2560000000
|
||||
|
||||
Allocating group tables: done
|
||||
Writing inode tables: done
|
||||
Creating journal (262144 blocks): done
|
||||
Writing superblocks and filesystem accounting information: done
|
||||
```
|
||||
|
||||
マウントは自動ではされないみたい。
|
||||
```
|
||||
# mkdir /mnt/raid-disk
|
||||
# mount /dev/md1 /mnt/raid-disk
|
||||
```
|
||||
で、使えることを確認。 fstabに追加・・・はうまくいかなかった(外付けだから?理由は不明)
|
||||
systemdでマウントすることにした。
|
||||
|
||||
ファイル名とマウントポイントを一致させる必要があるなどややこしい。
|
||||
(/mnt/hoge にマウントしたい場合は mnt-hoge.mount というファイル名にする必要があるらしい。)
|
||||
WantedBy= の所をギリギリまで遅くしている。
|
||||
```
|
||||
# cat /etc/systemd/system/raid.mount
|
||||
[Unit]
|
||||
Description=Mout Raid USB HDD(delayed)
|
||||
|
||||
[Mount]
|
||||
What=/dev/disk/by-uuid/fcf8ecc4-59bc-4510-b0c0-adfde0cda386
|
||||
Where=/raid
|
||||
Type=ext4
|
||||
Options=defaults
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
cf. [systemd で外付けディスクをマウントする話 - げっとシステムログ](https://www.getto.systems/entry/2019/11/19/203543)
|
||||
|
||||
|
||||
|
||||
## Refs.
|
||||
- [linuxのmdadmで作ったRAID5を壊したり直したり。 - Blanktar](https://blanktar.jp/blog/2014/02/mdadm-raid5)
|
||||
- [Linux Software RAID をコマンドラインから組んでみる #Linux - Qiita](https://qiita.com/nishimry/items/5ed169ea1bd533872aa2)
|
Loading…
Reference in a new issue