Virtualization Archive

Mounting VirtualBox RAW disks

Posted December 2, 2017 By Landis V

Cleaning up some VMs this evening and wanted to mount a RAW disk partition I’d been using with an old VM. Surprised to find that a simple ‘mount’ wouldn’t do the trick. Fortunately pretty easy thanks to the info at the following link – use parted to get the offset and add that as one of the mount options.
https://askubuntu.com/questions/236263/browse-img-without-mounting

Be the first to comment

hostapd in a VM for device testing

Posted November 27, 2016 By Landis V

While working with my Chamberlain MyQ Garage Door Opener the other day, I ran into issues getting hostapd to work on Kali with the chap ass Netis WP2120 nano USB adapter I had (based on the RTL8192cu chipset/driver).  I need to clear off a few browser tabs and eventually see if I can get hostapd working with this adapter on a different box (VM) for testing.  A few of the links I worked with unsuccessfully, but provide some useful information.

 

More notes

Installed usbutils for lsusb
Installed hostapd
Installed iw
Installed lshw
Ran through steps at https://adamscheller.com/systems-administration/rtl8192cu-fix-wifi/, minor issue with “linux-headers-generic”, skipped it for now.

Did receive a modprobe error, “could not insert ‘8192cu’: Device or resource busy”. lsmod shows the old rtl8192cu drivers active. Did a reboot. Correct driver modules now listed, though no device listing in ‘iw list’. Does appear in ‘lshw -c network’, and appears as wlan0 in ‘ip link list’.

Started in with hostapd steps from http://sarumait.blogspot.com/2013/11/ubuntu-wireless-hotspot-using-edimax-ew.html and from my previous testing on the Chamberlain page.

Attempted to start hostapd service which seemed to work, but didn’t see my SSID. Ran it interactive debug and got an “invalid/unknown driver ‘8192cu'”.

Instructions at https://github.com/pritambaral/hostapd-rtl871xdrv
Git cloned the above repository and the w1.fi repository listed. Got hostapd to build after installing dependencies (below).

apt-get install apt-file libnl-3-dev libnl-genl-3-dev pkg-config libssl-dev
apt-file not needed, but handy for looking up files that resulted in failures during make.

Ran the patch process noted at https://github.com/pritambaral/hostapd-rtl871xdrv

Ended up having some success after doing a ‘make dkms’ in the rt8192cu directory cloned from https://github.com/dz0ny/rt8192cu and setting the driver in my hostapd.conf to the rtl871xdrv

Pages helpful in getting it to work

2 Comments so far. Join the Conversation

Resizing a Raw VMDK For a VirtualBox Guest

Posted December 27, 2015 By Landis V

Had to resize a partition as I had run out of space on my VirtualBox Linux guests.  Pain in the butt.

Shut the guest down.  Ran a ‘lvextend -L+2GB /dev/amdfx/guestname‘ where “amdfx” is my physical volume and “guestname” is the logical volume name.

Had an extended partition with swap space, so used fdisk to delete the extended partition.  Also deleted and recreated the primary partition making sure to select the same starting sector and setting the end sector using the previous ending value plus 2*1024*1024 (should have been *2 again, but decided it was alright for now).

Recreated the raw disk image for the VM.  First detached and deleted it with ‘vboxmanage storageattach kmm –storagectl “SATA Controller” –port 0 –device 0 –medium none‘, ‘vboxmanage closemedium disk VirtualBox\ VMs/guestname/guestdiskname.vmdk‘, ‘vboxmanage closemedium disk VirtualBox\ VMs/guestname/guestdiskname.vmdk‘, and ‘rm VirtualBox\ VMs/guestname/guestdiskname.vmdk‘.  Then recreated and re-attached it with ‘vboxmanage internalcommands createrawvmdk -filename VirtualBox\ VMs/guestname/guestdiskname.vmdk -rawdisk /dev/mapper/amdfx-guestname‘, ‘vboxmanage storageattach guestname –storagectl “SATA Controller” –port 0 –device 0 –type hdd –medium /home/user/VirtualBox\ VMs/guestname/guestdiskname.vmdk‘.

