ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Expanding the Size of Disk Volume on a Hyper-V Linux Guest.

Updated on August 3, 2011

Oh no I've run out of space on my Linux Guest

If you're a Microsoft specialist and you've been setting up Hyper-V servers with Windows Guests then your more than likely come across the scenario of running out of disk space on your virtual guests. Now for Windows guests the task of expanding the virtual guests disk size is pretty easy but if you need help with that see my other hub - How to increase the size of my Hyper-V Windows Guest Disk.

Now you may have decided to run a couple of Linux systems on your Hyper-V host and because they work quite well you've also run out of space on one of those too. So how on earth do we increase the disk space on one of these machines.

Hyper-V Edit Disk Menu

Expanding the Virtual Hard Disk (VHD) File

Our first step is obviously to increase the size of the VHD File for that particular Linux Guest, just like you would if it were a Windows Guest. Make sure you shut down the Linux Guest before you start and I would advise taking a copy of the VHD file before we begin as a backup.

Next open up your Hyper-V manager and click on Edit Disk on the right hand side under Actions. On the Welcome screen just click next then click the Browse button and find your VHD file for your Linux Guest. Click next again and choose Expand from the 3 options and click next. Now you want to enter the new size that you would like to make the hard disk. Click next when you are done and confirm the summary details are correct and click finish.

Now you're going to need to wait while the VHD file is Expanded this can take quite some time depending on how much bigger you have made the disk.

Linux LVM Partitions in CFDISK

Extending the Extended Partition and adding a Logical Partition

Confused yet, well I was until I found this great tool called cfdisk which makes this job a lot easier. So now that you've expanded the VHD file you can boot the Linux Guest again and log in. Next we are going to use a program called cfdisk, now your server may not have this yet so you'll have to install it with either YUM or APT-GET.

Now that CFDISK is installed we simply type
cfdisk /dev/hda
cfdisk /dev/sda
Depending on your Linux Distribution.

You will then be presented with a screen similar to the image above.
You should see the space that you just added to the VHD file as Free Space at the end of your Disk. Now what we want to do is add a new Logical Partition to the HDA/SDA disk. So use the cursor to highlight the Free Space at the bottom of the list and choose New from the bottom menu. Next choose Logical for the partition type and enter the size you would like to make it then press enter. This will create a new logical partition with the File System type of Linux, next we need to change this to a Linux LVM File System Type. So choose Type from the bottom menu, press enter to continue, then enter 8e as the Filesystem Type. Next we just need to write the new Partition Table out, so choose Write from the Menu and confirm.

Linux LVDISPLAY Command Results

Increasing the LVM Logical Volume Size

Now that we have increased the size of our Virtual Hard Disk (VHD), we have created a new Logical Partition to store the data on, our last step is to expand the LVM Volume.

First we need to initialize the new Physical Volume for use with LVM by using this command
pvcreate /dev/hda? (? is whatever number you created using the CFDISK tool) or
pvcreate /dev/sda?

Next we need to run

This will give you an output similar to the picture above. From this we need to get the VG Name of the volume you need to add the space to, i.e. web2 in my case. To add the new partition to the Volume Group simply run the following command

vgextend web2 /dev/hda? (where WEB2 is your VG Name and ? is the Partition you created earlier)

Next we need to add the new partition space to the Logical Volume. Most people will want to add this to the Root LV but you may also have a Home LV. To do this we run the following command

lvresize -l +100%FREE /dev/web2/root (where /dev/web2/root is the LV Name of the volume you want to increase)

Linux DF -H Command

Online Expansion of Linux File System

Well if you've made it to this step congratulations, this final step involves expanding the Linux File System to make use of the new free space we just added. This can be run safely even while the machine is booted. Simply type the following command to perform the online resize.

resize2fs /dev/web2/root (where /dev/web2/root is your LV Name from the previous section)

Lastly you can run a DF -H command to view your new free space (see the image above)

Thanks for reading my post and as always if you have any issues feel free to leave a comment or contact me through my webpage One IT - IT Services and I'll help you out.


    0 of 8192 characters used
    Post Comment
    • profile image


      4 years ago

      Hi there,

      Thank you very much for the guide. Had been going well up until I had to do the lvdisplay. I type the command, but nothing shows - just goes to the next line in the terminal. Do you have any clues as to what I need to do to get the info required to move forward?

      I am running ubuntu 15.10.

      Thanks very much for your help,


    • profile image


      6 years ago

      I'm a Linux noob and this was INCREDIBLY helpful. Thank you very much for your time and effort!

    • profile image


      6 years ago

      Oneit, ty for the write up and pictures.

      For the rebooting issues, it depends on the linux distro.


    • profile image

      Cuong Tran 

      7 years ago

      Thank u very much. I did it

    • profile image


      7 years ago

      THANK YOU! I was looking everywhere for easy to follow instructions. Your post was the best and easiest to follow!

    • profile image


      8 years ago

      It's not working for me: after expanding I get:

      Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

    • Oneit profile imageAUTHOR

      One IT Ltd 

      8 years ago from Auckland

      I can't remember needing to reboot before I was able to run the 'pvcreate /dev/hda' command, next time I need to expand I'll make note of if it is needed.

    • profile image


      8 years ago

      Thanks for the write up. As with Mark I'm also new to the Linux world and needed to expand a disk running on Hyper-V. I tried a few other articles somehow corrupting the disk in the process, (not a huge issue when you have backups!).

      Also as Mark says I had to rboot before the 'pvcreate /dev/hda?' command. I'm running ubuntu, (if it makes a difference).

      Everything seems to be working okay but I did get messages saying 'Found duplicate PV......' so that's the next thing to learn....

      Thanks again.

    • profile image


      8 years ago

      What tool you use to create a VHD for linux. I want to move my existing red hat 6.0 enterprise server to hyper v.

    • Oneit profile imageAUTHOR

      One IT Ltd 

      8 years ago from Auckland

      Hi Mark, glad I was able to help. When you say you had to reboot before you could initialize the physical volume at what stage was this, after increasing the size of the VHD? I don't recall needing to do any initialization.

    • profile image


      8 years ago

      Being relatively new to the Linux world this was an outstanding write-up. Except for one thing, I had to reboot before I could initialize the physical volume...not a big deal and truly made my life much easier. I didn't have to build a new server. Thanks.


    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at:

    Show Details
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the or domains, for performance and efficiency reasons. (Privacy Policy)
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
    ClickscoThis is a data management platform studying reader behavior (Privacy Policy)