Skip to content

Instantly share code, notes, and snippets.

@mcandre
Last active May 3, 2020 16:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcandre/fb76e7468701eb3fb25f4863aee156ca to your computer and use it in GitHub Desktop.
Save mcandre/fb76e7468701eb3fb25f4863aee156ca to your computer and use it in GitHub Desktop.
FreeBSD Hyper V Notes

FreeBSD Hyper V Notes

Enable superuser privileges for a user account

  1. Exit the current user session. Login as root.
$ exit
Login: root
Password: <password>
# pw group mod wheel -m <username>

Rescue Mode

  1. If possible, cleanly halt the file system.
$ shutdown -h now
  1. Boot into Single User mode.

  2. Enable write permissions on /.

# mount -u /
  1. Cleanly halt the system.
# shutdown -h now
  1. Boot into normal multiuser mode.

Enable network connectivity

  1. Launch the Virtual Switch Manager from the Hyper V Manager.
  2. Add a New Virtual Network Switch. Type: External.
  3. For the external network, select the device that physically connects the host to the network, such as a wireless card or Ethernet adapter.
  4. Select an appropriate name.
  5. Select OK.
  6. Navigate to the FreeBSD VM Settings.
  7. In the Network Adapter section, select the named virtual switch.
  8. Select OK.

After a few seconds, a running FreeBSD VM will populate with DHCP records, allowing ping google.com to succeed, for example.

If necessary, use ifconfig <network interface> down && ifconfig <network interface> up && dhclient <network interface> to reload the connection, or use shutdown -h now to cleanly reboot.

Note: Some instances may require a configuration tweak to work around an issue with ARP, especially wireless adapters:

$ su -
<root password>
# sysctl net.link.ether.inet.max_age=60

Register user account for sudo

  1. Install the sudo package.
$ su -
<root password>
# pkg update && pkg install -y sudo
  1. Modify the sudoers configuration to allow sudo access by a specific account.
$ su -
<root password>
# vi /usr/local/etc/sudoers

Enter Insert mode by pressing i.

Insert the line <username> ALL=(ALL) ALL. For example, for user andrew, insert the line:

andrew ALL=(ALL) ALL

Or, if desired, insert the line %<group> ALL=(ALL) ALL. For example, for the wheel group, insert the line:

%wheel ALL=(ALL) ALL

Then force save and exit.

(ESCAPE)
:w!
:q
  1. Exit the root session. Exit the current user session. Reenter the user session.
# exit
$ exit
Login: <username>

Now try sudo pkg update and enter the current user password.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment