複数パーティーション情報を含むディスクイメージの作成からフォーマット,マウントまでのメモ

SD card などの実デバイスで作成して dd で書き出すという方法もありますが遅いし面倒なのでちょっと調べてみました.
以下は debian-jessie-raspberrypi.img というイメージファイルを 500MB の容量で作成し,fat と ext4 の2つのファイルシステムを作ってマウントするまでのメモです.

イメージの作成

% ionice -c 2 -n 0 dd if=/dev/zero of=./debian-jessie-raspberrypi.img bs=1M count=500

パーテションの作成(ここでは1つ目のプライマリパーティションに32Mのfat領域を,2つ目のプライマリパーティションに残り全ての容量でlinux領域を作成)

% /sbin/fdisk  ./debian-jessie-raspberrypi.img
 
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
 
 
Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-1023999, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-1023999, default 1023999): +32M
 
Created a new partition 1 of type 'Linux' and of size 32 MiB.
 
Command (m for help): t
Selected partition 1
Partition type (type L to list all types): e
Changed type of partition 'Linux' to 'W95 FAT16 (LBA)'.
 
Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2):
First sector (67584-1023999, default 67584):
Last sector, +sectors or +size{K,M,G,T,P} (67584-1023999, default 1023999):
 
Created a new partition 2 of type 'Linux' and of size 467 MiB.
 
Command (m for help): p
Disk ./debian-jessie-raspberrypi.img: 500 MiB, 524288000 bytes, 1024000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000
 
Device                           Boot Start     End Sectors  Size Id Type
./debian-jessie-raspberrypi.img1       2048   67583   65536   32M  e W95 FAT16 (LBA)
./debian-jessie-raspberrypi.img2      67584 1023999  956416  467M 83 Linux
 
Command (m for help): w
The partition table has been altered.
Syncing disks.
 

現在利用している loop デバイスを確認

% /sbin/losetup
NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE
/dev/loop0         0      0         1  1 /home/mk/Downloads/db410c_sd_install_ubuntu.img
/dev/loop1         0      0         0  1 /ubuntu/rootfs_1.img
/dev/loop2         0      0         0  1 /ubuntu/rootfs_2.img

オフセットを指定して loop デバイスに接続(上で確認したデバイスを避ける,オフセットはfdisk で確認できる開始セクタ /sbin/fdisk -l -u ./debian-jessie-raspberrypi.img で確認できる )

% sudo losetup -o2048 /dev/loop4 ./debian-jessie-raspberrypi.img
% sudo losetup -o67584 /dev/loop5 ./debian-jessie-raspberrypi.img

フォーマット

% sudo mkfs.fat /dev/loop4
mkfs.fat 3.0.28 (2015-05-16)
Loop device does not match a floppy size, using default hd params
% sudo mkfs.ext4 /dev/loop5
mke2fs 1.42.13 (17-May-2015)
Discarding device blocks: done
Creating filesystem with 511932 1k blocks and 128016 inodes
Filesystem UUID: b4d1c469-c057-4839-b412-86486f586d9b
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
 
Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
 

マウント

% sudo mount /dev/loop4 ./mnt/boot
% sudo mount /dev/loop5 ./mnt/rootfs
% mount |grep /dev/loop
/dev/loop4 on /var/tmp/debian_pi/mnt/boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=utf8,shortname=mixed,errors=remount-ro)
/dev/loop5 on /var/tmp/debian_pi/mnt/rootfs type ext4 (rw,relatime,data=ordered)

アンマウントと loop デバイスの切断

% sudo umount /dev/loop4 /dev/loop5
% sudo losetup -d /dev/loop4 /dev/loop5

Dragonboard 410c の購入メモ

<追記>
20151125にchip1stopからメールが届きました.出荷予定日が11/30から12/14になったそうです.それと EIAJ-3 で 24W な Dragonboard 410c に適合するACアダプタと,2.1mm から EIAJ-3 への変換プラグの取り扱いも始めたそうです.
TW-12020U TWシリーズ アイコー電子 アイコ― あいこー | パワーサプライ | ACアダプタ | AIKOH ELECTRONICS – チップワンストップ 電子部品半導体通販サイト
SSCI-025461 Speed United Electronics | パワーサプライ | 電源用アクセサリ | Speed United Electronics – チップワンストップ 電子部品半導体通販サイト
出荷が伸びたのは悲しいですが,ACアダプタと変換プラグは安いし良いのではないでしょうか.案内メールには注文後一括配送設定をすれば送料は掛からないとなっていますがうまく行きませんでした.これは問い合わせてみています…….(一括配送設定ボタンが出てこない) -> 注文時の条件で出ないことがあるようです.問い合わせして一括配送設定をしてもらえました :)
</追記>

