LoginSignup
1
0
Qiita×Findy記事投稿キャンペーン 「自分のエンジニアとしてのキャリアを振り返ろう!」

rapberry pi 5 を使って nvme のみから ubuntu を立ち上げる そして usbメモリからnvmeへクローン

Last updated at Posted at 2024-02-11

ubuntu とてもとても 安定してます

rasparchもarmbianも 少し不安定
pimoroniのnvmeアダプターを上に持っていくと nvme の入れ替えがとっても楽! 

Photo Marker_20240417_155439.jpg

Photo Marker_20240504_113038.jpg

Photo Marker_20240504_113104.jpg

と USB DACをつけて ヤマハのスピーカーで聞いてます

自分にとっては ubuntuでは Pi5 から 直接 印刷できるのが魅力です

p.jpg

もう一つ所有の laserプリンターは USBケーブルではだめですが 有線LANだとOKです
ppp.jpg

プリンターを登録してる光景は次のユーチューブで恐ろしく簡単



起動風景は

ですが、 刺してないSDcard 、 刺してないUSBメモリ のあと nvmeから起動する設定にしてますので 40秒前後時間がかかります



1)

nvme を USB アダプターに取り付けたあと  Windows 11のパソコンのusbポートにさし
pi imager をつかって インストール先をこの USB アダプターにします

2)

最後まで終了したら この [nvme の入った USB アダプター]を外して
Linux のusbポートにつけます

3)

config.txtを探して Linux 上で
最後に 
dtparam=pciex1
を加えます

4)

umountをして
この [nvme の入った USB アダプター] を外します

5)

中に入っている nvme を ラズベリーパイ 5 につけます
自分は pimoroniのにつけました

11.jpg

6)

後は Rpi5からの指示通りにやったら
ラズベリーパイ 5 で Ubuntu が nvme 上で動くようになります

ただし できたら 有線 LAN でやるのが無難です
というのは
wi-fi でやろうとすると wi-fi ルーターとの相性が悪い時にインストールが途中でストップするから

以下参考資料

# uname -ar
Linux pn5 6.5.0-1010-raspi #13-Ubuntu SMP PREEMPT_DYNAMIC Thu Jan 18 09:08:04 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux



# df
Filesystem     1K-blocks    Used Available Use% Mounted on
tmpfs             813048    3512    809536   1% /run
/dev/nvme0n1p2 122422648 7772772 109574668   7% /
tmpfs            4065224       0   4065224   0% /dev/shm
tmpfs               5120      12      5108   1% /run/lock
/dev/nvme0n1p1    516204  108210    407995  21% /boot/firmware
tmpfs             813044    2540    810504   1% /run/user/1000


# time dd if=/dev/zero of=ZERO bs=1024k count=10000
10000+0 records in
10000+0 records out
10485760000 bytes (10 GB, 9.8 GiB) copied, 22.2041 s, 472 MB/s
real	0m22.215s
user	0m0.004s
sys	0m18.151s

# ls -l ZERO 
-rw-r--r-- 1 root root 10485760000 Feb 17 03:53 ZERO



7) さらに深海へ ! USBメモリから nvmeへ クローンしてnvmeで動かす

「USBメモリ」 に導入した UBUNTUで

printer.jpg

というかたちで 10年以上前の 非CUPSプリンターで wiwi印刷できました

しかし その手順をすっかり忘れてしましました。

それで
「USBメモリ」を nvme にクローンして できました。

手順の概要です

1) マイクロSDカード、 USBメモリ 、nvme をつけて起動します
すると マイクロSDカードの raspberrypiOSがたちあがります
たぶん USBメモリのパーテションが mountされてると 思います。
これらは umonun しておいて下さい。
そこで USBメモリを ddで nvmeに クローンします

2)シャットダウン

3)マイクロSDカード、 nvme をつけて起動
すると マイクロSDカードの raspberrypiOSがたちあがります

4)nvmeの第一領域にある config.txtを探し出して
このファイルの最後に
dtparam=pciex1
を加えます

5)シャットダウン

6)nvmeだけにして Rpi5に電源をいれると
あらどうでしょう
「USBメモリ」にはいってた UBUNTUがたちあがり 古いプリンターから テスト印刷ができました

ーーーーーーーーーーー

が原点で

です




プリンター関係の追求を少ししてみます

$ sudo head -20 /etc/cups/printers.conf
# Printer configuration file for CUPS v2.4.6
# Written by cupsd
# DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING
NextPrinterId 142
<DefaultPrinter Brother_DCP-J925N>
PrinterId 15
UUID urn:uuid:d5840f1b-f694-397f-66db-fbe8352cd571
AuthInfoRequired none
Info Brother DCP-J925N
Location 
MakeModel DCP-J925N - IPP Everywhere
DeviceURI ipp://BRN001BA98AC0C7.local:631/ipp/port1
State Idle
StateTime 1708455159
ConfigTime 1704058978
Type 4124
Accepting Yes
Shared No
JobSheets none none
QuotaPeriod 0


