Install openHABian image on Linux

Posted by ads' corner on Saturday, 2020-08-08
Posted in [Linux][Openhab][Operating-Systems]

My plan is to reinstall openHABian on a bigger SDcard, and on a Raspberry Pi 4. The latest release (v1.5) supports the new Pi 4, and I decided it’s time to do a fresh install, and see if all my Playbooks are still working.

As always, I’m searching my shell history for the right command how to install the image … but came up empty.

Raspberry Pi 4 with Sertronics Armor (cooling) Case
Raspberry Pi 4 with Sertronics Armor (cooling) Case

The disk

Let’s start by identifying the SDcard. I’m running Ubuntu on my laptop, and I can use tail -f /var/log/syslog to see the log output. When I plugin the SDcard into the reader, I see the following in the log:

Aug  8 12:41:59 diamond kernel: [4724028.476293] sd 1:0:0:0: [sdb] 62333952 512-byte logical blocks: (31.9 GB/29.7 GiB)
Aug  8 12:41:59 diamond kernel: [4724028.478668] sd 1:0:0:0: [sdb] Write Protect is off
Aug  8 12:41:59 diamond kernel: [4724028.478675] sd 1:0:0:0: [sdb] Mode Sense: 03 00 00 00
Aug  8 12:41:59 diamond kernel: [4724028.479262] sd 1:0:0:0: [sdb] No Caching mode page found
Aug  8 12:41:59 diamond kernel: [4724028.479271] sd 1:0:0:0: [sdb] Assuming drive cache: write through
Aug  8 12:41:59 diamond kernel: [4724028.496369] sd 1:0:0:2: [sdd] Attached SCSI removable disk
Aug  8 12:41:59 diamond kernel: [4724028.498039] sd 1:0:0:3: [sde] Attached SCSI removable disk
Aug  8 12:41:59 diamond kernel: [4724028.499797] sd 1:0:0:1: [sdc] Attached SCSI removable disk
Aug  8 12:41:59 diamond kernel: [4724028.514518]  sdb: sdb1
Aug  8 12:41:59 diamond kernel: [4724028.518822] sd 1:0:0:0: [sdb] Attached SCSI removable disk

It’s super important to identify the right disk. If you write the new image to the wrong disk, you will damage an existing filesystem. In my case the SDcard is /dev/sdb. This matches my setup, sdb is the second disk and sda is another disk which is present when the laptop is in the docking station. I can verify that sdb is indeed what I expect it to be, by using fdisk -l /dev/sdb to see the size and partitions:

Disk /dev/sdb: 29,74 GiB, 31914983424 bytes, 62333952 sectors
Disk model: SD/MMC
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
/dev/sdb1        8192 62333951 62325760 29,7G  c W95 FAT32 (LBA)

Brand new disk, it comes with FAT32 by default. The size is 29,74 GiB, which is about 32 GB.

openHABian

Next I need the current openHABian release, it’s available on the GitHub page. v1.5 in my case. Download the img.xz file, afterwards this file should be in your download folder:

-rw-rw-r--  1 ads ads 293348300 Aug  8 12:08 /tmp/openhabian-pi-raspbian-201908050414-gitca0976f-crc6a66b5a1.img.xz

The .xz ending shows that the download is using LZMA compression. Recent tar versions on Linux can handle this natively. Otherwise the xz-utils package can handle these kind of files.

Installation

Putting this all together, I’m using dd to write the uncompressed image to the SDcard. Uncompression happens on the fly, unxz is emitting the uncompressed image to STDOUT and dd is using this stream as input:

1
unxz < /tmp/openhabian-pi-raspbian-201908050414-gitca0976f-crc6a66b5a1.img.xz | dd bs=4M conv=fsync status=progress of=/dev/sdb

The status flag is not necessary, but shows a nice progress report. The fsync ensures that everything is written to disk before dd exits.

2193997824 bytes (2,2 GB, 2,0 GiB) copied, 70 s, 31,3 MB/s
0+235916 records in
0+235916 records out
2197815296 bytes (2,2 GB, 2,0 GiB) copied, 141,059 s, 15,6 MB/s

Time to boot the Raspberry Pi and look after the Playbooks …


Categories: [Linux] [Openhab] [Operating-Systems]