DragonBoard-UpdatedImages-side
Dragonboard 410c という Snapdragon 410 開発ボードがあります.96Boards というマルチベンダーの ARM32/64 の開発ボードのシリーズの一つで Android/Ubuntu vivid ベースのOS やWindows 10 IoT Core に対応していて Wi-Fi/Bluetooth/GPS などが乗っているボードです.Raspberry Pi の倍くらいの値段だけどパワーはあるし,Wi-Fi/Bluetooth/GPS を後でのせることを考えると安いしちょっと欲しいなーと思っていたのですが,無線機器が付いているので日本国内で利用するにはいわゆる技適の問題があって面倒でした.このボードが国内でも技適取得済みで販売されることになりました.

16日に購入できるようになってその時300台ほどでしたが今日みても200台近く.ということは100台位しか捌けていない?
ということで Dragonboard 410c を買うのにちょっと調べたメモを残しておきます.

Raspberry Pi との大雑把な比較

Rasbperry Pi B+Raspberry Pi 2BDragonboard 410c
SoCBroadcom BCM2835Broadcom BCM2836Qualcomm SnapDragon 410
ARM versionARMv6ARMv7ARMv8
CPU700MHz 1Core900MHz 4Core1200MHz 4Core
RAM512MB1GB1GB
eMMC8GB(eMMC 4.51)
microSD1(Class10)1(Class10)1(UHS-I)
USB4(2.0)4(2.0)2(2.0)
Ethernet1(100Mb)1(100Mb)
Wi-FiIEEE 802.11 b/g/n 2.4GHz
Bluetooth4.1(BR/EDT + BLE)
GPSQualcomm WGR7640 GNSS(GLONASS+COMPASS)
GPIO4040LS40(UART, SPI, I2S, I2C x2, GPIO x12, DC power)
+ HS60(4L-MIPI DSI, USB, I2C x2, 2L+4L-MIPI CSI)
電源microUSB(5V 2A)microUSB(5V 2A)EIAJ-3(+6.5V to +18V 24W)

Dragonboard 410c の購入

技適の問題があるのでここから買うのが無難

電源

EIAJ-3 プラグ +6.5V to +18V
chip1stop の通販サイトによると24W 以上推奨

ハードウェアマニュアル v4.1 の該当部分

20151119_09:11:32-3233

96Boards の forum で紹介されていたもの

国内で探しても EIAJ3 はなかなか見当たらない.

一般的な 2.1mm のアダプタから変換するのがお手軽かもしれない.

その他便利そうなアクセサリ類

Raspberry Pi を使っている人なら揃っていそうですが,

Dragonboard 410c 関連ページ

Raspberry Pi をセロテープで修理する

Raspberry Pi 2 model B の microSD card slot のロックが壊れてしまい microSD を挿しても出てきてしまう状態になっていました.
新しいの欲しいなぁと思っていたのですが,値段を確認するとRS は \3,966(2015/02/02の値段) -> \4,900(今) と約1,000円値上がりしています.ちょっとつらい.
https://www.flickr.com/photos/119142834@N05/22624238729/in/dateposted-public/

microSD 刺さることは刺さるのでどうにか microSD を固定すればいけるのではと試しにセロテープ貼って固定したら動くようになりました.

https://www.flickr.com/photos/119142834@N05/23045475125/in/dateposted-public/
https://www.flickr.com/photos/119142834@N05/23056665281/in/dateposted-public/

暫くこれで様子見てみようかと思います.
+より前の旧型なら SD ソケット付け替えや増設出来そうなんですけど + 以降はmicroSD だし BGA ぽいしソケット入手出来ても辛そうですね.

ちなみに Androidの SIMやmicroSD ソケットを交換してくれる業者もあるようでお願いすれば修理いてくれそうですが,手数料と新品がそう変わらなくなりそうな感じです…….

追記)
ステープラー芯でロックできるというのも見かけて試してみました.

ターミナルで動作する Markdown Viewer terminal_markdown_viewer を試す

これは便利そう.ということで試してみました.

