This is not so weird a problem. I'd like to configure a new Raspbian image and then read it back so that I can write the
configured image on other SD cards or back on the original card when I want to start over. So here is what you do:
Code: Select all
sudo dd if=raspbian-stretch-lite.img of=/dev/sde
(or whatever your card device is)
Mount both partitions of the SD card, let's say as /media/x/boot and /media/x/rootfs.
Code: Select all
sudo touch /media/x/boot/ssh
sudo nano /media/x/rootfs/etc/init.d/resize2fs_once
In the script resize2fs_once, write a new line "exit 0" directly below the # lines so that it will be the first line that's executed. Save the file.
Depending on your network setup, you might also want to copy a working conf to /media/x/rootfs/etc/wpa_supplicant/wpa_supplicant.conf if you use wifi to connect to your RaspberryPi.
Umount, place SD card in the RaspberryPi and boot it up. You can then ssh to it and log in as pi/raspberry to configure it.
Be aware that that's only possible in a local network. To be able to connect from the outside via ssh, you need to edit /etc/ssh/sshd_config after you have changed your password.
Anyway, use "sudo raspi-config" to configure your RaspberryPi and possibly generate new host keys for ssh.
If you want to have the image resized the next time the Raspberry boots, take the exit 0 line out of /etc/init.d/resize2fs_once. If not, leave it in.
Now it's time to read the image back to save it for later. The original image is 1862270976 bytes big. That's exactly 1776 MB.
Code: Select all
sudo umount /dev/sde?
sudo dd if=/dev/sde of=raspbian-date-configured.img bs=1048576 count=1776