2021年1月10日日曜日

Docker memo

docker images             取得済みDockerイメージの一覧 

docker ps -a                 ローカル環境のDockerコンテナの一覧 

          -aは停止中のものも表示する。

docker run <image name>  ダウンロードと実行

docker pull <image name>  ダウンロード

docker rm <container name> コンテナの削除

docker stop <container name> コンテナの停止

docker exec -it  <container name> bash コンテナ内でbashの実行

docker commit <container name> <作成するimage name> Dockerイメージの作成

2021年1月6日水曜日

Ubuntu 20.04 Root on ZFS for Raspberry Pi

 OpenZFSにUbuntu on Raspberry PiのRootをSZFにする方法が記載されています。

SDカードで動作を確認できました。

USBの場合には、基本的な手順は同じですが、若干の差があります。

本家で指定されている、ディスクイメージは、USBデバイスでは、ブートできないので、Raspberry Pi ImagerでUSBストーレジにubuntu serverを書き込み、このデバイスをインストールimageとして使います。

あと/dev/mmcblk0を適宜/dev/sdx(xはaとかbとか環境により異なる)と読み替えると本家の手順どうりに行えます。

なお、eepromが、USBブートに対応していない場合は、ここを参照してください。



2021年1月1日金曜日

Raspberry Pi B4 USBブート

eepromのversionが2020-08-20以降のものは、USBブートが可能になっています。

Raspberry Pi imagerでかきこむOSを選び、SDカードを選ぶ画面を開くとUSBが選択できるので、書き込むめば、ブート用のUSBの完成です。


USBブートできない場合は、下記の方法でeepromを更新できます。

Raspberry Pi imagerでRaspberry Pi 4 boot recoveryを選びSDカードに書き込み

Raspberry Piで起動するだけ。


Misc utility imageを選ぶ

"Raspberry Pi 4 EEPROM boot recovery"を選ぶ

なお、Raspberry Pi  OSでapt full-upgradeでも最新eepromを最新に変更できる。


元ネタ

(2021.1.1)


2020年10月24日土曜日

The Go Programming Language


 公式サイト

公式tutorial getting started

自習場所

自習場所(日本語)


[memo]

外部からパッケージをインポートする場合は、

$ go mod init myprog.go

を実行すると (myprog.goは、外部パッケージをimportしているプログラム)

~/go/pkg/mod/

にダウンロードされる。

パッケージは、ここから検索できる。


外部から参照されるモジュールを作成する場合

モジュール用のデレクトリを作成しそこに移動する。

$ go mod init インポート名

インポート名は、importで参照する名前、ドメイン名/パッケージ名にする。

を実行しgo.modを作成する。

参照側は、自身のgo.modにreplace ドメイン名/パッケージ名 => 対象パス を追加する








2020年4月16日木曜日

FreeBSD kernel build

まずは、FreeBSD Handbookの8.5. Building and Installing a Custom Kernelを読む

#cd /usr/src
#make buildkernel KERNCONF=MYKERNE

詳しく知るには、
/usr/src/Makefileを読む。

その前に、Developers' HandbookのChapter 9. Building and Installing a FreeBSD Kernelを読む

#/usr/sbin/config MYKERNEL

続いて、config(8)を読む
man config

SYNOPSIS
     config [-CVgp] [-I path] [-d destdir] [-s srcdir] SYSTEM_NAME
     config [-x kernel]

     SYSTEM_NAME      Specify the name of the system configuration file
                      containing device specifications, configuration options
                      and other system parameters for one system
                      configuration.

MYKERNELは、SYSTEM_NAMEのことでシステムの構成を記述したファイル、
通常は、/sys/ARCH/confに存在する。(ARCHは、amd64)
configは、Makefileなどビルドに必要なファイルを作成する。
テンプレートが/sys/ARCH/confにある。テンプレートを修正してはいけない。
コピーして使う。
書き方は、config(5)に書かれている。

FILES
     /sys/conf/files                                         list of common files system is built from
     /sys/conf/Makefile.ARCH                                 generic makefile for the ARCH
     /sys/conf/files.ARCH                                    list of ARCH specific files
     /sys/ARCH/compile/SYSTEM_NAME   
                       default kernel  build directory for system  SYSTEM_NAME on ARCH

時間があれば、Building 4.4BSD Kernels with Configを読む。

config(5)によると
     device name [, name [...]]
     devices name [, name [...]]
             Configures the specified devices for inclusion into the kernel
             image.  Devices that are common to all architectures are defined
             in the file sys/conf/files.  Devices that are specific to
             architecture arch are defined in the file sys/conf/files.<arch>.


2020年4月5日日曜日

GNU Make 4.1 (1)

$ make --version
GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

makeは、versionが異なると細かい部分で異なるので注意が必要

make [OPTION]... [TARGET]...

makeは、makefileと呼ばれるファイルを読み込み、makefileに従い処理を行う。
makefileには、ビルドに必要な情報が書かれている。

makeを引数なしで実行すると
GNUmakefile, makefile, Makefileの順でファイルを探していく。
最初に見つかったファイルをmakefileとして処理する。

.dependがあれば読み込む。

$ make
make: *** No targets specified and no makefile found.  Stop.

$ touch GNUmakefile
$ make
make: *** No targets.  Stop.

$ echo hello: > makefile
$ make
make: *** No targets.  Stop.       # makefile でなくGNUmakefileが読み込まれる
$ cp makefile GNUmakefile 
$ make
make: Nothing to be done for 'hello'.

通常は、Makefileを使うことが推奨されている。
GNUmakefileは、GNU makeに限定される場合だけに使用する。

makeが上手く動作しない場合は、-dを付けて実行すると、原因がわかるかもしれない

概要   https://www.gnu.org/software/make/
マニュアルhttps://www.gnu.org/software/make/manual/
開発   http://savannah.gnu.org/projects/make/







2020年1月2日木曜日

ubuntu server インストール

ubuntu を使ってライブUSB を作ってインストールする方法

ここがインストールのチュートリアル。
https://tutorials.ubuntu.com/tutorial/tutorial-install-ubuntu-server?_ga=2.54415336.1168427040.1568425745-2077189292.1557957691#0

インストール用のUSBを作る。
ここがubuntuでの作成方法のチュートリアル。
https://tutorials.ubuntu.com/tutorial/tutorial-create-a-usb-stick-on-ubuntu#0

ここからISOイメージをダウンロードする。
https://ubuntu.com/download/server

‘Startup Disk Creator' を使ってusbメモリに書き込む。
 ddコマンドでも書き込める
lsblkでsdxをしらべ
dd bs=4M if=./image.usb of=/dev/sdX && sync

BIOSを設定して、USBから起動するようにする。

usbメモリを刺したまま起動する。

あとは、ガイドに従い操作する。

めも
BIOSをupdateしないとインストールできないことがある。