% git clone https://github.com/axiros/terminal_markdown_viewer.git
% terminal_markdown_viewer/mdv.py -h
Usage:
    mdv [-t THEME] [-T C_THEME] [-x] [-l] [-L] [-c COLS] [-f FROM] [-m] [-M DIR] [-H] [-A] [MDFILE]
 
Options:
    MDFILE    : Path to markdown file
    -t THEME  : Key within the color ansi_table.json. 'random' accepted.
    -T C_THEME: Theme for code highlight. If not set: Use THEME.
    -l        : Light background (not yet supported)
    -L        : Display links
    -x        : Do not try guess code lexer (guessing is a bit slow)
    -f FROM   : Display FROM given substring of the file.
    -m        : Monitor file for changes and redisplay FROM given substring
    -M DIR    : Monitor directory for markdown file changes
    -c COLS   : Fix columns to this (default: your terminal width)
    -A        : Strip all ansi (no colors then)
    -H        : Print html version
 
Notes:
 
    We use stty tool to derive terminal size.
 
    To use mdv.py as lib:
        Call the main function with markdown string at hand to get a
        formatted one back.
 
    FROM:
        FROM may contain max lines to display, seperated by colon.
        Example:
        -f 'Some Head:10' -> displays 10 lines after 'Some Head'
        If the substring is not found we set it to the *first* charactor of the
        file - resulting in output from the top (if you terminal height can be
        derived correctly through the stty cmd).
 
    File Monitor:
        If FROM is not found we display the whole file.
 
    Directory Monitor:
        We check only text file changes, monitoring their size.
 
        By default .md, .mdown, .markdown files are checked but you can change
        like -M 'mydir:py,c,md,' where the last empty substrings makes mdv also
        monitor any file w/o extension (like 'README').
 
        Running actions on changes:
        If you append to -M a '::<cmd>' we run the command on any change
        detected (sync, in foreground).
        The command can contain placeholders:
            _fp_    : Will be replaced with filepath
            _raw_   : Will be replaced with the base64 encoded raw content
                      of the file
            _pretty_: Will be replaced with the base64 encoded prettyfied output
 
        Like: mdv -M './mydocs:py,md::open "_fp_"'  which calls the open
        command with argument the path to the changed file.
 
 
    Theme rollers:
        mdv -T all:  All available code styles on the given file.
        mdv -t all:  All available md   styles on the given file.
                    If file is not given we use a short sample file.
 
        So to see all code hilite variations with a given theme:
            Say C_THEME = all and fix THEME
        Setting both to all will probably spin your beach ball, at least on OSX.
 
    Lastly: Using docopt, so this docstring is building the options checker.
    -> That's why this app can't currently use itself for showing the docu.
    Have to find a way to trick docopt to parse md ;-)

簡単に導入実行できていい感じです.
色付きのまま使えるページャーが欲しいのですがなにかいいものはないですかね…….
とりあえずは -A option で色無しで lv コマンドあたりに食わせています.

% terminal_markdown_viewer/mdv.py -A ~/Documents/pelican/content/1st_post.md |lv
 

asciicast

Termlnal で動作する Slack client の terminal-slack を試す

Termlnal で動作する Slack client の terminal-slack というものを見かけたので試してみました.

% git clone https://github.com/evanyeung/terminal-slack.git
% cd terminal-slack

"Slack Web API | Slack" で Token を入手して実行.

% SLACK_TOKEN=xxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx node main.js

https://www.flickr.com/photos/119142834@N05/22901628116/in/datetaken/

さくっと動作しましたが日本語は文字化けしてしまいます.残念.

追記)

Google+ で教えてもらったのですが,次のパッチで日本語が見られるようになりました.書き込みもOK でした :)

Dropbox の新機能のfile requests を試す

Dropbox に対不特定多数向けファイルアップロード機能が付いたということで試してみました。
(<br>タグが……)

ファイル非公開anonymous FTP の変りに使えるのかな?
てことで試しにURL 公開
Screenshot from 2015-06-18 09:30:57
Screenshot from 2015-06-18 09:31:15
Screenshot from 2015-06-18 09:31:26
Screenshot from 2015-06-18 09:40:35

https://www.dropbox.com/request/4mt4eOii9dJb3N5f0LsP

アップロードには氏名とメールアドレスが必要
適当でもよさそうだけど
Screenshot from 2015-06-18 09:43:28Screenshot from 2015-06-18 09:43:42
Screenshot from 2015-06-18 09:44:24
Screenshot from 2015-06-18 09:46:17

