Possible to set host- and username at boot?

Moderators: kirk, jamesbond, p310don, JakeSFR, step, Forum moderators

Post Reply
Neo_78
Posts: 376
Joined: Wed Dec 29, 2021 10:45 pm
Has thanked: 206 times
Been thanked: 9 times

Possible to set host- and username at boot?

Post by Neo_78 »

Tiny Core Linux as a live system has the interesting options to set a custom hostname, username and respective passwords (also for the root user) at boot:

http://www.tinycorelinux.net/faq.html#bootcodes

Is this possible in FatDog?

don570
Posts: 626
Joined: Sat Nov 21, 2020 4:43 pm
Has thanked: 5 times
Been thanked: 98 times

Re: Set host- and username at boot?

Post by don570 »

Have you tried using a save file rather than saving to a folder.
The various preferences and configurations (including internet connection ) will be inside the save file.

Then in 'menu.lst' you can choose the fatdog configuration you desire.

You need to know boot options..
https://distro.ibiblio.org/fatdog/web/f ... tions.html

It looks complex but essentially all you have to do is fill in the path to savefile at end of kernel line...
Here is the instructions...

device:dev:path:crypt
Where:
"device" is the command, you have to specify it as is. It tells Fatdog64 that the savefile is available on the specified device (see below).
"dev" is the device/partition name where the savefile is located, for example sda1, sdb, etc.
"path" is the path to the savefile including the filename. Example: /fd64/600/fd64save.3fs. Path is optional, if you don't specify it, the default of /fd64save.ext4 will be used.
"crypt" is an option, which can be either "crypt" (cryptoloop) or "dmcrypt" (LUKS). It informs Fatdog64 that the device that the savefile is in is encrypted (not the savefile itself). When this is specified, Fatdog64 will ask for a password during booting and try to decrypt the device before attempting to mount it. Crypt is optional.
As of version 811, Fatdog64 can detect LUKS encrypted devices automatically, so "dmcrypt" doesn't have to be specified anymore.

Neo_78
Posts: 376
Joined: Wed Dec 29, 2021 10:45 pm
Has thanked: 206 times
Been thanked: 9 times

Re: Possible to set host- and username at boot?

Post by Neo_78 »

Just to clarify the concept, in Tiny Core Linux you can use the following boot options in a live system:

Code: Select all

tinycore secure host=custom_hostname user=custom_username  noautologin

This will prompt you to set a root password, a password for a non-root user, sets a custom hostname and subsequently boots to the login screen instead of automatically accessing the root account.

Correct me if I am wrong but I do not see in the documentation that FatDog supports conparable boot options.

Clarity
Posts: 3358
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1386 times
Been thanked: 444 times

Re: Possible to set host- and username at boot?

Post by Clarity »

This is one of the 'missing' components of FD's "Quick Setup" . Maybe a future update to it will contain that feature since 90% of home users have a need for this.

ALSO, I have wondered why it must step thru so many screen for the initial setup of a FD PC for its mere basic use. Could all 4 of its current multiple-screen elements be handled within a Single screen; albeit a FATDOG screen?

Curious

Neo_78
Posts: 376
Joined: Wed Dec 29, 2021 10:45 pm
Has thanked: 206 times
Been thanked: 9 times

Re: Possible to set host- and username at boot?

Post by Neo_78 »

Yep, that would be a useful feature...

jamesbond
Posts: 594
Joined: Tue Aug 11, 2020 3:02 pm
Location: The Pale Blue Dot
Has thanked: 98 times
Been thanked: 316 times

Re: Possible to set host- and username at boot?

Post by jamesbond »

So many things, so little time ...
In what situation and scenarios is it useful?
But don't tell me something like this: "in case I want to boot up the system and not using savefile and not remastering but I want to set the hostname and the login name and I don't want to enable autologin" ... instead, tell me which situation in which you have to do the above.

Neo_78
Posts: 376
Joined: Wed Dec 29, 2021 10:45 pm
Has thanked: 206 times
Been thanked: 9 times

Re: Possible to set host- and username at boot?

Post by Neo_78 »

You would have a fully customized system at first boot with a single command that integrates into any existing network without having to graphically run mutiple setup screens, restarting x, etc. Especially interesting if you are only booting into cli.

je55eah
Posts: 183
Joined: Mon Jul 26, 2021 5:27 pm
Has thanked: 30 times
Been thanked: 5 times

Re: Possible to set host- and username at boot?

Post by je55eah »

I would also appreciate this. Currently, I am manually setting my hostname to match the UUID of the partition hosting my frugal installation in the format "fatdogUUID".

It would be cool if I could specify the UUID once in the grub.cfg and target the variable in the savefile parameters as well as in an argument which sets the hostname.

Is there something I can do to make this happen?

