Categories
Technology

Using Debian Cloud Images in VMWare Fusion

In my last post I described how to use debian-cloud-tools to build an AMI for AWS EC2 instances. What about running that same instance locally? Personally, I do most of my development in VMWare Fusion and I want that instance to look like my AWS instance. I use VMWare Fusion because I want to be able to develop without an Internet connection and because I don’t want to pay to run two instances in the cloud. Let’s see how I did this.

The steps start out the same as building for AWS. You want to start with an installation of buster and clone the debian-cloud-images repository and install some dependencies. Then you will run the build like this:

bin/debian-cloud-images build buster nocloud amd64 --build-id manual --version 1 --override-name nocloud-buster-image --build-type official

That command will run for a while and create a file called nocloud-buster-image.raw. We need to convert that to a VMDK image usable by VMWare Fusion. That can be done like this:

qemu-img convert -O vmdk nocloud-buster-image.raw nocloud-buster-image.vmdk

Once you have a VMDK image, copy it to the host where you run VMWare Fusion. I’m running VMWare Fusion 11.1.0 and these steps apply to that version.

  1. Choose “Create a vustom virtual machine.”
  2. For the operating system select “Other Linux 4.x or later kernel 64-bit”. This is because VMWare doesn’t know about buster yet.
  3. Select “Legacy BIOS”.
  4. Select “Use an existing virtual disk.” We’re going to select the VMDK file that we just created and we want to “make a separate copy of the virtual disk.”
  5. Finally, click “Customize Settings”. Give the system a name that you like.

Now you’ll see a settings dialog. Make these changes.

  1. Remove the camera.
  2. Remove the printer.
  3. Remove the sound card.
  4. Adjust the memory size and the total CPU count.
  5. Connect a CD/DVD drive and attach a buster boot disk. I’m using the debian-10.0.0-amd64-netinst.iso boot disk.
  6. Adjust the hard disk size.
  7. Set the CD/DVD drive as the startup disk and restart.

Now you’ll be at a Debian installer menu. Choose “Advanced options” and then “Rescue mode”. This will begin booting the rescue disk where we will make a couple changes.

  1. Choose the correct language and keyboard configuration.
  2. Choose any hostname and domain name. It doesn’t matter.
  3. Choose any timezone. It doesn’t matter.
  4. Boot to /dev/sda1.
  5. Mount a separate /boot/efi partition.
  6. Execute a shell in /dev/sda1.

Once you’re on the shell we’re going to edit /etc/default/grub and make these changes:

  1. Comment out the lines labeled GRUB_TERMINAL and GRUB_SERIAL_COMMAND.
  2. Change the line labeled GRUB_CMDLINE_LINUX to be empty, like this: GRUB_CMDLINE_LINUX="".
  3. Change this line, too: GRUB_CMDLINE_LINUX_DEFAULT="quiet elevator=noop net.ifnames=0 transparent_hugepages=never". I think that the elevator option is redundant and you probably don’t need the transparent_hugepages option but since I use Redis I put it in there.

After adjusting /etc/default/grub we need to install it by running this command:

grub-mkconfig -o /boot/grub/grub.cfg

And finally, right now we have no users and no passwords. We need to give the root user a password by running the passwd command. Just choose a password. You can change it or disable it later or add new users later.

Now exit out of the shell and reboot. When it reboots it will be on the Debian installer again so now disconnect the drive and send Ctrl-Alt-Delete to the host. The host will now boot in VMWare Fusion.

There are two final steps before you’re on your own. You need to give the host some SSH keys and you need to expand the disk. These are quite easy:

dpkg-reconfigure openssh-server
systemctl restart sshd
resize2fs /dev/sda1

You can choose to examine the SSH configuration but I used the existing one without issue.

Now you have a VMWare Fusion cloud host that looks just like your AWS host.

2 replies on “Using Debian Cloud Images in VMWare Fusion”

Comments are closed.