Skip to content

Commit 8875e57

Browse files
PsCustomObjectPsCustomObject
authored andcommitted
Added new post
1 parent 6e47817 commit 8875e57

2 files changed

Lines changed: 69 additions & 0 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: "Write RaspBerry image to SD card via command line"
3+
excerpt: ""
4+
categories:
5+
- Linux
6+
- Azure
7+
8+
tags:
9+
- Linux
10+
- Lab
11+
12+
toc: true
13+
header:
14+
teaser: "/assets/images/Kubernetes_Logo.png"
15+
---
16+
17+
I am in the process of rebuilding my *Docker/Kubernetes* portable cluster which I build using a couple of RaspberryPi 4 and as part of this I needed to *reflash* the various SD cards where oeprating system for each node is installed.
18+
19+
Usually [Balena Etcher](https://www.balena.io/etcher/) is my goto tool for such endavors but being in a rush and not easy way to download the tool on my Linux box I simply used the good old command line, here is how this is done.
20+
21+
First of all we need to locate the device mapped to our SD card, in my case I'm using a microSD to USB adaapter, which can be done with the following command:
22+
23+
```bash
24+
sudo fdisk -l
25+
26+
Disk /dev/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
27+
Disk model: WDC WD1003FZEX-0
28+
Units: sectors of 1 * 512 = 512 bytes
29+
Sector size (logical/physical): 512 bytes / 4096 bytes
30+
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
31+
Disklabel type: dos
32+
Disk identifier: 0x806d3748
33+
34+
Device Boot Start End Sectors Size Id Type
35+
/dev/sda1 * 2048 1126399 1124352 549M 7 HPFS/NTFS/exFAT
36+
/dev/sda3 1024002048 1953519615 929517568 443.2G 7 HPFS/NTFS/exFAT
37+
38+
39+
Disk /dev/sdb: 465.76 GiB, 500107862016 bytes, 976773168 sectors
40+
Disk model: Samsung SSD 850
41+
Units: sectors of 1 * 512 = 512 bytes
42+
Sector size (logical/physical): 512 bytes / 512 bytes
43+
I/O size (minimum/optimal): 512 bytes / 512 bytes
44+
Disklabel type: dos
45+
Disk identifier: 0xde0a016a
46+
47+
Device Boot Start End Sectors Size Id Type
48+
/dev/sdb1 * 2048 2099199 2097152 1G 83 Linux
49+
/dev/sdb2 2099200 976773119 974673920 464.8G 83 Linux
50+
51+
<snip for brevity>
52+
53+
Device Boot Start End Sectors Size Id Type
54+
/dev/sdd1 * 2048 526335 524288 256M c W95 FAT32 (LBA)
55+
/dev/sdd2 526336 6819619 6293284 3G 83 Linux
56+
```
57+
58+
In my case the SD card is mapped to device **/dev/sdd**, once we have found the device to use the following command:
59+
60+
```bash
61+
xzcat ./ubuntu-21.04-preinstalled-server-arm64+raspi.img.xz | sudo dd bs=4M of=/dev/sdd conv=fsync
62+
0+425226 records in
63+
0+425226 records out
64+
3491662848 bytes (3.5 GB, 3.3 GiB) copied, 99.9634 s, 34.9 MB/s
65+
```
66+
67+
In the above example I used **Ubuntu Server 21.04** as the operating system with the image file being stored in the same path where the command is being run but the same can be used with any other image file.
68+
69+
I hope this can be useful and probably in the future I will post how to easily build a portable Docker/Kubernetes cluster lab.

assets/images/Kubernetes_Logo.png

24 KB
Loading

0 commit comments

Comments
 (0)