I'm trying to restore a backup made using this tutorial from a live Raspberry PI (with Noobs) to an external SD Card.
From there I made an image of the card on my linux box,
sudo dd if=/dev/sdc of=~/vm/rpBackup.img bs=1M
I booted with
sd.img which I found in this other tutorial and also attached the image using this command:
$ sudo qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" -hda sd.img -hdb rpBackup.img
Once it was booted I mounted the vfat partition as well as the ext4 partition from the backup image, and changed them in accordance with the documentation in the first tutorial:
(NOOBs Users: If you are running a SD card created with NOOBs, you will need to manually modify the boot/cmdline.txt and etc/fstab files on your new SD card before you can boot.
You must edit and substitute the mmcblk0p* device names for the proper ones. In the fstab, slash (/) should be /dev/mmcblk0p and /boot should be /dev/mmcblk0p1.
proc /proc proc defaults 0 0 proc /proc proc defaults 0 0 /dev/mmcblk0p1 /boot vfat defaults 0 2 /dev/mmcblk0p / ext4 defaults,noatime 0 1 # a swapfile is not a swap partition, so no using swapon|off from here on, use dphys-swapfile swap[on|off] for that
In the cmdline.txt file, root= part should be root=/dev/mmcblk0p2. Once you have done that the OS that you backed up will be the only OS on the new SD card event if your NOOBs SD had multiple flavors of raspberry pi OS installed. My scripts on github discussed in the next section handle all of this automatically, which makes things a bit easier.)
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
Next, I tried to boot from the backup image in the emulator by running the following command
$ sudo qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=5000 rootfstype=ext4 rw" -hda rpBackup.img
and it stops here:
I'm not entirely certain what the correct numbers are for the
/dev/mmcblk0p* entries. How do I find out what they are so that I can boot my image in qemu?
I finally got the machine to boot in qemu using the following command (from this tutorial):
sudo qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=100 rootfstype=ext4 rw init=/bin/bash" -hda ./rpBackup.img
I think the source of the issue was that no init parameter was specified in the command.