What are the steps for changing the hostname?

I don’t see an option in the KDE Settings to change my PC’s hostname, so how does one go about changing it? I suspect there will be more than one simple step.

2 Likes

I found that for me, the answer involved two core areas; the second because I have a mdadm Software RAID: (click the arrows to expand)

Changing the hostname

I found I could do it via command line…

$ sudo -i
# hostnamectl set-hostname AM4-5600X-Linux
# nano /etc/hosts
 => updated "127.0.1.1  AM4-x5600-Linux" record to "127.0.1.1  AM4-5600X-Linux"

Not all systems use a /etc/machine-info file, but you can check if yours was updated if you do by inspecting its contents…

# cat /etc/machine-info

According to man machine-info, the hostnamectl command should have updated it (if you have one)…

You may use hostnamectl(1) to change the settings of this file from the command line.

`mdadm` homehost update

I also remembered the hostname being used when I setup my raid1 array with mdadm --create... and found some directions for updating that as well… (although I understand this was optional)

# umount /data/raid1
# mdadm --stop /dev/md127
# mdadm -A /dev/md127 /dev/sd[bc]1 --homehost=AM4-5600X-Linux --update=homehost

Confirmed updates took with…

# mdadm -E /dev/sdb1
# mdadm -E /dev/sdc1
# mdadm -D /dev/md127
 => all 3 now listing... "Name : AM4-5600X-Linux:RAID1Array  (local to host AM4-5600X-Linux)
"

I also remembered that after the mdadm create there was a step for updating a config file… mdadm --detail --scan >> /etc/mdadm.conf… so I edited the hostname in that file too…

# nano /etc/mdadm.conf
 => update one line to... "ARRAY /dev/md/RAID1Array metadata=1.2 name=AM4-5600X-Linux:RAID1Array UUID=54abcbfa:cc3fbecd:e4aad7e5:7961912d"

Mounted the array with # mount /data/raid1 and all looks fine. Then I recalled one more step was done after the mdadm --detail --scan >> /etc/mdadm.conf… and executed # mkinitcpio -P.

# mkinitcpio -P
==> Building image from preset: /etc/mkinitcpio.d/linux510.preset: 'default'
  -> -k /boot/vmlinuz-5.10-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-5.10-x86_64.img
==> Starting build: 5.10.56-1-MANJARO
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [autodetect]
  -> Running build hook: [modconf]
  -> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: xhci_pci
  -> Running build hook: [keyboard]
  -> Running build hook: [keymap]
  -> Running build hook: [filesystems]
  -> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-5.10-x86_64.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux510.preset: 'fallback'
  -> -k /boot/vmlinuz-5.10-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-5.10-x86_64-fallback.img -S autodetect
==> Starting build: 5.10.56-1-MANJARO
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [modconf]
  -> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: xhci_pci
  -> Running build hook: [keyboard]
  -> Running build hook: [keymap]
  -> Running build hook: [filesystems]
  -> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-5.10-x86_64-fallback.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux513.preset: 'default'
  -> -k /boot/vmlinuz-5.13-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-5.13-x86_64.img
==> Starting build: 5.13.8-1-MANJARO
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [autodetect]
  -> Running build hook: [modconf]
  -> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: xhci_pci
  -> Running build hook: [keyboard]
  -> Running build hook: [keymap]
  -> Running build hook: [filesystems]
  -> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-5.13-x86_64.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux513.preset: 'fallback'
  -> -k /boot/vmlinuz-5.13-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-5.13-x86_64-fallback.img -S autodetect
==> Starting build: 5.13.8-1-MANJARO
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [modconf]
  -> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: xhci_pci
  -> Running build hook: [keyboard]
  -> Running build hook: [keymap]
  -> Running build hook: [filesystems]
  -> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-5.13-x86_64-fallback.img
==> Image generation successful

Hopefully these steps might help someone else. I confirmed all well initially and post-reboot.

P.S. I also had to stop and restart conky for my name change to show up after the initial updates.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.