How can I add a script to the image to run at boot before popping the card into the Raspberry Pi? I can access the SD card in Ubuntu but not sure how to find /etc/init.d. The picture shows diskutil -l but I'm not sure which partition to mount.
sda isn't the SD card, it's the storage allocated for the VM. Even it you do find
/etc/init.d there, don't bother, it's the wrong one. This storage appears to be arranged so that it can have more than four partitions, which is why you have 1, 2, and 5. DOS style partition tables have a maximum of four primary partitions. To increase that, you can use a special "extended" partition, that can contain more "logical" partitions.
The extended partition doesn't itself contain a filesystem. The reason it's required is a DOS style MBR is only 512 bytes, which only has room for information about 4 partitions. An extended partition is just an extra table for information about more, but it has to be somewhere other than the MBR itself (which is the first sector of the device), and its allocated space incorporates the logical partitions within it. There is more information about this stuff in that wikipedia article. Anyway, so
sda5 is a logical partition that occupies all of
sda2. This might seem a bit silly, and perhaps it is in this case, but it is sort of like the difference between 6 and 3+3 ;) It's marked as swap, meaning it is for use if RAM allocated to the VM is all used up. Probably you don't need it and it was set this way when the VM was, but no big deal for now.
More to the point...
You may not have access to the SD card from the VM. To check, look at
ls -1 /dev/sd* before you insert it, and afterward. If they are the same, then you need to arrange for the VM to have access to external storage devices.
If they are different, you should now know which device the SD card is.
fdisk -l on that device (e.g.,
sdb) should look like this:
Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 8192 172031 163840 80M c W95 FAT32 (LBA) /dev/mmcblk0p2 172032 30318591 30146560 14.4G 83 Linux
The size of the second partition may be different, but note:
- The offset of the first partition is 8192. This is an SD card related thing.
- The first partition is very small (only 80M; the default on Raspbian currently is I think actually 60M) and FAT32. This is the boot partition. Everything can read FAT32, so it may be the only one that actually shows up under OSX
- The second partition is Linux. This is the root filesystem where you will find the
The first partition is a requirement for a Pi based card, so if you see anything where it isn't a little FAT32 (or VFAT) partition, it is not a Pi SD card.
This can easily be done with my Nard SDK distro. If the script
exist it will be run on boot and then become deleted.