まだこなれてないようでWeb画面英語になったり日本語になったり
ファイルUp者へのメールは日本語で、共有元には英語だったりしました。

ファイル非公開anonymous FTP の様にファイル提出を不特定多数から受け取るのに良さそうです。容量制限などが設定出来るといいかもですね。(1ファイル1MB 迄とか.txt のみとか)

ケーブルの抜け防止に良さそうな製品

AVANTEC(アバンテック) | 電源、USB、HDMI等コネクタ、ケーブルの抜け防止製品のご紹介

サーバやスイッチなんかの電源なんかは抜け防止の金具が付いてますが,PCなんかだと付いてません.
電源だとサプライ品で見たことありましたがこちらの製品だとUSBやスマホなんかのmicroUSBなんかも対応するものがあるみたい.場合によっては便利そうです.
オンラインショップはあるようですが,Amazonとかでも売ってると便利そうです.

DuckDuckGo を日本語環境で使う

DuckDuckGo という検索エンジンがあります.検索エンジンといえばGoogle一強という感じですがその分プライバシーがGoogleに筒抜けだったり蓄積されたりするのが嫌かもしれません(その分その人に合う検索結果が帰ってくるはずですが).それに対してDuckDuckGo はユーザプロファイルを作らず誰に対しても同じキーワードから同じ検索結果を返します.
DuckDuckGo使いたいけど日本語の情報が出てこないから使い物にならないって人が居たので日本語の検索結果を表示する設定が知られて無さそうということで最近使っている設定をメモしておきます.

https://duckduckgo.com/?q=keyword&kp=-1&kl=jp-jp&kc=1&kf=-1&kh=1&k1=-1
この例だと以下のように日本語の検索結果を返すようになっています.

q=検索キーワード
kp=-1 セーフサーチ無効
kl=jp-jp 日本向けの検索結果
kc=1 自動先読み有効
kf=-1 サイトアイコン有効
kh=1 https有効
k1=-1 広告無効

ブックマークツールバーなどに以下を登録しておくといい感じです.
https://duckduckgo.com/?q=keyword&kp=-1&kl=jp-jp&kc=1&kf=-1&kh=1&k1=-1

常用するなら以下のように規定の検索エンジンを差し替えてしまうといいでしょう.
Screenshot from 2015-02-06 06:54:45
Screenshot from 2015-02-06 06:55:20
Screenshot from 2015-02-06 06:56:17

JessieでフォントがDejaVuになって困る

ある時からDebianJessieのあちこちのフォントが中華な感じに.

Screenshot from 2014-12-24 14:37:17Screenshot from 2014-12-24 14:36:28

確認すると DejaVu というフォントらしい.

LibO で設定を変えてみても恐らく和文フォントを設定されていないテンプレートを利用した時などに戻ってしまったり.Chromium で設定を変えみても反映されなかったりでした.
Screenshot from 2014-12-24 14:49:03Screenshot from 2014-12-24 15:06:24

とりあえずこのフォントは使わないなってことで消して対処療法….

% sudo apt purge fonts-dejavu fonts-dejavu-core fonts-dejavu-extra ttf-dejavu ttf-dejavu-core ttf-dejavu-extra

RaspberryPi B+ でUSB で1.2A を利用できるようにする(失敗)

“Raspberry Pi Model B+のUSBポートに1.2Aの電力を供給する – あっきぃ日誌” http://akkiesoft.hatenablog.jp/entry/20140727/1406443999

を見て /boot/config.txt 編集しないとB+ でUSB に1.2A の電力を供給できないことを知りました.
で,/boot/config.txt 規定値のまま,safe_mode_gpio=4 登録,max_usb_current=1登録.両方登録のパターンで試したんですがいずれもHDD スピンアップしませんでしたorz

電源はGPIO から河野総統謹製のラズベリーポット(ラズベリーハブの電源部分のみ+αのもの),microUSB からAnker の40W USB 電源の2パターンを試しました.
HDD はSeagate Momentus XT 500GB/4GB SSD付きハイブリッド7200rpm を500円位で秋葉原で売っていた適当なケースに入れたものです.5400rpmとかなら行けるのかなとか?

Y型のUSB cable を使って片方から給電したら動くのでHDD は問題なくRaspberryPi B+ からの電気が足りないせいなはず.ちなみにPC(Lenovo X220)だとUSB x1で動作します.

OS 色々いじってるので一旦初期状態にしてからまた試してみようかと思います.

IMG_20140730_080938