Change hostname, harder than anticipated

ohgoditsgoingtobreak

Active member
Jun 6, 2011
40
0
0
Visit site
Why: the learning experience, and a name that is easier on the eyes.
I've been trying all day to discover how Android designates its hostname, (the name it has on a network). By default it is "ANDROID_<16 digit hexdecimal id>", and on all other Linux systems it is set in /system/etc/hosts. However that file on Android seems to not define the #HOSTNAME. I've been poking and prodding at any file that can be viewed in a text editor, and have not been able to find what I'm looking for. I've done close to a hundred searches and have found nothing about what to modify. Is there something simple I'm overlooking? Can #HOSTNAME="nameofchoice" just be added to the hosts file?

Sidenote; We all know by now that I'm a droidnoob, so ill say it now so you don't have to.

Thanks for your time!
 

ohgoditsgoingtobreak

Active member
Jun 6, 2011
40
0
0
Visit site

Hmm, this doesn't seem to work... here's what I did
Code:
mount -o remount,rw -t yaffs2 /proc /proc

echo ANDROID_EA102D43416E041D > newname /proc/sys/kernel/hostname
Which yields the error "cannot create newame: read only filesystem". I also tried

Code:
mount -o remount,rw -t yaffs2 /proc /proc

echo newname > /proc/sys/kernel/hostname
.
Which yields no response from the terminal, hostname stays the same, and the hostname files contents do not change. I tried making a copy of the file, editing it manually, and then moving it in place of the old, which stuck until reboot, but never changed the hostname.
Am I misunderstanding the syntax? or the procedure entirely?
 

watskyhotsky

Well-known member
May 26, 2011
899
115
0
Visit site
I just gave you a link from a google search. little bit nicer than a "Let me google that for you" link haha

should be possible, others have clearly done it. keep digging
 
Feb 19, 2011
1,971
284
0
Visit site
Hmm, this doesn't seem to work... here's what I did
Code:
mount -o remount,rw -t yaffs2 /proc /proc

echo ANDROID_EA102D43416E041D > newname /proc/sys/kernel/hostname
Which yields the error "cannot create newame: read only filesystem". I also tried

Code:
mount -o remount,rw -t yaffs2 /proc /proc

echo newname > /proc/sys/kernel/hostname
.
Which yields no response from the terminal, hostname stays the same, and the hostname files contents do not change. I tried making a copy of the file, editing it manually, and then moving it in place of the old, which stuck until reboot, but never changed the hostname.
Am I misunderstanding the syntax? or the procedure entirely?

the mount command is wrong.
instead, use
Code:
mount -o remount,rw -t proc /proc /proc
and you might want to
Code:
cat /proc/sys/kernel/hostname
to see what it is currently. mine is 'localhost'
 

sblood86

Well-known member
Apr 12, 2011
426
103
0
Visit site
Hmm, this doesn't seem to work... here's what I did
Code:
mount -o remount,rw -t yaffs2 /proc /proc

echo ANDROID_EA102D43416E041D > newname /proc/sys/kernel/hostname
Which yields the error "cannot create newame: read only filesystem". I also tried

Code:
mount -o remount,rw -t yaffs2 /proc /proc

echo newname > /proc/sys/kernel/hostname
.
Which yields no response from the terminal, hostname stays the same, and the hostname files contents do not change. I tried making a copy of the file, editing it manually, and then moving it in place of the old, which stuck until reboot, but never changed the hostname.
Am I misunderstanding the syntax? or the procedure entirely?

Everything found under /proc is part of a virtual file system; the easiest way to change these is an init.d script so that it applies on boot, that's what the xda post is suggesting.

Write a script in notepad++ or gedit or similar (NOT notepad), something along the following lines

Code:
#!/system/bin/sh
#

echo CellPhoneHostName > /proc/sys/kernel/hostname

where CellPhoneHostName is the name you want applied.

save it with no extension something like: 88hostname
the number in the name refers to the order at which the scripts are executed on boot up, 1 being first, 99 being last. Most custom roms will have other init.d scripts setup so before you save it make sure the number you are using doesn't exist on your current rom. Just look in /system/etc/init.d/
usually there's just a few scripts in there.

Once you have your script written you will need to copy it to the /system/etc/init.d/ directory
than set the permission, could do it in a terminal, or an adb shell
chown 077 /system/etc/init.d/88hostname

substitute 88hostname for whatever you named your script.

I havn't ever tried to rename the network name on a phone, and I havn't tested this method; the file in question does exist, and the above script will successfully change it. Whether it will yield the correct results I'm not sure. Too lazy to check myself :D

Good luck

Edit: You didn't say what rom this was. Init.d scripting is not supported in stock.
Edit2: Haha, I must have been half asleep when I wrote this, for anyone trying to do that, the permissions would be chown 0777... Seems I missed 1, sorry lol
 
Last edited:

Eollie

Well-known member
Feb 22, 2011
1,534
258
0
Visit site
If you are using asopCM7 you can edit it by hitting settings>applications> development and then scrolling to the bottom clicking on Device hostname.
 

Forum statistics

Threads
943,140
Messages
6,917,473
Members
3,158,836
Latest member
Robbyworkman1995