On 20120227_131327, Jason Heeris wrote: > I have an image of a Debian Squeeze system that I want to put onto > multiple systems (flash-based disks for a single-board computer). I'd > like each system to have a different hostname, but have that hostname > persist across subsequent reboots. > > My first thought was that I could remove "/etc/hostname" from the > image, and modify /etc/init.d/hostname.sh to something like: > > do_start () { > if [ ! -f /etc/hostname ]; then > RANDOM_MAGIC="$(cat /dev/urandom | tr -dc '0-9A-Z' | head -c 6)" > echo "prefix-${RANDOM_MAGIC}" > /etc/hostname > fi > > HOSTNAME="$(cat /etc/hostname)" > > [ "$VERBOSE" != no ] && log_action_begin_msg "Setting hostname > to '$HOSTNAME'" > hostname "$HOSTNAME" > ES=$? > [ "$VERBOSE" != no ] && log_action_end_msg $ES > exit $ES > } > > Then, upon the first boot AFTER imaging, this script would see that > there's no /etc/hostname, generate one, write the new value to the > file and I'd be done. > > The problem is that the root FS is not mounted writeable at this stage > of the boot process! Is there another point in the rcS.d script > sequence where I can persist the current hostname? After > S10mountall.sh? Or is there a better way to achieve this that I'm > missing? > > — Jason > > > -- > To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org > with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org > Archive: > http://lists.debian.org/CA+Zd3FeXx7CRzXHM6ozpOMUdkQvxi2-=2zmhxxr5oht8nel...@mail.gmail.com >
I've been lurking, hoping to learn. Maybe I don't fully understand, but --- Wouldn't you be better off using the MAC address of the interface chip in each computer rather than a random number. The MAC address is supposed to be unique. I know it can be changed in software, but the value stored in ROM should be adequate for your purpose. If the above is acceptable, then the test for whether the boot image has been properly editted or not should be whether or not the image agrees with the ifconfig eth0 output as to the value of the MAC address. And keep in mind that you might want to do the change as a too step process. First do edits that get the computer bootable with a strictly temporary hostname, then when booting with that temporary name, edit and reboot with a more permanent and convenient name for the follow-on use/processing of the individual computer. But --- maybe I misunderstand totally the nature of your problem, in which case sorry for the noise. -- Paul E Condon pecon...@mesanetworks.net -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20120227185938.ga2...@big.lan.gnu