How to mount local image [src]
The problem is that the .img files are not images of a partition, but of a whole disk. That means they start with a boot loader and a partition table. You have to find out the offset of the partition and mount it with the offset option of mount. If you do a
fdisk -l /path/to/imageit will show you the block-size and the start-block of the partition. You can use that to calculate the offset. For example, I have an image of a bootable stick with a 4GB FAT32 partition. The output of the fdisk command is
Disk Stick.img: 3984 MB, 3984588800 bytes
249 heads, 6 sectors/track, 5209 cylinders, total 7782400 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
Disk identifier: 0x0004bfaa
Device Boot Start End Blocks Id System
Stick.img1 * 128 8015999 4007936 b W95 FAT32So I have a block-size of 512 bytes and the start-block is 128. The offset is 512 * 128 = 65536. So the mount command would be
mount -o loop,offset=65536 Stick.img /mnt/tmpModify the image to allow boot from usb [src]
Then enable USB boot mode with this code:
echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txtThis adds program_usb_boot_mode=1 to the end of /boot/config.txt. Reboot
the Raspberry Pi with sudo reboot, then check that the OTP has been programmed
with:
$ vcgencmd otp_dump | grep 17:
17:3020000aCheck that the output 0x3020000a is shown. If it is not, then the OTP bit has
not been successfully programmed. In this case, go through the programming
procedure again. If the bit is still not set, this may indicate a fault in the
Pi hardware itself.
If you wish, you can remove the program_usb_boot_mode line from config.txt,
so that if you put the SD card in another Raspberry Pi, it won't program USB
boot mode. Make sure there is no blank line at the end of config.txt.
You can edit config.txt using the nano editor using the command
sudo nano /boot/config.txt, for example.
Enable ssh to raspbian image [src]
Then
# place file on boot partition
touch /mnt/boot/sshFinally umount the image
umount /mnt/bootdefault user: pi default pass: raspberry
Modify hostname to raspbian image [src]
Modify /mnt/fs/etc/hostname, /mnt/fs/etc/host by replacing raspberrypi
with the desired hostname. Finally umount the image
umount /mnt/fsEnable network to raspbian image [src]
Modify /mnt/fs/etc/network/interfaces as follows
source-directory /etc/network/interfaces.d
auto eth0
iface eth0 inet dhcp
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.confThen create a /mnt/fs/etc/wpa_supplicant/wpa_supplicant.conf with the
following content to connect to a common WPA2 wifi network:
country=IT
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
ap_scan=1
network={
ssid="myssid"
psk="mypasskey"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
}Installing docker [src]
Requirements:
sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y
sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -Add the repository by adding the following line to /etc/apt/source.list
deb [arch=armhf] https://download.docker.com/linux/debian stretch stableUpdate the repos:
sudo apt-get updateThen install docker:
sudo apt-get install docker-ce docker-ce-cli containerd.iosudo usermod -aG docker $USERsudo systemctl enable dockerRun the following command:
sudo systemctl edit docker.serviceThe add those lines:
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375Then restart the daemon:
sudo systemctl daemon-reload
sudo systemctl restart docker.serviceCheck:
sudo netstat -lntp | grep dockerd