Help me: slowly booting when adding an entry in /etc/hosts
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Help me: slowly booting when adding an entry in /etc/hosts
Hi,
when I add an entry in the /etc/hosts, such as:
192.168.1.15 firefly
my FC4 box will boot slowly. It seems stopping at: "Enabling swap space:.....". I don't know how to fix this problem. Can you help me?
the swap is ok.
it seems stopping after "Enabling swap space: ............ [OK]".
any change in /etc/hosts makes this problem.
Extra info.: My machine gets an IP addr from a DHCP server and I should add its hostname into the /etc/hosts to avoid the warning "Log in anyway?" after checking username and password.
Can you give me a solution ?
If you're getting your IP from DHCP then the only IP for your local host in /etc/hosts should be the "localhost" entry:
127.0.0.1 myhostname localhost
In the above 127.0.0.1 is the loopback interface (lo in ifconfig). localhost is a keyword (you can have localhost.domain where domain is your actual domain) and myhostname would be the name you've given to your host.
The above should be the FIRST uncommented entry in your /etc/hosts file.
You can NOT specify any other IP address for myhostname as it will change due to being obtained from DHCP (especially if the DHCP is coming from your ISP - in house networks typically have longer reservations so you might get away with it on one of those but why risk it?).
While prior poster is correct that starting swap space should have nothing to do with your hosts entries what may be occurring is that the init script that starts right after your swap space is hanging.
Do grep swap /etc/rc?.d/* to find out which file is running swapon. This should be something like:
/etc/rcS.d/S35mountall.sh
You would then look for the next higher number in that directory as that is the next thing being started (ls /etc/rcS.d/S*). Check out that item as it is likely what is hanging. It is possible it is the mountall itself that is hanging if you have configured any NFS mounts.
Thank you, jlightner.
when typing: grep swap /etc/rc?.d/* , i got:
/etc/rc0.d/S01halt:# Turn off swap, then unmount file systems.
/etc/rc0.d/S01halt:[ -f /proc/swaps ] && SWAPS=`awk '! /^Filename/ { print $1 }' /proc/swaps`
/etc/rc0.d/S01halt:[ -n "$SWAPS" ] && runcmd $"Turning off swap: " swapoff $SWAPS
/etc/rc6.d/S01reboot:# Turn off swap, then unmount file systems.
/etc/rc6.d/S01reboot:[ -f /proc/swaps ] && SWAPS=`awk '! /^Filename/ { print $1 }' /proc/swaps`
/etc/rc6.d/S01reboot:[ -n "$SWAPS" ] && runcmd $"Turning off swap: " swapoff $SWAPS
I don't know what's wrong with the swap. My /etc/fstab is configured:
# This file is edited by fstab-sync - see 'man fstab-sync' for details
LABEL=/ / ext2 defaults 1 1
/dev/devpts /dev/pts devpts gid=5,mode=620 0 0
/dev/shm /dev/shm tmpfs defaults 0 0
/dev/proc /proc proc defaults 0 0
/dev/sys /sys sysfs defaults 0 0
/etc/hda7 swap swap defaults 0 0
/dev/fd0 /media/floppy auto pamconsole,exec,noauto,managed 0 0
/dev/hdc /media/cdrom auto pamconsole,exec,noauto,managed 0 0
I think the swap option is not wrong.
When I edit the /etc/hosts as the default:
127.0.0.1 localhost.domain localhost
the machine runs ok. Howerver, after login, I get the notice: "Could not lookup internet address for -mymachinename- ... correct the problem by adding -mymachinename- to the /etc/hosts" "Log in Anyway?".
Any change in the /etc/hosts will makes the machine startup very slowly.
I don't know how to fix this problem. Can you help me?
My bad. My example was from my Debian box. On my RedHat AS 3 box the swapon is done in /etc/rc.d/sysinit instead.
You might want to have a look at that and see what it does.
No reason updating /etc/hosts should cause this problem unless you're putting an entry above the 127.0.0.1 line. However as noted if you're using DHCP you should not be adding an entry to /etc/hosts for your real IP as that IP can change on reboot.
Entry for localhost should be:
127.0.0.1 localhost.localdomain localhost
You can also insert your real hostname in the above line:
127.0.0.1 realhostname localhost.localdomain localhost
Just make sure the localhost stuff is still there as many network startup and/or daemon processes use that.
If NOT doing dhcp to get your IP address the next line down can be the real IP and the real hostname. So you leave the 127.0.0.1 lline as in my first example then create a new line similar to:
The real domain is the DNS domain you're on (e.g. linuxquestions.org). The realhostname after the space is an short name alias for the ereal name so you don't always have to type in the fully qualified domain name (FQDN).
Again only add that entry if you're NOT using DHCP to get your IP or if your IP is static (a DHCP pool with only 1 IP allowed).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.