Tiny Core Linux
Tiny Core Base => TCB Q&A Forum => Topic started by: beerstein on February 27, 2011, 03:18:34 PM
-
Hi:
I changed the name "box" in /etc/hostname from "box" to "box2" and put the
hostname file into the /opt/.filetool.lst
After reboot hostname is still "box2"
but in my Terminal I still see tc@box instaed of tc@box2
How can I change that?
Thank you so much in advance
roberts edited title. Added: "when booting from CD"
-
Hi beerstein
I set up a script file in /opt for my file server to do this with the following commands.
#!/bin/sh
NEWNAME="BitBucket"
echo $NEWNAME > /etc/hostname
hostname -F /etc/hostname
cat > /etc/hosts <<EOT
127.0.0.1 $NEWNAME localhost
EOF
Don't forget to make it executable and add it to filetool.lst.
-
Or you can just append host=box2 as a boot option and let the init.d scripts set /etc/hosts and /etc/hostname for you automagically. ;)
-
thank you so much for your help. I will try it out.
In another post I have red that it is not necessary to change the "box" , but what do you think?
I have several machines running TC and they all have the name "box" but different IP addresses?
That may get a mess when I try to connect via host names. Is this correct?
Or does the name "box" in tc@box not affect the machine host-named "box2" which also has tc@box in its CL?
-
I've seen problems on a local network which automatically resolved local host names when more than one machine is called "box"
-
Hi:
Rich I tried your script and tried to test it from the CL - it worked and my tc@box changed to
tc@box2
BUT: After that I was not able to click on anything on my screen and could not backup.
The terminal was still working. So I put "box" back into the file hostname
did the following:
$ hostname -L /etc/hostname
so my old tc@box was back and with it all my applications .
BTW: On another PC where I have a frugal install I put host=box2 into the kernel line in menu.lst
And that is working.
But On the CD boot system I can not make this permanent - that way
Any suggestions?
Thank you and have a good day
-
Hi beerstein
I see I had a typo in my script, change EOT to EOF and see if that helps.
-
Hi Rich:
thank you for your last post. I tried several things and I could not change the hostname from tc@box
into tc@box2. here is my script:
#!/bin/sh
#original script EOT changed to EOF
NEWNAME="box2"
echo $NEWNAME > /etc/hostname
hostname -F /etc/hostname
cat > /etc/hosts << EOF
127.0.0.1 $NEWNAME localhost
EOF
I saved it as changeh.sh into /opt/changeh.sh
I changed ownership to: root/staff
and permissions to 100775
I added to /opt/.filetool.lst opt/changeh.sh
I also changed box into box2 in /etc/hosts and /etc/hostname and added these two files also
to the .filetool.lst so that they do not loose its content after backup and reboot.
When I start the script in /opt/changeh.sh manually the terminal idenifier changes from tc@box into tc@box2, but
then may appliactions freeze
-
Add the boot option "host=box2".
-
Hi gerald_clark: Thank you for this. Yes - on a frugal install and boot via grub I have
added this into the kernel line in menue.lst. Works fine.
I also can use the bootcode: tinycore host=box2 when booting from CD, but I would like to have it
built in so I can save this input everytime I boot.
It should work somehow. May be I have to put something into the bootlocal file?
-
@beerstein: Having a separate script (e.g. '/opt/changeh.sh') which does in fact a subset of the sethostname() function (in '/etc/init.d/tc-functions') might work for you, but only if this script is also called as part of the boot process. This probably should be done from '/opt/bootlocal.sh'. I'm not sure when reading your description that you've included such a call.
Whilst I agree with gerald_clark that probably the best (and easiest) way is to use a boot code I've just suggested (http://forum.tinycorelinux.net/index.php?topic=8985) an alternative. By enhancing in a minor way the Core functionality in this matter one would not need to rely on an additional script (which feels to me more like "re-inventing the wheel").
-
Hi beerstein
I execute the script by calling it from bootlocal.sh. The script sets up the hosts and hostname files
so adding them to the filetool.lst will cause a conflict, don't do that.
@maro: That's exactly where I got it from, minus the IPv6 stuff. I did it this way because I didn't want
to burn a new CD just to change the name of my file server. I agree that the boot code is the
preferred way when it's practical.
-
Hi there:
Yes - I tried that too: I put my script named /opt/changeh.sh into bootlocal and in addition
into /opt/.filetool.lst.
When I backed up and rebooted, my screen was black and a white mouse cursor (shaped like white + )
was sitting in the middle of the screen. I could move the cursor, but was not able to see a result from right- or left clicking the mouse. (dead)
So I used <CTRL> <ALT> F1 to switch to the command Line (CL)
Here I saw that my system was named: tc@box2
When I switched back using <CTRL> <ALT> F2 I still saw the black screen with the white cursor. So I went back to the command line using <CTRL> <ALT> F1 and started with startx - and all of the sudden I had my good old original TC screen back. (w-bar and everything worked) Even the terminal emulator now showed tc@box2.
But this procedure is not what I want.
Do you think I should remove the script from /opt/.filetool.lst ? and leve it only in /opt/bootlocal ?
I will play around in the meantime, but I am always scared that will get stuck and will not be able to backup in order to fix problems I have generated.
-
Hm, right, if you do that with a script it should go in bootsync. X may not like if the hostname changes from under it.
-
Hi there:
I put the script "changeh.sh" located in /opt into /opt/bootlocal.sh and removed it from /opt/.filetool.lst
Ouch this was bad thinking, because the script "changeh.sh" disappeared from the /opt/ folder due to the fact, that it was not listed in /opt/.filetool.lst any more. Now what?
So I left it in bootlocal.sh and put it back again into /opt/.filetool.lst.
After backup and reboot I see that black screen with the white mouse cursor in the middle. I can move the mouse cursor but no clicks recocnized.
Going to the command CL line and comming back using tc@box2~$startx I am in business and have what I wanted.
But I think there is a problem with X and or the WM.
I have no idea how to fix that. Can somebody please help me?
-
Put it into bootsync.sh instead of bootlocal.sh.
-
Hi beerstein
Actually, the problem is with my implementation. I just went out to the garage and turned on the monitor
on my file server and saw I have the same black screen with a white x for the cursor. I normally make
changes to the server using SSH via a terminal so I didn't notice the GUI wasn't coming up. Try curaga's
suggestion of moving the changeh.sh entry from bootlocal.sh to bootsync.sh. I can't test it for you since
my server is running version 2.10 and doesn't use bootsync.sh, so I'll have to figure out something else
if I want to fix it on my machine.
-
Put it into bootsync.sh instead of bootlocal.sh.
Hi curuga and Rich: Thank you so much for your help. The above did the trick. Now I have my system working and tc@box2 shows up where it is supposed to. I can recommend this modification to everybody using TC in a network with more than one TCs installed. As I previously said, booting from hd --> use the boot code in menue.lst, if you only boot once in a blue moon frm a live CD, use F2 and type: tinycore host=boxX for X=1...n
-
Hi there:
One more thing. The script works fine now, but I discovered something which want you to know.
Here is the script gain:
#!/bin/sh
#original script EOT changed to EOF
NEWNAME="box2"
echo $NEWNAME > /etc/hostname
hostname -F /etc/hostname
cat > /etc/hosts << EOF
127.0.0.1 $NEWNAME localhost
EOF
This script writes: 127.0.0.1 box2 localhost into /etc/hosts this way all modifications of the file hosts are lost after reboot. So if you use this script and have your other hosts (fixed IP) listed you must include the hosts into the script above.
example:
#!/bin/sh
#original script EOT changed to EOF
NEWNAME="box2"
echo $NEWNAME > /etc/hostname
hostname -F /etc/hostname
cat > /etc/hosts << EOF
127.0.0.1 $NEWNAME localhost
192.168.1.4 box1
192.168.1.5 box3
#..... and so on
EOF
While using a host name other than box I think I ran into some problems with cups.
printing from leafpad, mousepad, Gnumeric - error message in Leafpad is: "No application is registered as handling this file".
Printing works fine in Abyword, Office Writer and Geanny-editor.
-
Hi all:
with the new rc1 of TC3.6 robert made provisions to set the hostname in an easier way. Did somebody already make use of it and knows how to to it?
If yes, pleae share. Thank you so much
-
$ cat /opt/bootsync.sh
#!/bin/sh
# put other system startup commands here, the boot process will wait until they complete.
# Use bootlocal.sh for system startup commands that can run in the background
# and therefore not slow down the boot process.
/usr/bin/sethostname doublewide
/opt/bootlocal.sh &
Note: Using boot parameter takes precedence.
-
thank you roberts:
I hope I got that right.
So when I boot the first time via CD/DVD and have tce=hda1
I use the bootcode for hostname=newbox2
After that this new hostname is fixed and stays in /etc/hostname?
-
No.
Roberts showed you the /opt/bootsync.sh file with the required sethostname line added.
-
Thank You:
Using a boot CD, I just booted with /tce in hda1 and then I modified the line in /opt/bootsync.sh file into:
/usr/bin/sethostname box7
After reboot the system carries the new hostname: box7