pi@pi_horizon_emb:~ $ fdisk -lu /media/pi/41AB-0764/2016-03-18-raspbian-jessie-lite.img Disk /media/pi/41AB-0764/2016-03-18-raspbian-jessie-lite.img: 1.3 GiB, 1361051648 bytes, 2658304 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: 0x6f92008e Device Boot Start End Sectors Size Id Type /media/pi/41AB-0764/2016-03-18-raspbian-jessie-lite.img1 8192 131071 122880 60M c W95 FAT32 (LBA) /media/pi/41AB-0764/2016-03-18-raspbian-jessie-lite.img2 131072 2658303 2527232 1.2G 83 Linux
Note the block size and start location of the partition you wish to mount.
Then mount the partition within the image to a location of your choice on your local disk. Note you need to specify the offset, which is the start location * the block size.
pi@pi_horizon_emb:/ $ sudo mount -t auto -o loop,offset=$((131072*512)) /media/pi/41AB-0764/2016-03-18-raspbian-jessie-lite.img ~/iso_mount/ pi@pi_horizon_emb:/ $ ls ~/iso_mount/ bin boot dev etc home lib lost+found media mnt opt proc root run sbin srv sys tmp usr var pi@pi_horizon_emb:/ $
You can then modify the contents of the image partition. Note the partition size is restricted (it won't just expand as you add to it):
pi@pi_horizon_emb:/ $ df /home/pi/iso_mount
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/loop0 1210960 732164 399232 65% /home/pi/iso_mount
Great article! This post on mounting ISO images on Raspberry Pi was really helpful. For those interested in taking their Raspberry Pi projects further, you might also like this detailed guide on IoT Embedded Projects — it explains how IoT and embedded systems work together for real-world automation and smart device applications.
ReplyDelete