$ ls -ltr /etc/cups/ppd
total 100
-rw-r----- 1 root lp   11087 Jan  1 06:42 Brother_DCP-J925N.ppd.O
-rw-r----- 1 root lp   11087 Jan  1 06:42 Brother_DCP-J925N.ppd
-rw-r----- 1 root lp    9088 Feb 14 07:16 laser.ppd.O
-rw-r--r-- 1 root root  9144 Feb 14 07:17 laser.ppd
-rw-r----- 1 root lp    9303 Feb 19 12:59 Brother_HL-L8360CDW_series.ppd.O
-rw-r----- 1 root lp    9313 Feb 19 12:59 Brother_HL-L8360CDW_series.ppd
-rw-r----- 1 root lp   11087 Feb 21 06:12 Brother_DCP_J925N.ppd.O
-rw-r----- 1 root lp   14513 Feb 21 06:12 Brother_DCP_J925N.ppd
あれれのれ、ここに勝手 にプリンタードライバーがきてる


----------------



dpkg-query -l からのを利用して


# cat ki | grep foomatic
ii  foomatic-db-compressed-ppds                   20230202-1                              all          OpenPrinting printer support - Compressed PPDs derived from the database

 
# cat ki | grep gutenprint

# aptitude search foomatic
p   foomatic-db                                                    - OpenPrinting printer support - database                                 
i A foomatic-db-compressed-ppds                                    - OpenPrinting printer support - Compressed PPDs derived from the database
p   foomatic-db-engine                                             - OpenPrinting printer support - programs                                 
p   foomatic-filters                                               - OpenPrinting printer support - filters                                  
p   foomatic-filters-beh                                           - Openprinting Backend error handler                                      


# aptitude search gutenprint
p   gimp-gutenprint                                                - print plugin for the GIMP                                               
p   gutenprint-doc                                                 - users' guide for Gutenprint and CUPS                                    
p   gutenprint-locales                                             - locale data files for Gutenprint                                        
p   libgutenprint-common                                           - support files for the Gutenprint printer driver library                 
p   libgutenprint-dev                                              - development files for the Gutenprint printer driver library             
p   libgutenprint-doc                                              - documentation for the Gutenprint printer driver library                 
p   libgutenprint9                                                 - runtime for the Gutenprint printer driver library                       
p   libgutenprintui2-2                                             - runtime for the Gutenprint printer driver user interface library        
p   libgutenprintui2-dev                                           - development files for the Gutenprint printer driver user interface libra
p   printer-driver-gutenprint                                       - printer drivers for CUPS 



資料 1)
https://www.raspberrypi.com/documentation/computers/raspberry-pi-5.html#cooling-raspberry-pi-5
https://www.kali.org/docs/arm/raspberry-pi-5/
https://blog.alexellis.io/booting-the-raspberry-pi-5-from-nvme/
資料 2)
dtparam=pciex1_gen=3

# ./comment-out.bat /boot/firmware/config.txt
[all]
kernel=vmlinuz
cmdline=cmdline.txt
initramfs initrd.img followkernel
[pi4]
max_framebuffers=2
arm_boost=1
[all]
dtparam=audio=on
dtparam=i2c_arm=on
dtparam=spi=on
disable_overscan=1
[cm4]
dtoverlay=dwc2,dr_mode=host
[all]
dtoverlay=vc4-kms-v3d
camera_auto_detect=1
display_auto_detect=1
arm_64bit=1
dtoverlay=dwc2
dtparam=pciex1
dtparam=pciex1_gen=3
にて


# time dd if=/dev/zero of=ZERO bs=1024k count=10000
10000+0 records in
10000+0 records out
10485760000 bytes (10 GB, 9.8 GiB) copied, 18.8142 s, 557 MB/s

とスピードはアップしたけど 2倍にはなってません。
1Gだと 正確なnvmeの性能は測れないと自分はおもいます(キャシュの関係?)

比較のため

ちょっと性能いい下記のLINUXマシン(Hp Z2)では
   Xeon(R) CPU E3-1245 v5 @ 3.50GHz
   Mem:        16298540
time dd if=/dev/zero of=ZERO bs=1024k count=10000
10485760000 bytes (10 GB, 9.8 GiB) copied, 5.9237 s, 1.8 GB/s
まあ スポーツカーとの比較なのでしょうがないですねえ

資料 3) バックアップ

raspberryOS のはいっている 320GBの機械式ハードディスクドライブを
ハードディスクスタンドにはめ込み USB接続させてます

これにて raspberryOSがきどうします

そこで
https://blog.goo.ne.jp/a-storm/e/616403c75c544d4c5aaefdeeb4147093
みて

 dd if=/dev/nvme0n1 bs=64k status=progress | gzip -c > RPI5-nvme.gz 
255944163328 bytes (256 GB, 238 GiB) copied, 2606 s, 98.2 MB/s
3907173+1 records in
3907173+1 records out
256060514304 bytes (256 GB, 238 GiB) copied, 2607.4 s, 98.2 MB/s

動画では 以下な感じです

自分の場合は

