Ask Your Question

F22: how to change /dev/fedora_BadHostname directory to /dev/fedora_GoodHostname?

asked 2015-09-26 16:24:13 -0500

Eryq Ouithaqueue gravatar image

Hi! I just installed Fedora 22, and the installer apparently guessed my hostname poorly. I corrected the hostname easily (via hostnamectl), but the "bad-hostname" still appears as the logical name of the disk devices: on bootup, udev (I assume) creates the following directory and symlinks:

 /dev/fedora_BadHostname/home -> ../dm-5
 /dev/fedora_BadHostname/root -> ../dm-0
 /dev/fedora_BadHostname/swap -> ../dm-1

These /dev/fedora_BadHostname/* aliases then appear in other (more-visible) places, like /etc/fstab and the Disk Utility. I'd like the system to use "fedora_GoodHostname" instead, but I can't find out where "BadHostname" is coming from.

I think the ultimate origin is the grub2 configuration, because /etc/grub2.cfg has the BadHostname impregnated in it, which in turn may be coming from /etc/sysconfig/grub, because I see this:

GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_CMDLINE_LINUX=" rhgb quiet"

But (1) I'm hella scared about modifying this file without understanding what I'm doing, and (2) I see "root" and "swap" but not "home", which makes me think I'm still missing a piece of the puzzle.

Can anyone give me some guidance on what to do? Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-09-26 22:42:52 -0500

updated 2015-09-26 23:25:46 -0500

So the reason that directory exists is that your Logical Volume Manager created a volume group called "fedora_BadHostname" when you selected the default disk layout in anaconda while first installing the system. If you use the command sudo vgs, you'll see that you have a volume group named "fedora_BadHostname". The reason GRUB references the volume group is that it's the location of your root and swap volumes, necessary for booting your system, and you would have rendered your system unbootable if you had stripped those references from GRUB.

What you need to do is rename the volume group using the vgrename command. Unfortunately, in this case, it's your root volume group. In order to rename it, it can't be mounted, so you're going to have to:

  1. Make sure everything you care about is backed up to a separate system (as it should be; regularly, of course)
  2. Boot from a Fedora (preferably) rescue disk to access your system while its root volume group isn't mounted.
  3. Use vgrename to reconfigure fedora_BadHostname into fedora_GoodHostname.
  4. I'll need to see your logical volume layout before providing specific advice on this step, but if you chose the standard installation options, I'd mkdir /mnt/GoodHostname and mount -t xfs /dev/mapper/fedora_GoodHostname-root /mnt/GoodHostname
  5. Here, depending on your use of BIOS or UEFI, we'll need to mount your boot(/efi) partition(s) into /mnt/GoodHostname/boot(/efi) so that grub2-mkconfig below will be able to place the new GRUB configuration file in the proper location.
  6. chroot /mnt/GoodHostname /bin/bash
  7. Modify the /etc/fstab file, replacing all references to fedora_BadHostname to fedora_GoodHostname
  8. Modify the /etc/default/grub file, replacing all references to fedora_BadHostname to fedora_GoodHostname, and grub-mkconfig yourself a new grub.conf file.
  9. Reboot your system and allow GRUB to boot into your old host.
  10. Confirm that the volume group name has been changed, and the /dev/fedora_BadHostname directory is renamed along with it.

I don't know if you'll conclude this to be too much trouble to simply rename your volume group; unless you had a really bad breakup with BadHostname, I wouldn't consider it necessarily pressing enough to change. If you aren't willing and able to recover from backup in the event of some sort of disaster, I wouldn't advise doing it. It's not a difficult procedure, but mistakes can be costly enough to prevent your system from booting, so you need to be very careful in attempting it.

Don't take that list above as the final, authoritative guide on this. If you need help constructing more specific steps from that general outline, I'll be glad to assist, but unless you're interested in it purely as a technical exercise (which is laudable), it's probably not worth your while.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-09-26 16:24:13 -0500

Seen: 455 times

Last updated: Sep 26 '15