Monday, September 29, 2014

Expanding a KVM guest disk without LVM!

I recently ran out of space on my primary home server kernel virtual machine (Linux Mint) because I created the disk with a paltry 20G of space. To remedy this, I decided to add 30 additional gigabytes. The following are the steps I took.

Note that step 4 is potentially dangerous (specifically deleting and then re-creating the root partition), and setting the system up with LVM would have prevented me having to do it but if you are following this guide you are in the same situation and can't really benefit from could have/should have thoughts. :-) Anyway, everything worked fine when I was done.

  1. Shut down the guest (on host)
    1. virsh -connect qemu:///system
    2. shutdown your-guest-domain-name
  2. Expand virtual disk (on host)
    1. qemu-img resize guest-disk.img +30G
  3. Restart virtual machine (on host)
    1. virsh -connect qemu:///system
    2. start your-guest-domain-name
  4. Expand ext4 partition and filesystem on bare disk (on the guest)
    1. I followed this guide to the letter to resize the root os partition, reboot, and then expand the filesystem


Jawbone UP24 App Crashing After Personalization

Recently I got a nice large persimmon Jawbone UP 24 after seeing how useful my wife's was for fitness and sleep tracking, and the persimmon color is pretty cheap and looks good on either sex. Unfortunately, I was very frustrated trying to get it to work with my Android-based Oneplus One due to app issues preventing me from completing the setup. After lots of trial and error, I finally figured out an odd set of steps that got it working:


  1. If you haven't signed up for an account already, sign-up in the app. During signup the app may become non-responsive and crash. This is fine.
  2. Now sign-up again with the same account information and uncheck the e-mail notifications before proceeding. If you are getting a message about the account already existing, something is different than what I ran into and my solution probably won't work.
  3. When you hit next/okay at this point it may just return you to the e-mail/password screen. Keep at it, eventually it will move on. I theorize that something at this stage causes the problem to be resolved.
  4. Run through personalization, and you will be rewarded by it completing successfully.


Thursday, September 4, 2014

RDP broken on Linux Mint (possibly after upgrading)

Background:
I am a fan of SSH of course, but RDP is pretty rock solid and easy to set up for remote desktop sessions and has given me a lot less trouble than nomachine setup that I used to use.

Problem
You used to have nice RDP sessions to your Linux server with xrdp. However, suddenly you get to a grey or checkerboard screen with an X for your cursor that never goes away after entering your login credentials. I encountered this after I took my main home server virtual machine from Mint 14 to Mint 17 in a single step.

Solution:
Specify the use of a mate session (if using mate) rather than an X11 session as described in this forum post.

Monday, February 10, 2014

nvidia-settings don't load on reboot

UPDATE:
This seems to no longer fix the problem for me lately after an upgrade to Mint 17, and I'm unsure why.

Problem: 

You are using an Ubuntu/Mint/Debian with an Nvidia driver (or perhaps another proprietary GPU driver), and your custom resolutions are lost at each restart even though you applied them and saved to xorg.conf. This frustrates you to no end, and even if you script a live modeline change putting your box to sleep or a reboot will mean it doesn't get automatically reapplied. Also, your settings don't get reloaded into the settings GUI after a reboot, and you are mystified.

Explanation: 
The built-in Mint Preferences > Displays tool doesn't give a crap about your custom configuration, and it will reload whatever it had set previously just to torture you. You can kill it with fire though. To see if it has a settings file look for a ~/.config/monitors.xml file.

Solution:
You may not need the first four steps, or you may have already performed them.

  1. sudo nvidia-xconfig    # create a fresh xorg.conf
  2. gksudo nvidia-settings # set it up like you wanted it; my overscan fix example
  3. Click "apply"
  4. Click "save to x-config file"
  5. rm ~/.config/monitors.xml  # get rid of the non-xorg Displays configuration
  6. restart
I have seen this problem again and again on forums where nobody knew that deleting that file would fix the problems. Spread the word my friends.

Wednesday, December 18, 2013

Apt-get behind a corporate proxy: A tale of Ironport, 401 errors, and NTLM

Problem:
I was trying to fetch packages via aptitude and apt-get, but I would get "ign" or "401 Authorization Required" when attempting it.  I knew we had a proxy set up and figured out where it was. I tried all the advice to use user:pass@domain as the http_proxy value directly to no avail, but NTLM was the way to get out in our Windows oriented shop. Oddly, wget would work to download the package indexes, but apt-get could not.


