Okay, from your comments on the other answer, it looks like you want to change the hostname of Raspberry Pi image without actually booting it. This should be trivial.
We want to modify the /etc/hostname in the second partition, so we will find its location in the image using fdisk.
fdisk -l image.img
Where image.img is your image file. Look under the start column for the second (Linux ext4) partition to find the block it starts on. Substitute that into the command below. Note that this won't change after this process, so you can change the hostname, send off the image, and then change it again, without needing to run fdisk and use a new value.
sudo mount -o loop,offset=$((TYPE_START_BLOCK_HERE*512)) image.img /mnt
nano /mnt/etc/hostname
Get rid of the default and type in the hostname you want, and then hit Ctrl-x, then y, and then enter. We can now unmount the image like this.
sudo umount /mnt
Done! Using dd to load the image onto the SD card and booting the card in a Pi will set the Pi's hostname to the one you specified above.
To automate this process and change the hostname of an image quickly between dd's, one could write a bash script:
#!/bin/bash
mkdir tst;
echo ${1:?"Set argument one to filename"} > /dev/null;
echo ${2:?"Set argument two to desired hostname"} > /dev/null;
mount -o loop,offset=$(($(fdisk -l $1 |awk '$7=="Linux"{print $2}')*512)) $1
tst;
echo $2 > tst/etc/hostname;
umount tst;
rmdir tst;
/etc/hostname
?sudo raspi-config
and selectAdvanced Options
->Hostname
to update your Pi's name./boot/bootsetup/hostname
, see more github.com/SloCompTech/rpi-boot-setup.