Resizing a LVM install of Ubuntu 13.10 for Windows 7 Dual-Boot

I have Ubuntu 13.10 installed on my computer.  I had done a fresh install and used the LVM filesystem.  I now want to install Windows 7 on the same drive.  Apparently this isn’t so simple as one might think.

Here are 2 good resources on LVM


  1. Get Ubuntu Live CD / USB to boot from (this information can be found elsewhere online ( via windows or via ubuntu )
  2. Boot up Live OS
  3. Open terminal
  4. Run command
    sudo lvdisplay

    This should show you the layout of your logical volumes.  With my install this displayed as
    — Logical volume —
    LV Path                /dev/ubuntu-vg/root
    LV Name                root
    VG Name                ubuntu-vg

    — Logical volume —
    LV Path                /dev/ubuntu-vg/swap_1
    LV Name                swap_1
    VG Name                ubuntu-vg

    Here we can see that /dev/ubuntu-vg/root and /dev/ubuntu-vg/swap_1 are what I will need to resize/move first

  5. Run command
    sudo lvreduce --resizefs --size -250G /dev/ubuntu-vg/root

    lvreduce will shrink the root ( “/” ) logical volume by the size specified by ‘–size -XG’ where X is the number of gigabytes.  The size of the logical volume before was ~450 GB, so this shrinks it down to ~200 GB.

  6. Now we need to move the swap volume ( /dev/ubuntu-vg/swap_1 ) so that is is no longer all the way at the opposite end of the physical volume.  Here is a good explanation of how this (slightly) complicated process works.
    We run this command

    lvdisplay --map

    which will display the range that the logical volumes take up and it will display something like

    — Segments —
    Logical extent 0 to 639:
    Type linear
    Physical volume /dev/sda5
    Physical extents 0 to 639
    — Segments —
    Logical extent 0 to 31:
    Type linear
    Physical volume /dev/sda5
    Physical extents 1544 to 1575

  7. Now run the command
    pvmove --alloc anywhere /dev/sda5:1544-1575 /dev/sda5:640-671

    which will move the logical volume of /dev/ubuntu-vg/swap_1 (the second segment listed) to be positioned exactly next to /dev/ubuntu-vg/root (the first segment listed).  You will want to replace the values here with the ones that lvdisplay shows you.  These are not my values, these are pulled from the explanation linked above.  Now that you have all your logical volumes moved to be contiguous in the physical volume, you can go into GParted and resize the physical volume.

  8. Open GParted and when it loads right click /dev/sda5 and select “Deactivate”.
  9. Right click /dev/sda5 and select Resize/Move.  Move the right hand slider all the way to the left edge of the used space of the physical volume.  Apply the changes.
  10. Right click /dev/sda2 and select Resize/Move.  Move the right hand slider all the way to the left edge of the used space of the physical volume.  Apply the changes.
  11. You should now have unallocated space following /dev/sda2.  You can now create a new NTFS partition with that space to install windows on.

You will now need to follow the steps indicated in Install Windows after Ubuntu to handle Windows overwriting the MBR/Grub.


Create Launcher for Aptana Studio 3 in Ubuntu 13.10 with menus fixed for Unity

I followed the steps in this video “Install Aptana Studio 3 on Ubuntu” on youtube (link no longer available) which explains how to set up a launcher in Ubuntu with an icon so that you can start Aptana from the dock launcher or search for the application.

Unfortunately there is a known bug in Ubuntu currently for Aptana 3’s menus that seems to have been around for awhile.

The fix that has been posted works but it isn’t convenient.  I don’t want to have to open a terminal window to launch Aptana and then have to keep that window open and unusable.

What I did was to edit the .destkop file for Aptana that was created in the video linked above.

Follow the instructions here to create the aptana.desktop file using these commands…

sudo nano /usr/share/applications/aptana.desktop

And copy this code into the aptana.desktop file

[Desktop Entry]
Comment=Aptana Studio 3
Icon=/opt/Aptana_Studio_3/icon.xpm <- replace this whit the ABSOLUTE path in which you unpacked aptana
Exec=/opt/Aptana_Studio_3/AptanaStudio3 <- the same applies here, replace with the ABSOLUTE path

Except I changed/added these lines.

Exec=/usr/bin/runaptana %F

And then I created the bash script, that was explained in the second set of links above

sudo nano /usr/bin/runaptana

I added these lines to the script


And made a symbolic link from /usr/bin/AptanaStudio3 to the application

ln -s /opt/Aptana_Studio_3/AptanaStudio3 /usr/bin/AptanaStudio3

You can rename it to a .sh file if you want but you will need to change the path in the .desktop file as well.

Make sure that the runaptana file is given executable rights

sudo chmod u+x /usr/bin/runaptana

Now when I search in the Unity launcher, the Aptana Studio 3 icon shows up AND when I run it the application has functioning menus.

Object reference not set to an instance of an object – Stored Procedures

After making some changes to accounts and permissions on a webserver running an application I found that when trying to log in I received this error back from the webserver.

“Object reference not set to an instance of an object.”

The login process calls several stored procedures on the SQL Server (2005) that authenticate and grab user information.  These stored procedures need to run under the Network Service account on the server which hosts both the webserver and the database.

After doing some quick searching, this error often implies, at least with stored procedures, that the procedure is not returning valid data to the object intended to store the results.  I checked permissions on the SQL Server instance and found that Network Service did not ‘Execute’ permissions on the database so the stored procedures required for login were not running and therefore not returning data.

I gave execute permissions to the schema that Network Service is a member of on the required database and the application worked once more.

I’m curious as to what would have happened that removed these permissions from the account in the first place as the application was working fine before applying these OS and SQL Server updates and changing the account settings.  I know something changed along the way but I’m not certain what.

Reporting Services 2005 Web Portal Problem

I was attempting to get a malfunctioning report server running correctly.  Whenever I would try to load localhost/reports, I would get an error back stating

“The report server is not responding. Verify that the report server is running and can be accessed from this computer”

I checked suggestions here : which said to make sure file permissions were set correctly on the report server folders under the MSSQL installation directory for the Network Service account, but those permissions should already be set for the SQLServer2005ReportingServicesWebServiceUser$ group of which Network Service is a member.

I then found some references on the web suggesting to check the event log on the server to see what the error was.

The error that was occurring each time I tried to load the web portal page for the report server was “The page must have a <%@ webservice class=”MyNamespace.MyClass” … %> directive”, with a Request URL of “http://localhost/ReportServer/ReportService2005.asmx&#8221;.

After doing a little more searching I found out that this .asmx file can become corrupted (or edited, I suppose?) and this would cause the error I was seeing.  I copied the .asmx file from another server on which I have reporting services installed and overwrote the corrupted version.

Presto!  The web portal loads.