Solution:
A tool called cntlm creates a little proxy at a specified port on your box which handles authentication with the real proxy. I found a good guide here* for how to set it up, but see my notes and added clarification about the config parameters below. Keep in mind that there will be trial and error if you have an uncooperative network security team in your organization. I had to figure out where the proxy was, the port to use, and masquerade the server as my desktop workstation to get it all going. Good luck, and don't give up. Once you get the settings right, this works flawlessly.

Parameters in /etc/cntlm.conf:
    1. username - Active Directory username
    2. domain - Active Directory domain
    3. workstation - Name of the workstation (feel free to spoof this to that of another machine, NTLM can't stop you)
    4. proxy - the ip:port of the proxy
    5. listen - the local port to use for relaying your traffic 
* Note that the value in the -M parameter value in "cntlm -H -M" had to be something other than the proxy itself (eg http://test.com) in order to work for me.

* Note that the guide I linked shows two separate hashes for the password (PassNT and PassLM), but you may only get one with NTLMv2 (PassNTLMv2) as shown at the bottom of the cntlm page. This is fine, and just paste that one line into your /etc/cntlm.conf.

Sunday, July 7, 2013

Linux Mint Overscan Woes

I fired up Linux Mint 15 because my Ubuntu distribution was looking a bit dated, and it had developed an overscan problem where the edges of the screen went off the monitor. I am using an nvidia graphics card with nvidia drivers.

Problem: 
The overscan was all screwed up on my 23 inch Hannspree monitor. It was listed as device DFP-1, and no resolution I could use in the nvidia-settings GUI menu would resolve the problem.

Solution: 
I needed to set a metamode to fix the overscan. I headed over to this page, and the metamode suggested worked perfectly with "DFP-0" altered to
"DFP-1."

DFP-0: 1920x1080 { ViewPortOut=1820x1020+50+30, ViewPortIn=1920x1080 } 



  1. sudo nvidia-xconfig
  2. gksudo nvidia-settings

Then plug your custom resolution configuration into nvidia-settings like so. Note that I had to manually select the 1920x1080 resolution or the settings below it wouldn't work right:



After that, hit apply. Then click save to X configuration file.

If you lose your settings after a restart, then you may be experiencing a problem that plagued me for a long time. My solution is HERE.

Thursday, December 20, 2012

Simple KVM Server Virtualization

I want to virtualize a server from scratch. I have a server in mind already, but I don't want to bother with virtualizing it directly since it is running on a dated OS.  I figure I will build a new VM in parallel on some spare hardware and then migrate the image over to my beast server. Some key benefits of this are that I can use some of the spare capacity of that beast server to test out other server operating systems and software in parallel with my main server.  Also, I can install crashplan on the host itself and have it backup my server images for painless offsite backup whereas now I really don't have a backup of the physical server configs.

This guide will be devided into three stages as follows because this is the order I carried out the steps in.

  1. Set up a host CENTOS 6.3 server
  2. Set up a guest MINT 14 server (with MATE desktop)
  3. Set up a static bridged network and configure our VM to use it

1.Setting up host server

First thing, you should make sure your processor supports kvm virtualization. Install CENTOS 6.3 or later. I am not a redhat/centos guy for most of my home Linux systems, but it seems ideal for a VM host where I don't really need the latest and greatest packages and stability and concise configuration are key. I am assuming you can install this on your own with the graphical installer or however.

Now, we will need some special tools to get virtualization running.  As root, do the following on your fresh CENTOS box:

# I recommend you update your box first, this may take a while
yum update

# get the core virtualization pieces
yum groupinstall Virtualization "Virtualization Client" "Virtualization Platform" "Virtualization Tools"

# install and turn on the avahi daemon
yum install avahi
service avahi-daemon start
chkconfig avahi-daemon on

# I ran into this not being on.  The virt-manager just sat there trying to connect before I did this.
service libvirtd start
chkconfig libvirtd on

That's it, you are ready to virtualize!  Some people say you need to deactivate SELINUX, but some say it isn't needed.  You can do so by editing /etc/selinux/config if you think it is causing you troubles.

2.Setting up a guest server

This is pretty straight forward (except for the last little bit where we correct some video settings). Download  an ISO and/or burn it to a CD for the OS you want to install. In this example, I am using Linux Mint 14 with MATE desktop.

Open up the KVM manager tool you installed in step 1.


In the top left click play button on a monitor that says "Create a new virtual machine" when you hover over it.  Then, on the step 1 window name your server and pick ISO/CDROM.



On the step 2 windows, tell it where the ISO/CD is.  For OS type, just use Linux.  For version, go to "see all" and select the latest kernel available as shown.  The OS being installed is so far ahead (3.x) kernel, that there is no more up-to-date choice that I can tell.


On the step 3 window, set up your memory (give Mint 14 at least a gig) and select how many cores to set. There are ways to alter this later if you need to, so don't get too hung up on getting this just right now.  In my case, the host has too few cores and too little memory to set it up like I will after I migrate it to something more powerful.  


On the step 4 window, set up your storage. The default 8GB is probably a bit tight, 20GB+ may be better. After taking this screenshot, I chose 40GB. You don't have to "allocate entire disk now." I say let it grow dynamically.


On the step 5 window, review your selections and then hit finish.  If you carried out the final section of this guide before doing the VM setup, you could expand the Advanced options and choose your network now. However, I am trying to break this into quick chunks for time-crunched people like myself and getting your VM up feels like progress ;-).


Now launch your VM and install the OS as you would on a physical machine (except maybe more slowly and less responsively) in the window that pops up.  The blue "i" icon on the VM popup window (next to the terminal icon) will show you system stats and you can change things here.

I had an issue where every time I logged in, I got bounced back out.  To fix it, I had to do two things.  I did these out of order, so I don't know if they were both necessary.  I will share them in the opposite order I did them. If the first step works for you, don't bother with the second.

First, switch the virtual video adapter from cirrus to vga.


If you still can't login to the VM gui, then carry out this second part. At the login screen to your guest OS:
use the send menu to send ctrl alt f2           # to drop to virtual terminal on VM
login as root
apt-get install nvidia-current
reboot

After it reboots, it should work like a charm. Also, if you want to shut off the GUI later, you can always edit the /etc/inittab to prevent loading the GUI. I like having the option of the GUI on my servers since it really doesn't take up that much disk space and can be disabled as needed.

Your network should be set up fine for using this guest VM like a desktop to go on the internet, get updates, etc as long as your host's network is working right. Out of the box it gives you a virtual network using NAT which is fine for these purposes.  I could reach out to other boxes on my network just fine. The show-stopper for virtualizing a server, is that nothing else on my network can reach out to the VM except its own host.  In the next step, we fix that nonsense.

3.Setting up a bridged network

Okay, this was a bit foreign to me. I have used a wireless network bridge, but I never built a virtual bridge on a box off of a physical NIC before. I am doing something odd here in using a static IP for the bridge itself which nobody seemed to do in their guides, but it is easy enough.

I have to give some credit here as I got started with bridging using information from this site.  I also found a good reference on killing NetworkManager which doesn't play nice with your bridge.  Anyway, here is my condensed version.

As root on the host:

service NetworkManager stop
chkconfig NetworkManager off
chkconfig network on

Clear out any crappy config files you have like /etc/sysconfig/network-scripts/ifcfg-Auto_eth0 that were made by NetworkManager. 

vi /etc/syconfig/network-scripts/ifcfg-eth0   #(this may be different on your system if eth0 isn't your NIC)

DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
BRIDGE=br0
------------------------
vi /etc/syconfig/network-scripts/ifcfg-br0  # set up your static IP and DNS entries

DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
DNS1=192.168.0.1
DNS2=8.8.8.8
GATEWAY=192.168.0.1
IPADDR=192.168.0.205
NETMASK=255.255.255.0
ONBOOT=yes
DELAY=0
------------------------

Make sure you have DELAY=0 and ONBOOT=yes.  Usually DNS points to your router (gateway) and/or a service like google (8.8.8.8).


vi /etc/sysconfig/iptables  #edit the firewall definititions by adding a line
.....
-A INPUT -i lo -j ACCEPT  # EXISTING LINE
-A INPUT -i br0 -j ACCEPT # ADD LINE SIMILAR TO THE ABOVE EXCEPT CHANGE lo TO br0
.........

service network start  # should give all OK's
service iptables restart  # restart the firewall

Now you need to edit your VM settings. While the VM is off, open it and hit the blue "i" like we did to alter the video adapter. I used device model vertio because it was the default, but there may be merit in some of the other options. Anyway, go to the NIC device and set it up as shown:


Then click apply. Now you can boot up the guest OS and configure its network settings with a normal static IP or even DHCP. It will work just like it is on the network directly using its own NIC.

I hope this guide has been helpful for you. Feel free to offer any tips or improvements or ask questions. Now go forth and virtualize!