本文首發 nagle.cn
snap core 學習交流微信羣(微信羣二維碼易過期,加微信號:mirco1101 )
csdn 上未排版,如果亂碼請查看最新: 個人筆記
零、前言
創建自己的ubuntu core image 鏡像是通過從snap store 拉取官方的 core snap(core 16)、 kernel snap(pc-kernel)、 gadget snap(pc)
https://tutorials.ubuntu.com/tutorial/create-your-own-core-image#0
一、安裝相應工具
sudo apt install ubuntu-image snapd snapcraft
ubuntu-image --help
snap list
snap info pc
snap info pc-kernel
snap info core
二、創建你自己的簽名密鑰( signature keys)
1、創建
snap create-key your-key-name
並設置密鑰對應的密碼
說明:your-key-name 可以不用加
2、列出創建的密鑰
sudo snapcraft list-keys
3、上傳你創建的signature keys到 snap store
snapcraft register-key
輸入你的 ubuntu one 帳號對應註冊郵箱和帳號密碼 。關於如何註冊請ubuntu one 帳號,請google。
上傳signature keys成功後會看到如下圖:
三、製作 model assertion
model assertion是根據一個json文件生成,json文件中寫明model assertion的各項配置,然後通過snap命令生成model assertion。
1、製作json 文件:
myadm64-model.json
{ "type": "model", //在代表assertion的類型,這裏製作的是model assertion,故必須爲 model "series": "16", //代表 ubuntu core系列,這裏用的是 core16 "model": "myamddev", //目標設備的名字,最好是小寫 "architecture": "amd64", //處理器架構 "gadget": "pc", //從snap store 拉取的gadget snap名稱, "kernel": "pc-linux", //從snap store 拉取的kernel snap名稱,
"required-snaps": ["hello", "hello-world"], //從snap store 拉取snap app,預裝在image中 "authority-id": "xxxxxx", // ubuntu one 帳號中的account ID "brand-id": "xxxxxx", // ubuntu one 帳號中的account ID "timestamp": "xxxxxx" //通過 date -Iseconds --utc 命令產生。 }
2、生成 model assertion文件
cat myadm64-model.json | snap sign -k my-key-name > myadm64.model
需要輸入上面步驟中設置的signature keys密碼。
四、生產 ubuntu core image
sudo ubuntu-image -o myadm64.img -c beta myadm64.model
五、寫入磁盤/usb/sd卡等
$ sudo dd if=myadm64.img of=/dev/sdXX bs=32M; sync;
snap core 學習交流微信羣(微信羣二維碼易過期,加微信號:mirco1101 )