1. ohgoditsgoingtobreak's Avatar
    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!
    06-28-2011 06:55 PM
  2. watskyhotsky's Avatar
    06-28-2011 07:00 PM
  3. ohgoditsgoingtobreak's Avatar
    O.o I'm not sure how I missed this... Thank you much, Watskyhotsky
    06-28-2011 07:12 PM
  4. ohgoditsgoingtobreak's Avatar
    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?
    06-28-2011 08:34 PM
  5. watskyhotsky's Avatar
    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
    06-28-2011 08:58 PM
  6. bigsupersquid's Avatar
    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'
    06-28-2011 11:52 PM
  7. sblood86's Avatar
    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

    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
    06-29-2011 01:07 AM
  8. Eollie's Avatar
    If you are using asopCM7 you can edit it by hitting settings>applications> development and then scrolling to the bottom clicking on Device hostname.
    07-01-2011 12:00 PM
  9. watskyhotsky's Avatar
    If you are using asopCM7 you can edit it by hitting settings>applications> development and then scrolling to the bottom clicking on Device hostname.
    hahahaha this is beautiful!!!
    07-01-2011 05:30 PM
LINK TO POST COPIED TO CLIPBOARD