Tiny Core Linux
Tiny Core Base => TCB Q&A Forum => Topic started by: get2guy on November 30, 2014, 08:27:28 AM
-
Hi all,
What is the proper way of changing the hostname of tiny core?
Does the GUI has this option? or only command?
Thx
-
use the bootcode "host="
-
use the bootcode "host="
Sorry but i dont understand that. how can i use it?
I tried to press F2 or F3 or F4 after the bootloader menu (dual boot system) but nothing happens and the Tiny core starts normally.
What am i doing wrong?
-
Edit your bootloader menu.
-
Edit your bootloader menu.
Wish i would know whats the meaning
Can you refer me or explain a bit more on what should i do?
My bootloader is tiny core boot loader the only option i have there is TAB
-
You said you are dual booting. If that is true, you add a boot stanza to your boot loadre config file to boot Core.
Add the "host=myhost' boot option to the line containing the existing boot options.
-
get2guy please tell me which operating system you use means ubuntu and tinycore or windows and tinycore then i tell you step by step just tell me your OS name you are using.
-
Thanks but i managed to make it work by editing extlinux.conf
Just deleted the host=myhost after the first boot.
-
For a more indirect approach (needed here as I have a few dozen machines and I can't see editing boot codes for each) you have two primary options:
1) If you have the ability to set up DNS for yourself, set the computer's host name in DNS (preferably by MAC)
2) If DNS isn't an option, the following is all that's needed:
a) in /opt/bootsync.sh replace the line sethostname= with the preferred host name *preferred
or
b) add etc/hostname to /opt/.filetool.lst and edit /etc/hostname to suit (and remove the command in bootsync.sh accordingly)
-
Use the boot code host=myhost in the boot command line (extlinux.conf, grub.conf, etc etc..) and leave it there for tc-config to set the parameter every boot thereafter like all the other boot codes. see page 56 of the core book.
-
For a more indirect approach (needed here as I have a few dozen machines and I can't see editing boot codes for each) you have two primary options:
1) If you have the ability to set up DNS for yourself, set the computer's host name in DNS (preferably by MAC)
2) If DNS isn't an option, the following is all that's needed:
a) in /opt/bootsync.sh replace the line sethostname= with the preferred host name *preferred
or
b) add etc/hostname to /opt/.filetool.lst and edit /etc/hostname to suit (and remove the command in bootsync.sh accordingly)
Hi centralware,
I don't have quite so many machines to keep track of, but between the "homeschool computer lab" (all tiny core, all the time) and the data center at work (where some of the Windows servers may only ever need to boot other than into Windows once every few years) I've found that it's convenient to be able to boot many different boxes from the same boot system (on USB flash drives) by determining which host I'm on at boot time based upon the physical characteristics of the box.
Originally, I kept only a table of the UIDs of the filesystems on each actual hard disk in each machine and it worked like a charm... until I used it on a box where the hard drive had been removed.
Then I added a table of the mac addresses of each box's ethernet cards as the primary reference and the disk IDs remain as secondary identifier.
It's been on my todo list for a couple of years now to package up the script for submission to the repo, but every time I sit down to "clean it up once and for all" I end up adding some little feature or another instead. :) Below is an old'ish listing of the main script and below that some sample data. In bootsync.sh are lines like this:
WHATHOST=`/opt/bin/whathost`
/bin/hostname ${WHATHOST}
For basic host name setting, that's all you need. For more involved customizations, I have a subdirectory tree under
/opt/whathost/<hostname>
that contains, for instance, supplementary bootsync.sh and bootlocal.sh files for certain boxes. Of course, by the time bootsync.sh figures out what host we're on, it's too late to affect what extensions get loaded.
A future version will load the whathost script from an extension and run it from the extension's install script - which can then load additional extension lists (a la onboot.lst) customized for the host - so my web server can load apache and my file server can load samba and my worksation can load libreoffice, etc, etc and everybody can load openssh. At that point, the macdb and diskdb files and the per-host config file trees will live on boot media, probably alongside the grub menu file, so I can update them w/o having to actually boot each stick and w/o having to constantly rebuild the extension. Since extension loading happens before data is restored from backup, one could even maintain separate mydata.tgz files per host - though I have a slightly uneasy feeling about that idea.
#!/bin/sh
# whathost - determine on what physycal host we are running. lem 2010-06-13
# 2011-11-30 lem - added determination of physical host by MAC address of NIC
# 2012-09-11 lem - added override with "whathost=hostname" boot code.
getmac() {
ifconfig -a eth0 |grep -i hwaddr |while read REC ; do echo ${REC} |cut -d" " -f5 ; done
}
MACDB=/opt/whathost/macdb.txt
DISKDB=/opt/whathost/diskdb.txt
WHATHOST=""
. /etc/init.d/tc-functions
WHATHOST=`getbootparam whathost`
[ -n "${WHATHOST}" ] && echo ${WHATHOST}
if [ -z "${WHATHOST}" ] ; then {
# ID machine by eth0 MAC
if MAC=`getmac` ; then {
if REC=`grep ${MAC} ${MACDB}` ; then {
WHATHOST=`echo ${REC} |cut -d" " -f1`
} fi
[ -n "${WHATHOST}" ] && echo ${WHATHOST}
} fi
} fi
if [ -z "${WHATHOST}" ] ; then {
# ID machine by HD filesystems' UUIDs
blkid |grep -v loop |while read DISK ; do {
if [ -z "${WHATHOST}" ] ; then {
# get the UUID of the device...
VALQ="NONE"
PIECE=1
while [ "${VALQ}" != "UUID" ] ; do {
VALQVAL=`echo ${DISK} |cut -d" " -f${PIECE}`
VALQ=`echo ${VALQVAL} |cut -d"=" -f1`
VAL=`echo ${VALQVAL} |cut -d"=" -f2`
PIECE=`expr ${PIECE} + 1`
} done
# and look it up in the disks database
if REC=`grep ${VAL} ${DISKDB}` ; then {
WHATHOST=`echo ${REC} |cut -d" " -f1`
} fi
[ -n "${WHATHOST}" ] && echo ${WHATHOST}
} fi
} done
} fi
# database of mac addresses vs. host names for use by whathost.
D4600 00:0C:F1:D6:73:44
tigress 00:E0:4C:91:19:0C
cgs1501 00:19:89:68:4e:e0
neptune 00:13:20:47:E6:02
D4600 /dev/sda1: LABEL="D4600" UUID="7faa7183-0cd1-4677-b790-8d4a814a95a9" TYPE="ext2"
leepc /dev/sda1: UUID="B0B880D3B8809A0C" TYPE="ntfs"
leepc /dev/sda5: LABEL="SDA5" UUID="3C71-9C09" TYPE="vfat"
leepc /dev/sda6: UUID="c963ba63-ded9-432f-9d38-5c30e684d63c" TYPE="ext2"
neptune /dev/sda1: SEC_TYPE="msdos" LABEL="DellUtility" UUID="07D5-061B" TYPE="vfat"
neptune /dev/sda2: UUID="E6D42FD4D42FA5B1" TYPE="ntfs"
neptune /dev/sda5: UUID="DAE8BAF2E8BACC4F" TYPE="ntfs"
-
@Lee: Nice concept. You'll want to create an update system to allow the machine to update its MAC database from a central location without intervention otherwise it's a lot of manual input to add/edit/remove even a single machine in the list. The only real "flaw" I see with the implementation you have is... what if a given machine bites the dust? The MAC is no longer in service, thus you'll have to update (or ignore) the listings for that MAC everywhere else AND... you'll have to build a new TC pen for a new machine. The way we've put things together... we've made it to where if our headless DNS/DHCP/TFTP/NFS/etc. server were to die tomorrow, all that's needed is to pull the whopping 128MB Compact Flash card from that machine and stick it into another. ~30 seconds later, we're back up and running - the only differences being the two MAC addresses for the network ports; the network doesn't really know much of a difference as the switches will detect the changes and squash the old MACs in no time.
The beauty of having a modular operating system is the ability to swap "pieces" of the OS. In these cases, mostly what involves persistence.
In my situation, let's take my kids (home-schooling applies here too)...
My son's five... so his tools and toys for Kindergarten are hardly what my teen daughter would want for writing her paper on WWII. As such, each child is dedicated a memory pen instead of each machine. No matter which person plugs into which machine, their profile, software, host-name, IPs, etc. follow no matter where they're at on the network. (There's also a backup method in place in case my daughter goes to the library which doesn't depend on our network in the least... her desktop follows where ever she's at and becomes pretty independent - though the library machines are a little flaky from time to time regarding graphics hardware.) In the event of a pen failure... it takes about 2-3 minutes to reformat a new one and she's back to where she left off... homework and all.
Though I do like the idea of a centralized MAC database... it falls short of what I see TC being capable of, but I do imagine those with only a few machines to manage would see it as being very beneficial.
-
I use the following in bootsync.sh:
/opt/waitip
/opt/gethost
These are the two scripts
#!/bin/sh
#/opt/gethost
IP=$(ifconfig|grep "Bcast:"|awk -F':' '{ print $2 }'|awk '{ print $1}')
sethostname $(nslookup $IP | grep " $IP " | awk '{ print $4 }')
I f you are not pxe booting and need to wait for your dhcp IP address to be assigned you can precede the gethost with waitip
#!/bin/sh
#/opt/waitip
SEC=60
while [ $SEC -gt 0 ] ; do
ifconfig | grep "inet addr:" | grep -qv "127.0.0.1" && break
echo -ne "Waiting for IP $(( SEC--)) \r"
sleep 1
done
echo
-
@gerald: I imagine that would only work if DNS server or proxy was set up for dhcp-host(s) using a reversed look-up or if /etc/hosts was propagated with host names. There may be routers out there which cache host names as well, but those here (Cisco 2600s/3600s, Tenda, D-link, Motorola, Webstar, uBee) do not seem to.
-
If your network does not have a nameserver that resolves local machines, then it will not work.
Are you saying your name server cannot resolve machine names internal to your network?
A simple dnsmasq caching nameserver should do the job.
Your machines must have either static IP addresses with resolv.conf manually maintained,
or you use dhcp. I you use dhcp, your dhcp server can assign a suitable nameserver.
-
For a more indirect approach (needed here as I have a few dozen machines and I can't see editing boot codes for each) you have two primary options:
1) If you have the ability to set up DNS for yourself, set the computer's host name in DNS (preferably by MAC)
2) If DNS isn't an option, the following is all that's needed:
a) in /opt/bootsync.sh replace the line sethostname= with the preferred host name *preferred
or
b) add etc/hostname to /opt/.filetool.lst and edit /etc/hostname to suit (and remove the command in bootsync.sh accordingly)
I've tried both of these options on 6.1RC and it keeps forcing me back to tc@box >:( Suggestions welcome.
-
Option #1 - though I don't use this to know how stable:
1) Set the boot code host=MyHostName -- I believe this is in TCL6 as well as older models
If you have opt=(persistent) as a boot code (preferred), you can easily do the following:
1) Create a file /opt/hostname (and inside it, enter your hostname on a single line)
2) Edit /opt/bootsync.sh and replace sethostname box to sethostname `cat /opt/hostname`
If you must rely on "backups" you can
1) Create a file /opt/hostname (and inside it, enter your hostname on a single line)
2) Edit /opt/bootsync.sh and replace sethostname box to sethostname `cat /opt/hostname`
3) Edit /opt/.filetool.lst and make sure opt is listed
4) Run filetool.sh -b as non-root
*) As long as the boot code norestore IS NOT being used, this should work flawlessly
A final desperate method would be to edit (and back up) /opt/bootlocal.sh and add the line:
sethostname hostname &
This applies a little AFTER boot, so it may be invisible to you initially.
Which ever direction you take, when it's finished simply type in hostname at the prompt (or from Terminal if using a desktop) to make sure it "took."
Good luck!