# ./comment-out.bat dd-gzip.bat
clear
ls -l *.gz
df
echo '------------------'
df | grep sda
echo '-----nnnnnnnnnnnnn'
fdisk -l /dev/nvme0n1
echo
dd if=/dev/nvme0n1 bs=64k status=progress | gzip -c > RPI5-nvme-256060514304.gz
x=`date +%Y%m%d`
cp RPI5-nvme-256060514304.gz RPI5-nvme-256060514304-bytes-$x.gz

なスクリプトです

---
結果は
-rw-r--r-- 1 root root 9507332923  3月  2 05:23 RPI5-nvme-256060514304.gz
-rw-r--r-- 1 root root 9507332923  3月  2 05:28 RPI5-nvme-256060514304-bytes-20240302.gz
で
10GB弱です


資料4

raspberry pi フォーラム
https://forums.raspberrypi.com/

資料5 ベンチマーク

# time sysbench cpu run --events=10000 --threads=4
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 4
Initializing random number generator from current time


Prime numbers limit: 10000

Initializing worker threads...

Threads started!

CPU speed:
    events per second: 10190.85

General statistics:
    total time:                          0.9796s
    total number of events:              10000

Latency (ms):
         min:                                    0.37
         avg:                                    0.39
         max:                                   20.37
         95th percentile:                        0.37
         sum:                                 3878.42

Threads fairness:
    events (avg/stddev):           2500.0000/116.69
    execution time (avg/stddev):   0.9696/0.01


real	0m0.994s
user	0m3.665s
sys	0m0.012s






-----------------------
https://gigazine.net/news/20240126-raspberry-pi-5-ssd-boot/
の
sudo curl https://raw.githubusercontent.com/TheRemote/PiBenchmarks/master/Storage.sh | sudo bash

では
     Category                  Test                      Result     
HDParm                    Disk Read                 792.21 MB/sec            
HDParm                    Cached Disk Read          764.84 MB/sec            
DD                        Disk Write                294 MB/s                 
FIO                       4k random read            157538 IOPS (630153 KB/s)
FIO                       4k random write           48075 IOPS (192300 KB/s) 
IOZone                    4k read                   190928 KB/s              
IOZone                    4k write                  126086 KB/s              
IOZone                    4k random read            63722 KB/s               
IOZone                    4k random write           167761 KB/s              

                          Score: 36614                                       


資料6 Pi5がおかしくなったときの backup

自分は libreofficeが起動しなくなりました. backupで回復しました
USBなraspbery OS で起動して以下をします

./comment-out.bat dd-gzip.bat
clear
ls -l *.gz
df
echo '------------------'
df | grep nvme0n1
echo '-----nnnnnnnnnnnnn'
fdisk -l /dev/nvme0n1
echo
echo
echo
echo 'dd if=/dev/nvme0n1 bs=64k status=progress | gzip -c > RPI5-nvme-256060514304.gz '
dd if=/dev/nvme0n1 bs=64k status=progress | gzip -c > RPI5-nvme-256060514304.gz
echo
echo
echo
x=`date +%Y%m%d`
mv RPI5-nvme-256060514304.gz RPI5-nvme-256060514304-bytes-$x.gz
ls -ltr *.gz
echo ' gunzip -c xxx.gz | dd of=/dev/nvme0n1 bs=64k status=progress '

Photo Marker_20240317_041834.jpg

という USBハードディスクスタンドを用いて

https://wiki.archlinux.jp/index.php/RAID
をみて
mdadm --create --verbose --level=0 --metadata=1.2 --chunk=64 --raid-devices=2 /dev/md0 /dev/sdx1 /dev/sdy1 

mkfs.ext4 -v -L myarray -m 0.5 -b 4096 -E stride=16,stripe-width=32 /dev/md0

して
mount /dev/md0 /mm0
にて
# ls -l /mm0/
合計 50394832
-rw-r--r-- 1 root root 51604275200  3月 17 03:42 RPI5-nvme-256060514304.img
-rwxr-xr-x 1 root root         417  3月 17 03:36 dd-gzip.bat
-rwxr-xr-x 1 root root         315  3月 17 03:33 dd-gzip.bat-ok-1
drwx------ 2 root root       16384  3月 17 03:31 lost+found
の gzipしない生のimgのほうがはやい



資料5

nvme が
# smartctl -a /dev/nvme0 | grep Model
Model Number:                       KXG50ZNV256G TOSHIBA
これでも、大丈夫でした


しかし
     Category                  Test                      Result     
HDParm                    Disk Read                 410.37 MB/sec            
HDParm                    Cached Disk Read          405.67 MB/sec            
DD                        Disk Write                203 MB/s                 
FIO                       4k random read            105567 IOPS (422268 KB/s)
FIO                       4k random write           46757 IOPS (187031 KB/s) 
IOZone                    4k read                   74561 KB/s               
IOZone                    4k write                  105871 KB/s              
IOZone                    4k random read            27027 KB/s               
IOZone                    4k random write           127118 KB/s              
                          Score: 26574                                       

なので samsungのより 成績がちょっとわるいです




1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0