2021/3/2

mender.io 製作系統更新檔

document source: 以 pi 為範例。
系統檔由 pi 上取得,用 mender-artifact 這個 tool 來做。
mender-artifact 執行檔在 meder server 下載,參考上面的 link

首先 pi 3 要跟 PC 有網路連接,ssh login OK
然後在 PC 端下:
mender-artifact write rootfs-image -f ssh://"pi@172.16.200.12" -t "raspberrypi3" -n system-v1 -o system-v1.mender -S "-p 22"
pi@172.16.200.12's password: 
..................................................Writing Artifact...
Version             	✓
Manifest            	✓
Manifest signature  	✓
Header              	✓
Payload
........................................................................ - 100 %
輸出就是 system-v1.mender

看source code,payloads = rootfs-image,這種 type,install module 是寫死的,也不容許有 custom script

換一個好了...

在 target board 上,使用這個 command,出現 Error:
mender-artifact write rootfs-image -f ssh://"root@10.0.1.2" -t "dm1" -n system-d1 -o system-d1.mender -S "-p 22"
time="2021-03-03T08:23:43Z" level=error msg="Device-local data is stored on the partition being snapshotted: /var/lib/mender. 
The recommended approach is to have a separate data-partition mounted on \"/data\" and add a symbolic link (/var/lib/mender -> /data). 
Consult either https://docs.mender.io/system-updates-debian-family/overview#partition-layoutfor Debian family 
or https://docs.mender.io/system-updates-yocto-project/overview#partition-layoutin case you use Yocto"
time="2021-03-03T08:23:43Z" level=error msg="data store (/var/lib/mender) is located on filesystem /"
imgFilesystemType error: imgFilesystemType: blkid command failed: exit status 2
看一下 example 的 raspberrypi3 的 /var/lib:
lrwxrwxrwx 1 root root   12 Jan 21 03:06 mender -> /data/mender
把 /var/lib/mender copy 到 /data 後,再
ln -s /data/mender /var/lib/mender
這個 folder 存的好像是 device identity,所以要是copy 這個 folder 到令一個 device。這兩格 device 在 mender.io 會被認為是同一個。
所以不能 copy
第一次 run mender daemon 時,會產生這個 folder 的資料。

之後再 mender-artifact write 就正確download 到,並且產生 system-d1.mender