jamesbond
Posts: 594
Joined: Tue Aug 11, 2020 3:02 pm
Location: The Pale Blue Dot
Has thanked: 98 times
Been thanked: 316 times

Re: Possible to set host- and username at boot?

Post by jamesbond »

The problem with this "feature" is that it only makes sense when running with RAM-only no-savefile scenarios.
When you use a savefile (=most of the users), then this options basically re-writes the hostname, and username, and passwords each time you boot - overwriting what's already in the savefile. Not good.

je55eah wrote: Thu Oct 13, 2022 3:01 am

Is there something I can do to make this happen?

You can edit /etc/rc.d/rc.local and add the parsing to read the parameters from kernel's command line (available in /proc/cmdline), and do the update you need.
Hostname can be updated by editing /etc/hostname and /etc/hosts, then run "hostname -F /etc/hostname".
This changes of course only applies to a situation where you have a savefile, but you can do a remaster that includes this change.

je55eah
Posts: 183
Joined: Mon Jul 26, 2021 5:27 pm
Has thanked: 30 times
Been thanked: 5 times

Re: Possible to set host- and username at boot?

Post by je55eah »

I added

Code: Select all

/usr/local/bin/proc-cmdline-parser.sh

to /etc/rc.d/rc.local

then I created /usr/local/bin/proc-cmdline-parser.sh, beginning with this script:

I added the following to the end of it.

Code: Select all

# Set hostname at boot if HOSTNAME is specified as a kernel option
if [ $(has_cmd HOSTNAME && echo true || echo false) == 'true' ]; then
    BOOTHOSTNAME=$(get_cmd HOSTNAME)
    OLDHOSTNAME=$(< /etc/hostname) 
    sed -i "s/$OLDHOSTNAME/$BOOTHOSTNAME/" /etc/hosts
    echo $BOOTHOSTNAME > /etc/hostname
else
    echo "HOSTNAME is not specified, continuing without making changes"
fi

Then I made it executable.

chmod u+x /usr/local/bin/proc-cmdline-parser.sh

This worked in my testing.
Thank you @jamesbond

je55eah
Posts: 183
Joined: Mon Jul 26, 2021 5:27 pm
Has thanked: 30 times
Been thanked: 5 times

Re: Possible to set host- and username at boot?

Post by je55eah »

Will you build this into future releases?

jamesbond
Posts: 594
Joined: Tue Aug 11, 2020 3:02 pm
Location: The Pale Blue Dot
Has thanked: 98 times
Been thanked: 316 times

Re: Possible to set host- and username at boot?

Post by jamesbond »

je55eah wrote: Mon Oct 24, 2022 10:25 am

Will you build this into future releases?

Sorry to disappoint you, but the answer is most probably "No".

I mentioned the reason before:

jamesbond wrote: Sun Oct 16, 2022 3:22 pm

The problem with this "feature" is that it only makes sense when running with RAM-only no-savefile scenarios.
When you use a savefile (=most of the users), then this options basically re-writes the hostname, and username, and passwords each time you boot - overwriting what's already in the savefile. Not good.

Fatdog is a general purpose OS and we can't meet every single specific requirements.
That's what remaster is for - so you can customise Fatdog to your own specific needs.

je55eah
Posts: 183
Joined: Mon Jul 26, 2021 5:27 pm
Has thanked: 30 times
Been thanked: 5 times

Re: Possible to set host- and username at boot?

Post by je55eah »

The way it is implemented the hostname would only be overwritten if the user put HOSTNAME=desiredhostname into their boot stanza. If they did that then it is a desired outcome. If they do not put it there then nothing would be changed. I am using it with a savefile and it is useful because when I am creating multiple fatdog usbs I can copy the files from a working usb to another and change the hostname and the uuid right in grub.conf so that multiple systems do not share the same hostname. The current situation mandates that I will need to manually implement this everytime a new fatdog is released. Your explanation for not including it doesn't make sense because usernames and passwords are not changed and the boot option is merely an option.

jamesbond
Posts: 594
Joined: Tue Aug 11, 2020 3:02 pm
Location: The Pale Blue Dot
Has thanked: 98 times
Been thanked: 316 times

Re: Possible to set host- and username at boot?

Post by jamesbond »

As I said, sorry to disappoint you.

je55eah
Posts: 183
Joined: Mon Jul 26, 2021 5:27 pm
Has thanked: 30 times
Been thanked: 5 times

Re: Possible to set host- and username at boot?

Post by je55eah »

Why? I gave you the working scripts.

Neo_78
Posts: 376
Joined: Wed Dec 29, 2021 10:45 pm
Has thanked: 206 times
Been thanked: 9 times

Re: Possible to set host- and username at boot?

Post by Neo_78 »

+1 to add this feature. :thumbup:

Post Reply

Return to “FatDog”