Results 1 to 9 of 9
  1. Thread Author  Thread Author    #1  

    Default Change hostname, harder than anticipated

    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!
    Read what I wrote, before you go for my throat.
  2. #2  

    Default Re: Change hostname, harder than anticipated

  3. Thread Author  Thread Author    #3  

    Default Re: Change hostname, harder than anticipated

    Quote Originally Posted by watskyhotsky View Post
    O.o I'm not sure how I missed this... Thank you much, Watskyhotsky
    Read what I wrote, before you go for my throat.
  4. Thread Author  Thread Author    #4  

    Default Re: Change hostname, harder than anticipated

    Quote Originally Posted by watskyhotsky View Post
    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?
    Read what I wrote, before you go for my throat.
  5. #5  

    Default Re: Change hostname, harder than anticipated

    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
  6. #6  
    bigsupersquid's Avatar
    o_O

    Posts
    1,418 Posts
    ROM
    OV KitKat-JBC, 3.0 kernel

    Default Re: Change hostname, harder than anticipated

    Quote Originally Posted by ohgoditsgoingtobreak View Post
    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'
    keep the wife happy with my dev time:
    donate!
    the THANKS button is quite acceptable if you're as stingy as me, too.
  7. #7  
    sblood86's Avatar

    Posts
    431 Posts
    ROM
    Quatrimus / CM10

    Default Re: Change hostname, harder than anticipated

    Quote Originally Posted by ohgoditsgoingtobreak View Post
    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
    Last edited by sblood86; 06-29-2011 at 11:25 PM.
  8. #8  
    Eollie's Avatar

    Posts
    1,566 Posts
    Global Posts
    1,575 Global Posts
    ROM
    Some arrogant a-holes

    Default Re: Change hostname, harder than anticipated

    If you are using asopCM7 you can edit it by hitting settings>applications> development and then scrolling to the bottom clicking on Device hostname.
  9. #9  

    Default Re: Change hostname, harder than anticipated

    Quote Originally Posted by Eollie View Post
    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!!!

Posting Permissions

B