Restarted the VM, it booted normally.  I was then able to run a ‘resize2fs /dev/sda1‘ from within the guest and realize a gig of extra space (would have been 2GB, except for my screw-up forgetting to multiply by two).

Resources

  • http://askubuntu.com/questions/115310/how-to-resize-enlarge-grow-a-non-lvm-ext4-partition
  • https://forums.virtualbox.org/viewtopic.php?f=7&t=50255
  • http://www.tldp.org/HOWTO/LVM-HOWTO/extendlv.html
Be the first to comment

http://myhomelab.blogspot.com/2013/05/installing-mikrotik-routeros-under-VirtualBox.html

Since I’ve finally gotten around to building a decent VirtualBox installation, this may be useful/fun.

Be the first to comment

VM System With VGA Pass-Through

Posted March 31, 2015 By Landis V

Hardware hangup note for Ctrl+C to get past.
http://www.reddit.com/r/debian/comments/25h49k/debain_wheezy_network_installation_freezes_after/

Configured LVM environment with /home, /usr/, and /var on spinning platter drive.

Configured an IP reservation on my DHCP server, though I may change this to a true static address at some point.

Instructions for linux-headers and virtualbox setup:  https://wiki.debian.org/VirtualBox

Downloaded the extension pack with wget http://download.virtualbox.org/virtualbox/4.1.36/Oracle_VM_VirtualBox_Extension_Pack-4.1.36-97684.vbox-extpack (NOTE:  you will need to download the appropriate version for your installed VirtualBox version.  Run vboxmanage -v and compare the output version to the versions available at https://www.virtualbox.org/wiki/Downloads; it apears you will need to match at least Major.Minor version numbers) and installed using instructions at https://www.virtualbox.org/manual/ch08.html#vboxmanage-extpack.

