Saturday, February 9, 2019

Mount Raspbian file systems

I needed to "inject" a first-boot script into the Raspbian image so I needed to "crack open" the .img file in order to add something to /etc/init/rc.local. I came across this article on how to do it: https://raspberrypi.stackexchange.com/questions/13137/how-can-i-mount-a-raspberry-pi-linux-distro-image

Here are the offsets and commands to mount up the Raspbian 2018-11-13 image:


fdisk -l 2018-11-13-raspbian-stretch.img

Disk 2018-11-13-raspbian-stretch.img: 3405 MB, 3405774848 bytes, 6651904 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 label type: dos
Disk identifier: 0x025ce4e3

                          Device Boot      Start         End      Blocks   Id  System
2018-11-13-raspbian-stretch.img1            8192       98045       44927    c  W95 FAT32 (LBA)
2018-11-13-raspbian-stretch.img2           98304     6651903     3276800   83  Linux


512 * 8192 = 4194304
512 * 98304 = 50331648

mkdir /mnt/img
mkdir /mnt/img/one
mkdir /mnt/img/two

mount -v -o offset=4194304 -t vfat 2018-11-13-raspbian-stretch.img /mnt/img/one
mount -v -o offset=50331648 -t ext4 2018-11-13-raspbian-stretch.img /mnt/img/two

Current Audible Reading List

Title You Never Forget Your First: A Biography of George Washington A Self-Made Man: The Politica...