zgenhostid(8)

zgenhostid8

Generate host id into /etc/hostid

Usage

zgenhostid [-f] [-o filename] [hostid]

Overview

Creates /etc/hostid file and stores the host ID in it. If hostid was provided, validate and store that value. Otherwise, randomly generate an ID.

Options

-h

Display a summary of the command-line options.

-f

Allow output overwrite.

-o filename

Write to filename instead of the default /etc/hostid.

hostid

Specifies the value to be placed in /etc/hostid. It should be a number with a value between 1 and 2^32-1. If 0, generate a random ID. This value must be unique among your systems. It must be an 8-digit-long hexadecimal number, optionally prefixed by "0x".

Files

/etc/hostid

Examples

Generate a random hostid and store it
# zgenhostid
Record the libc-generated hostid in /etc/hostid
# zgenhostid "$(hostid)"
Record a custom hostid (0xdeadbeef) in /etc/hostid
# zgenhostid deadbeef
Record a custom hostid (0x01234567) in /tmp/hostid and overwrite the file if it exists
# zgenhostid -f -o /tmp/hostid 0x01234567

Releases

4 releases since Debian 10 (Buster); the text changed 3 times.

  1. 10
  2. 11
  3. 12
  4. 13

-f since Debian 11 (Bullseye); -h since Debian 11 (Bullseye); -o since Debian 11 (Bullseye).

History

zgenhostid emulates the genhostid(1) utility and is provided for use on systems which do not include the utility or do not provide the sethostid(3) function.

From zfsutils-linux 2.3.9-0+deb13u1 in Debian 13 (Trixie). Parsed by carta from the page's mdoc source.