OpenWrt USBとディスク

:warning:Japanese notation

# こちらに統合しました

::: note
### [オールインワンスクリプト](https://qiita.com/site_u/items/c6a50aa6dea965b5a774)

![selector.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3412833/809fa65b-d98d-16f6-50e2-72a0030c1a56.png)

### 対応スクリプト

- [package-config.sh](https://github.com/site-u2023/config-software/blob/main/package-config.sh)
- [package-auto-g.sh](https://github.com/site-u2023/config-software/blob/main/package-auto-g.sh)
- [package-manual-g.sh](https://github.com/site-u2023/config-software/blob/main/package-manual-g.sh)

:::

::: note
### [PowerShell](https://learn.microsoft.com/ja-jp/powershell/scripting/what-is-windows-powershell?view=powershell-7.4)で[SSHアクセス](https://openwrt.org/docs/guide-quick-start/sshadministration)

- [PowerShellの開始](https://learn.microsoft.com/ja-jp/powershell/scripting/windows-powershell/starting-windows-powershell?view=powershell-7.4) (キー入力)：`Win`+`x` > `a` > `はい`
※Windows7以降標準搭載

```sh
ssh root@192.168.1.1
```

<details><summary>ssh root@192.168.1.1のショートカット作成（デスクトップ）</summary>

```powershell:powershell
$DESKTOP = ([Environment]::GetFolderPath("Desktop") + "\192.168.1.1.lnk")
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$DESKTOP")
$Shortcut.TargetPath = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
$Shortcut.Arguments = '-windowstyle hidden -ExecutionPolicy RemoteSigned "Start-Process ssh root@192.168.1.1"'
$Shortcut.IconLocation = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe,0"
$Shortcut.WorkingDirectory = "."
$Shortcut.Save()

```

- `強制的に貼り付け`
- `yes`

---

</details>

<details><summary>SSHログイン出来ない場合:exclamation:</summary>

known_hostsクリア
- `C:\Users\yourusername\.ssh\known_hosts` ※Windows隠しファイル
```powershell:powershell
Clear-Content .ssh\known_hosts -Force

```
---
OpenSSHのインストール
※Windows 10 Fall Creators Update(1709)以降標準搭載
- 機能の確認
```powershell:powershell
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'

```
- 機能のインストール
```powershell:powershell
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

```
---

</details>

:::

# [USB](https://openwrt.org/docs/guide-user/storage/usb-drives)
:::note
### ベース

```bash
opkg update
opkg install block-mount
opkg install kmod-usb-storage
opkg install kmod-usb-storage-uas
opkg install usbutils
opkg install gdisk
opkg install libblkid1
# USBポート_LEDトリガー
opkg install kmod-usb-ledtrig-usbport
opkg install luci-app-ledtrig-usbport
# reboot

```
:::
::: note
### [ファイルシステム](https://openwrt.org/docs/guide-user/storage/filesystems-and-partitions)
```bash
opkg update
# FAT32
opkg install dosfstools
opkg install kmod-fs-vfat
# ext4
opkg install e2fsprogs
opkg install kmod-fs-ext4
# f2fs
opkg install f2fs-tools
opkg install kmod-fs-f2fs
# exFAT
opkg install exfat-fsck
opkg install kmod-fs-exfat
# NTFS
opkg install ntfs-3g
opkg install kmod-fs-ntfs3
# HFS & HFS+
opkg install hfsfsck
opkg install kmod-fs-hfs
opkg install kmod-fs-hfsplus

```
:::
::: note
### [ハードディスクアイドル](https://openwrt.org/docs/guide-user/storage/hd-idle)
```bash
opkg update
opkg install hdparm
opkg install hd-idle
opkg install luci-app-hd-idle
opkg install luci-i18n-hd-idle-ja

```
:::
::: note
### [USBドライブフォーマット](https://openwrt.org/docs/guide-user/storage/usb-drives-quickstart)
- フラッシュメモリー(メモリースティック等)
```bash
mkfs.f2fs /dev/sda1

```

- ハードディスク
```bash
mkfs.ext4 /dev/sda1

```

- WIndowsからフォーマット
  - [EaseUS Partition Master](https://jp.easeus.com/partition-manager-software/)
    - [Free](https://down.easeus.com/product/epm_free?ref=https%3A%2F%2Fjp.easeus.com%2Fpartition-manager-software%2F)

:::

# カスタムフィード
::: note
### [ディスクインフォ](https://github.com/gSpotx2f/luci-app-disks-info)
```sh
#! /bin/sh
# custom feed (log viewer, cpu status, cpu perf, temp status, Internet detector, disk info)
if [ -e ${UPDATE} ]; then
opkg update
UPDATE="1"
fi
mkdir -p /etc/config-software
wget --no-check-certificate -O /etc/config-software/pacage_list https://github.com/gSpotx2f/packages-openwrt/raw/master/current/
PACAGE_LIST=`cat /etc/config-software/pacage_list |sed -ne '/ <script type/,/<\/script>/p' |sed -e 's/<[^>]*>//g'`
DISKA_INFO=`echo ${PACAGE_LIST} | awk '{print substr($0,index($0,"current/luci-app-disks-info") ,60)}' | awk '{ sub(".ipk.*$",""); print $0; }'`
wget --no-check-certificate -O /tmp/luci-app-disks-info_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/${DISKA_INFO}
opkg install /tmp/luci-app-disks-info_all.ipk
rm /tmp/luci-app-disks-info_all.ipk

```
:::

:::note
### [ディスクマン](https://github.com/lisaac/luci-app-diskman)

```sh
#! /bin/sh
if [ -e ${UPDATE} ]; then
opkg update
UPDATE="1"
fi
opkg install luci-compat
opkg install luci-lib-ipkg
opkg install parted
opkg install blkid
opkg install smartmontools
opkg install e2fsprogs
opkg install make
opkg install btrfs-progs # オプション
opkg install lsblk # オプション
opkg install mdadm # オプション
opkg install kmod-md-raid456 # オプション
opkg install kmod-md-linear # オプション
mkdir -p package/luci-app-diskman && \
wget https://raw.githubusercontent.com/lisaac/luci-app-diskman/master/applications/luci-app-diskman/Makefile -O package/luci-app-diskman/Makefile
mkdir -p package/parted && \
wget https://raw.githubusercontent.com/lisaac/luci-app-diskman/master/Parted.Makefile -O package/parted/Makefile

#compile package only
make package/luci-app-diskman/compile V=99

#compile
make menuconfig
#choose LuCI ---> 3. Applications  ---> <*> luci-app-diskman..... Disk Manager interface for LuCI ----> save
make V=99
```

:::

:::note
### [SAMBA4 (WSDD2)](https://qiita.com/site_u/items/aa9164859a78cb4e3f8f)

:::