Created a separate logical volume on my SSD drive.  Dedicated it to the Win10 guest (see https://wiki.archlinux.org/index.php/VirtualBox#Create_a_VM_configuration_to_boot_from_the_physical_drive).

Created a VM from the CLI.  Had to actually go into the BIOS and enable AMD-V on my Gigabyte 78LMT-USB3 as it was disabled.  Could not get the version of VirtualBox included with the Debian distribution to give anything except the “Your PC needs to restart” 0x0000005D error, even when trying to force the NX bit using info for setting CMPXCHG16B as found at http://www.makeuseof.com/tag/try-windows-10-youre-running-linux/.  Ultimately ended up loosely following instructions from http://www.admin-magazine.com/Articles/Server-Virtualization-with-VirtualBox but substituting “wheezy contrib” for “lucid contrib” early in the instructions, and substituting 4.3 for 4.1, then running a “modifyvm” and setting ostype to Windows81_64.  Once this was done, I was able to start the install process.  Yay.

Had to modify the e1000g0 adapter config from http://www.perkin.org.uk/posts/create-virtualbox-vm-from-the-command-line.html to instead be “eth0” since I’m on a linux box (also had to remove it before re-adding, got an error when even attempting to start the machine).

Mouse pointer was batty, like it was scaled.  Ended up downloading the appropriate VirtualBox guest additions to the host machine, mounting them in the DVD drive, selecting the AMD64 file, bringing up properties and setting to compatibility mode Windows 8 (can’t seem to locate where I found this), and was able to install.  Pointer synced, system is on the web.

Second Steps – Debian LXC Guest for KDE

Debian 7.8

#From https://wiki.debian.org/LXC - loosely

apt-get install lxc
apt-get install bridge-utils libvirt-bin debootstrap

# Failed with:
# Failed to fetch http://security.debian.org/pool/updates/main/libx/libxml2/libxml2-utils_2.8.0+dfsg1-7+wheezy3_amd64.deb 404 Not Found [IP: 128.31.0.63 80]
# E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

apt-get
apt-get install bridge-utils libvirt-bin debootstrap

# Successful this time

echo -e "cgroup\t/sys/fs/cgroup\tcgroup\tdefaults\t0\t0" >>/etc/fstab
mount /sys/fs/cgroup
mount

# Confirmed that cgroup is mounted

lxc-checkconfig

# All show enabled
# Check out http://www.turnkeylinux.org/blog/announcing-turnkey-lxc, maybe add
# Turnkey template for some other functionality on this box
# Switched tracks and decided to try out Docker
# From http://docs.docker.com/installation/debian/#debian-wheezystable-7x-64-bit

echo "deb http://http.debian.net/debian wheezy-backports main" >> /etc/apt/sources.list
apt-get update
apt-get install -t wheezy-backports linux-image-amd64
reboot

# SSH'ed back into machine, verify new kernel

uname -a
wget https://get.docker.com/
chmod +x index.html
gpasswd -a my-account docker
service docker restart

# Service apparently did not restart, so had to start it again manually

service docker start

# Now as non-root
# Determined the following from http://www.syncano.com/getting-started-docker/

docker pull ubuntu:14.10
docker images

# Lists the newly pulled image; attempted to run it.
docker run -t ubuntu:14.10

# At this point, continuously encountered an error similar to the following:
# FATA[0034] Error response from daemon: Cannot start container (container UUID here): [8] System error: write /sys/fs/cgroup/docker/(container UUID here)/cgroup.procs: no space left on device
# There is definitely space left on the device, I do not appear to be lacking inodes as others seem to have encountered similarly, and permissions look OK.
# Started to install strace to troubleshoot further... but I need to get an accounting system back online.
# Switched to a VirtualBox KDE environment plan.  I guess I can always kill it later :)

lvm lvcreate -L 10g -n kmm
wget http://peppermintos.com/iso/Peppermint-5-20140623-amd64.iso
vboxmanage createvm --name kmm --register
vboxmanage modifyvm kmm --memory 1024 --acpi on --boot1 dvd --nic1 bridged --bridgeadapter1 eth0
VBoxManage internalcommands createrawvmdk -filename ~/VirtualBox\ VMs/kmm/kmmSSD.vmdk -rawdisk /dev/amdfx/kmm
vboxmanage storagectl kmm --name "SATA Controller" --add sata
vboxmanage storageattach kmm --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium ~/VirtualBox\ VMs/kmm/kmmSSD.vmdk
vboxmanage storageattach kmm --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium ./Peppermint-5-20140623-amd64.iso
vboxmanage modifyvm kmm --ostype Ubuntu_64 --vrde on --vrdeport 22888
vboxmanage startvm kmm --type headless

# Able to RDP in and started Peppermint install process.
Be the first to comment

Four very good articles I’ve encountered today regarding networking in Linux containers. This is a space that has blossomed and matured surprisingly quickly, and many of the frustrations I had previously encountered are gradually being solved.

I was initially researching veth’s and bridging a container network to the host network. I have a container inside a VirtualBox VM with a NAT network, and want to bridge the container so it retrieves an address from the VirtualBox NAT network. As I’ve dug into it further, this appears to actually be what’s happening, but I start to run into issues when I attempt to set up a port forward on the VirtualBox NAT to a service running within the LXC container.

A Brief Introduction to Linux Containers with LXC
http://blog.scottlowe.org/2013/11/25/a-brief-introduction-to-linux-containers-with-lxc/

Introducing Linux Network Namespaces
More interesting to me in the context of VRF lite a la Cisco than in the context of LXC, but definitely something I’ll be coming back to.
http://blog.scottlowe.org/2013/09/04/introducing-linux-network-namespaces/

Exploring LXC Networking
Gets into LXC testing using Vagrant, which is another tool I have been meaning to learn more about. Perhaps one of the most helpful articles in understanding just what I was encountering.
http://containerops.org/2013/11/19/lxc-networking/

Disposable Development Boxes: Linux Containers on VirtualBox
This was a second search as I started to look more into the issues getting the forwaring to work right. Egresss from the container seemed to work OK, I could ping Google and such, but I couldn’t seem to bring anything back in easily.
http://mike.teczno.com/notes/disposable-virtualbox-lxc-environments.html

Be the first to comment

Creating a new VirtualBox VM on the command line

Posted March 1, 2014 By Landis V

I finally removed a computer that I’ve had running for quite a while, configuring another “intermittently operational” system to run all the time.  I’d like to have the old system run as a VirtualBox VM on the new system.  My VirtualBox VMs are running headless as services using VboxVMService.  Further, one of my VirtualBox VMs runs an Ubuntu guest which itself runs Linux Containers guests for some small, lightweight hosts on my network.

I’ve got a couple of existing LXC guests that do some monitoring for me using Nagios, run a Gitlab instance, and a couple of others that I no longer need and will probably remove.  I’d also like to set up a couple of new hosts to run a small, simple webserver for my home network “homepage” with links to things I commonly use and a Puppet system to manage my configurations a little bit more efficiently (especially credentials if I look to expand the number of Linux hosts on my network; I’d like the logins to be maintained automatically, and very preferably to be key based).

My straight Nagios monitoring takes a bit more thought to maintain than I’d like, given the number of things on my mind at any given time, so that’s one of the first things I’d like to simplify.  However, from the point of view of simplicity, creating a dead simple web host (though I’d like to eventually integrate some DNS service discovery…) is the simplest.

I spun up a new, basic LXC with Apache, RCS, and a few Perl modules to load Foswiki onto for a basic intranet home page.

Finally attempting to spin a new VM from the command line… fails

VBoxVMService does not allow you to run the VirtualBox GUI at the same time, as I understand it.  As such, I assume that I will need to create any new native (non-LXC) guests I require from the command line.  This Oracle reference describes how to configure the VM instances from the CLI using the ‘vboxmanage’ command.  However, upon issuing a ‘vboxmanage list ostypes’ command, I discovered that even the CLI version appears to be dependent upon the same COM configuration that prevents the GUI from running.  So, I configured as stated at http://sourceforge.net/p/vboxvmservice/wiki/Runing%20VirtualBox%20GUI%20together%20with%20VBoxVmService/.  This didn’t take immediately, so I restarted.

Numerous hassles

I had a lot of problems being able to get back into VirtualBox to work on setting up a VM to replace the machine I took down, generally appearing to be related to permissions.  I’d run across a batch file that someone had written that supposedly sets the permissions appropriately to allow you to switch back and forth between the VirtualBox GUI and VBoxVMService, but it didn’t seem to be very effective.  I was finally successful after uninstalling VirtualBox, deleting the VirtualBox directory, reinstalling, then going into DCOMConfig and setting permissions back to defaults (everything on Security tab as “Use Defaults” and the Identity tab as “Launching User”).  That let me get back in and do some things.

Using a physical/raw disk in a VM

I referenced these instructions to configure the disk I had pulled from my old system as a raw disk for the VM.  A couple of notes on items that proved handy:

  • The command wmic diskdrive list brief under Windows 7 helps to identify the correct PhysicalDrive setting to use in creating the VMDK.
  • User Account Control under Windows 7 is a turd for configuring the physical disk as a VMDK.  I was able to get around this by going into User Accounts -> Change User Account Control Settings and slid the bar all the way to the bottom – i.e., don’t prompt me for anything (I didn’t reboot as the system told me I had to).  I was then able to create the VMDK under my local account, which has administrative privileges (previously I had received the error “VBoxManage.exe: error: Cannot open the raw disk ‘\\.\PhysicalDrive1’: VERR_ACCESS_DENIED
    VBoxManage.exe: error: The raw disk vmdk file was not created” under my own account and “VBoxManage.exe: error: Failed to create the VirtualBox object!
    VBoxManage.exe: error: Code CO_E_SERVER_EXEC_FAILURE (0x80080005) – Server execution failed (extended info not available)
    VBoxManage.exe: error: Most likely, the VirtualBox COM server is not running orfailed to start” under a “runas administrator” command window.

This was a great idea until I determined that I couldn’t (or at least there wasn’t a method I could find) grant my user account raw/physical disk access under Windows 7 Home.  I can run VirtualBox as an administrator and launch the machine, booting from the physical drive, and everything works.  Unfortunately I’d prefer not to run as an administrator, so I will probably need to work on converting the physical disk to an image.  My goal is ultimately to get everything copied off of that drive anyway and eliminate the machine; I had just thought this might be a shortcut to save a step or two.

Be the first to comment