upload 到 server, make release (create 一個 dm1group.把 dm1 家入), deploy 時 fail...server 端 log:
2021-03-03 08:35:47 +0000 UTC info: Running Mender client version: 7cb96ca
2021-03-03 08:35:47 +0000 UTC debug: Handling update fetch state
2021-03-03 08:35:47 +0000 UTC debug: received the GET_AUTH_TOKEN action
2021-03-03 08:35:47 +0000 UTC debug: Connecting to server docker.mender.io
2021-03-03 08:35:47 +0000 UTC debug: Status reported, response 204 No Content
2021-03-03 08:35:47 +0000 UTC debug: Received fetch update response &{200 OK 200 HTTP/1.1 1 1 
map[Accept-Ranges:[bytes] Connection:[keep-alive] Content-Length:[144589824] Content-Security-Policy:[block-all-mixed-content] 
Content-Type:[application/vnd.mender-artifact] Date:[Wed, 03 Mar 2021 08:35:48 GMT] Etag:["c8154---"] 
Expires:[Wed, 03 Mar 2021 08:43:55 GMT] Last-Modified:[Wed, 03 Mar 2021 08:33:58 GMT] 
Server:[openresty/1.13.6.2] Strict-Transport-Security:[max-age=0; includeSubdomains; preload] 
Vary:[Origin] X-Amz-Request-Id:[1668C829E54429D3] X-Content-Type-Options:[nosniff] X-Frame-Options:[DENY] 
X-Xss-Protection:[1; mode=block]] 0x400045abc0 144589824 [] false false map[] 0x400051e800 }+
2021-03-03 08:35:47 +0000 UTC info: State transition: update-fetch [Download_Enter] -> update-store [Download_Enter]
2021-03-03 08:35:47 +0000 UTC debug: received the GET_AUTH_TOKEN action
2021-03-03 08:35:47 +0000 UTC debug: Handling update install state
2021-03-03 08:35:47 +0000 UTC debug: received the GET_AUTH_TOKEN action
2021-03-03 08:35:47 +0000 UTC debug: Connecting to server docker.mender.io
2021-03-03 08:35:47 +0000 UTC debug: Status reported, response 204 No Content
2021-03-03 08:35:47 +0000 UTC debug: Reading data from the device manifest file: /var/lib/mender/device_type
2021-03-03 08:35:47 +0000 UTC debug: device_type=dm1
2021-03-03 08:35:47 +0000 UTC debug: Current manifest data: dm1
2021-03-03 08:35:47 +0000 UTC info: No public key was provided for authenticating the artifact
2021-03-03 08:35:47 +0000 UTC debug: Checking if device [dm1] is on compatible device list: [dm1]
2021-03-03 08:35:47 +0000 UTC debug: Installer: Successfully read artifact [name: system-d1; version: 3; compatible devices: [dm1]]
2021-03-03 08:35:47 +0000 UTC error: Artifact install failed: Payload: can not install Payload: rootfs.tmp214618134: No match between boot and root partitions.: exec: "fw_printenv": executable file not found in $PATH
2021-03-03 08:35:47 +0000 UTC info: State transition: update-store [Download_Enter] -> cleanup [Error]
2021-03-03 08:35:47 +0000 UTC debug: Transitioning to error state
2021-03-03 08:35:47 +0000 UTC debug: statescript: The timeout for executing scripts is not defined; using default of 1h0m0s seconds
2021-03-03 08:35:47 +0000 UTC debug: statescript: The timeout for executing scripts is not defined; using default of 1h0m0s seconds
2021-03-03 08:35:47 +0000 UTC debug: Handling Cleanup state
2021-03-03 08:35:47 +0000 UTC info: State transition: cleanup [Error] -> update-status-report [none]
2021-03-03 08:35:47 +0000 UTC debug: statescript: The timeout for executing scripts is not defined; using default of 1h0m0s seconds
2021-03-03 08:35:47 +0000 UTC debug: Handling update status report state
2021-03-03 08:35:47 +0000 UTC debug: received the GET_AUTH_TOKEN action
2021-03-03 08:35:47 +0000 UTC debug: Connecting to server docker.mender.io
2021-03-03 08:35:47 +0000 UTC debug: Status reported, response 204 No Content
2021-03-03 08:35:47 +0000 UTC debug: Attempting to upload deployment logs for failed update
因為 mender client hard coding env tool : fw_printenv

Custom Update Module

除了寫死,固定的 dual-rootfs 更新,其他的更新都是在這裡。
讓你自由的(?)做出更新任何東西(bootloader, deb install, files, directory ..)

document source:

回到 rootfs 更新..
device 端手動執行 mender daemon,看 log..
deploy,, 進行 download ...
INFO[0934] Correct request for getting image from: 
https://s3.docker.mender.io:9000/mender-artifact-storage/127a8a88-ada3-4a7a-9212-c16a376db1cc?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=minio%2F20210303%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210303T033619Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&response-content-type=application%2Fvnd.mender-artifact&X-Amz-Signature=88d79-- [name: system-v2; devices: [raspberrypi3]] 
INFO[0934] State transition: update-check [Sync] -> update-fetch [Download_Enter] 
INFO[0934] Running Mender client version: 2.5.0         
INFO[0934] State transition: update-fetch [Download_Enter] -> update-store [Download_Enter] 
INFO[0934] No public key was provided for authenticating the artifact 
INFO[0934] Opening device "/dev/mmcblk0p2" for writing  
INFO[0934] Native sector size of block device /dev/mmcblk0p2 is 512 bytes. Mender will write in chunks of 1048576 bytes 

沒有留言:

張貼留言