Raspberry Pi notes : Emulating Jessie image with 4.1.7 kernel

To emulate Jessie image with 4.1.7 kernel in this repo, steps differ slightly compared to a lot of (and standard) wheezy emulating guides on the internet.

In order to prepare your image for the first time, you will need a linux box (or any other OS that can mount an ext4 file from a .img file.)

I’m assuming that you have,

1. Latest jessie image

2. 4.1.7 qemu-kernel for versatilepb.

Steps :

fdisk -l <image-file>. It should show output like this one :

Disk 2015-11-21-raspbian-jessie.img: 3.7 GiB, 3934257152 bytes, 7684096 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: 0xea0e7380

Device                          Boot  Start     End Sectors  Size Id Type
2015-11-21-raspbian-jessie.img1        8192  131071  122880   60M  c W95 FAT32 (LBA)
2015-11-21-raspbian-jessie.img2      131072 7684095 7553024  3.6G 83 Linux

The filesystem (.img2) starts at sector 131072, which equals 512 * 131072 = 67108864 bytes. Use this as the offset, ie. mount -v -o offset=67108864 -t ext4 your-image-file.img /path/to/mnt/

  1. mount -v -o offset=67108864 -t ext4 /path/to/mnt/
  2. cd /path/to/mnt
  3. nano ./etc/ld.so.preload
  4. Comment out every entry in it, ctrl + x –> Y to save and exit.
  5. nano ./etc/fstab
  6. Comment out entries containing /dev/mmcblk, ctrl + x –> Y to save and exit.
  7. cd ~
  8. unmount /path/to/mnt

Once done with this changes, you can emulate it on Qemu by, qemu-system-arm -kernel kernel-qemu-4.1.7-jessie -cpu arm1176 -m 256 -M versatilepb -serial stdio -append "root=/dev/sda2 rootfstype=ext4 rw" -hda <image-file-name.img>

Hope it helps.

12 thoughts on “Raspberry Pi notes : Emulating Jessie image with 4.1.7 kernel

  1. Hi,dhruvvyas,

    What the qemu version you used ? i can’t even to mount the Jessie image in the first steps if i am using your kernel-qemu with currently Jessie

    the Qemu keep getting into rebooting looping or just stop in one second

    Could you please be more specific ?

    Many thanks!

    Cheers
    Leigh

    1. Hello Leigh,

      Sorry for late response. Kernel-qemu doesn’t work with jessie images. You might need to try a new kernel under my repo.

  2. well.. suggest you modify your blog

    mount -v -o offset-62914560 -t ext4 /path/to/mnt/

    this offset need to double check the img with the download

    1. Yes, I agree. Newer jessie images have different offset. I will modify it as soon as possible. Thanks for heads up. 🙂

  3. Note that we need to use the exact filename of the image file, with the “.img” extension. The +10G parameter will add 10 Gigabytes to the image, which should be more than enough.

Leave a Reply

Your email address will not be published. Required fields are marked *