Skip to content

Instantly share code, notes, and snippets.

@JPalmerGithub
Forked from plembo/createkvmstoragepool.md
Created November 3, 2022 12:07
Show Gist options
  • Save JPalmerGithub/e32b0dc0ff2783278b6e1fcdd5f82c8c to your computer and use it in GitHub Desktop.
Save JPalmerGithub/e32b0dc0ff2783278b6e1fcdd5f82c8c to your computer and use it in GitHub Desktop.

Revisions

  1. @plembo plembo revised this gist Aug 29, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion createkvmstoragepool.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ $ virsh pool-list --all

    **NOTE: If a default pool already exists, follow [this gist](https://gist.github.com/plembo/5e108dc8000850442d756fc3747d31a3) to relocate it to your preferred storage volume.**

    Assuming you want the physical path of the new pool to be /data1/libvirt/images, create that directory (```sudo mkdir -p /data1/libvirt/images```) and run the following commands:
    Assuming no pre-existing default pool exists and you want the physical path of the new pool to be /data1/libvirt/images, create that directory (```sudo mkdir -p /data1/libvirt/images```) and run the following commands:

    ```bash
    $ virsh pool-define-as default dir --target "/data1/libvirt/images"
  2. @plembo plembo revised this gist Aug 29, 2022. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions createkvmstoragepool.md
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,8 @@ $ virsh pool-list --all
    -----------------------------
    ```

    **NOTE: If a default pool already exists, follow [this gist](https://gist.github.com/plembo/5e108dc8000850442d756fc3747d31a3) to relocate it to your preferred storage volume.**

    Assuming you want the physical path of the new pool to be /data1/libvirt/images, create that directory (```sudo mkdir -p /data1/libvirt/images```) and run the following commands:

    ```bash
  3. @plembo plembo revised this gist Aug 29, 2022. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions createkvmstoragepool.md
    Original file line number Diff line number Diff line change
    @@ -13,13 +13,12 @@ Assuming you want the physical path of the new pool to be /data1/libvirt/images,

    ```bash
    $ virsh pool-define-as default dir --target "/data1/libvirt/images"
    $ virsh pool-define-as default dir --target "/data1/libvirt/images"
    $ virsh pool-build default
    $ virsh pool-start default
    $ virsh pool-autostart default
    ```

    Check the configuration with virsh-info:
    Check the status with virsh-info:
    ```bash
    $ virsh pool-info default
    Name: default
    @@ -32,7 +31,7 @@ Allocation: 1.15 GiB
    Available: 914.66 GiB
    ```

    And then with pool-dumpxml:
    And then the configuration with pool-dumpxml:

    ```xml
    $ virsh pool-dumpxml default
  4. @plembo plembo revised this gist Aug 29, 2022. 1 changed file with 29 additions and 29 deletions.
    58 changes: 29 additions & 29 deletions createkvmstoragepool.md
    Original file line number Diff line number Diff line change
    @@ -9,47 +9,47 @@ $ virsh pool-list --all
    -----------------------------
    ```

    Assuming you want the physical path of the new pool to be /data1/libvirt/images, create that directory (```sudo mkdir -p /data1/libvirt/images```) and run the following command:
    Assuming you want the physical path of the new pool to be /data1/libvirt/images, create that directory (```sudo mkdir -p /data1/libvirt/images```) and run the following commands:

    ```bash
    $ virsh pool-define-as default dir --target "/data1/libvirt/images"
    $ virsh pool-define-as default dir --target "/data1/libvirt/images"
    $ virsh pool-build default
    $ virsh pool-start default
    $ virsh pool-autostart default
    ```
    $ virsh pool-define-as default dir --target /data1/libvirt/images
    ```
    Check the configuration:

    ```xml
    $ virsh pool-dumpxml default
    <pool type='dir'>
    <name>default</name>
    <uuid>a93c414a-5380-4f53-8236-a28b6d1e2ee8</uuid>
    <capacity unit='bytes'>0</capacity>
    <allocation unit='bytes'>0</allocation>
    <available unit='bytes'>0</available>
    <source>
    </source>
    <target>
    <path>/data1/libvirt/images</path>
    </target>
    </pool>
    Check the configuration with virsh-info:
    ```bash
    $ virsh pool-info default
    Name: default
    UUID: 8b806f67-87b4-403b-ae64-c652c0764641
    State: running
    Persistent: yes
    Autostart: yes
    Capacity: 915.82 GiB
    Allocation: 1.15 GiB
    Available: 914.66 GiB
    ```
    Compare this with a pool definition generated on the creation of the first image on another machine:

    And then with pool-dumpxml:

    ```xml
    $ virsh pool-dumpxml default
    <pool type='dir'>
    <name>default</name>
    <uuid>63eb0fa4-6b1e-40e2-92cf-41dced138fc7</uuid>
    <capacity unit='bytes'>3937758330880</capacity>
    <allocation unit='bytes'>836987985920</allocation>
    <available unit='bytes'>3100770344960</available>
    <uuid>8b806f67-87b4-403b-ae64-c652c0764641</uuid>
    <capacity unit='bytes'>983349346304</capacity>
    <allocation unit='bytes'>1238208512</allocation>
    <available unit='bytes'>982111137792</available>
    <source>
    </source>
    <target>
    <path>/data1/libvirt/images</path>
    <path>/d1/libvirt/images</path>
    <permissions>
    <mode>0711</mode>
    <owner>64055</owner>
    <group>108</group>
    <mode>0755</mode>
    <owner>0</owner>
    <group>0</group>
    </permissions>
    </target>
    </pool>
    ```
    You'll notice right away that there a few things missing here, like the capacity values and permissions for the directory. Everything should work without these, but what I do is edit the definition to at least set up the permissions.
  5. @plembo plembo renamed this gist Aug 29, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion relocatekvmstoragepool.md → createkvmstoragepool.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Relocate the default KVM storage pool for images
    # Create the default KVM storage pool for images
    Some distributions create the defaut KVM (libvirtd) storage pool for images when they install KVM, others do this upon the creation of the first KVM guest. Creating the default pool from scratch is pretty straightforward. Here's how to do it with virsh.

    First verify there is no existing default pool:
  6. @plembo plembo revised this gist Aug 29, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion relocatekvmstoragepool.md
    Original file line number Diff line number Diff line change
    @@ -52,4 +52,4 @@ Compare this with a pool definition generated on the creation of the first image
    </target>
    </pool>
    ```
    You'll notice right away that there a few things missing here, like the capacity values and permissions for the directory. Things should work without these, but what I do is edit the definition to at least set up the permissions.
    You'll notice right away that there a few things missing here, like the capacity values and permissions for the directory. Everything should work without these, but what I do is edit the definition to at least set up the permissions.
  7. @plembo plembo revised this gist Aug 29, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion relocatekvmstoragepool.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # Relocate the default KVM storage pool for images
    Some distributions create the defaut KVM (libvirt) storage pool for images when they install KVM, others do this upon the creation of the first KVM guest. Creating the default pool from scratch is pretty straightforward. Here's how to do it with virsh.
    Some distributions create the defaut KVM (libvirtd) storage pool for images when they install KVM, others do this upon the creation of the first KVM guest. Creating the default pool from scratch is pretty straightforward. Here's how to do it with virsh.

    First verify there is no existing default pool:

  8. @plembo plembo renamed this gist Aug 29, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion createdefkvmstoragepool.md → relocatekvmstoragepool.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Change the location of the default KVM storage pool for images
    # Relocate the default KVM storage pool for images
    Some distributions create the defaut KVM (libvirt) storage pool for images when they install KVM, others do this upon the creation of the first KVM guest. Creating the default pool from scratch is pretty straightforward. Here's how to do it with virsh.

    First verify there is no existing default pool:
  9. @plembo plembo revised this gist Aug 29, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion createdefkvmstoragepool.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Change the default KVM storage pool for images
    # Change the location of the default KVM storage pool for images
    Some distributions create the defaut KVM (libvirt) storage pool for images when they install KVM, others do this upon the creation of the first KVM guest. Creating the default pool from scratch is pretty straightforward. Here's how to do it with virsh.

    First verify there is no existing default pool:
  10. @plembo plembo revised this gist Aug 29, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion createdefkvmstoragepool.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Create the default KVM storage pool for images
    # Change the default KVM storage pool for images
    Some distributions create the defaut KVM (libvirt) storage pool for images when they install KVM, others do this upon the creation of the first KVM guest. Creating the default pool from scratch is pretty straightforward. Here's how to do it with virsh.

    First verify there is no existing default pool:
  11. @plembo plembo revised this gist Aug 28, 2022. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions createdefkvmstoragepool.md
    Original file line number Diff line number Diff line change
    @@ -27,7 +27,7 @@ $ virsh pool-dumpxml default
    <source>
    </source>
    <target>
    <path>/d1/libvirt/images</path>
    <path>/data1/libvirt/images</path>
    </target>
    </pool>
    ```
    @@ -43,7 +43,7 @@ Compare this with a pool definition generated on the creation of the first image
    <source>
    </source>
    <target>
    <path>/d1/libvirt/images</path>
    <path>/data1/libvirt/images</path>
    <permissions>
    <mode>0711</mode>
    <owner>64055</owner>
    @@ -53,4 +53,3 @@ Compare this with a pool definition generated on the creation of the first image
    </pool>
    ```
    You'll notice right away that there a few things missing here, like the capacity values and permissions for the directory. Things should work without these, but what I do is edit the definition to at least set up the permissions.

  12. @plembo plembo created this gist Jul 16, 2022.
    56 changes: 56 additions & 0 deletions createdefkvmstoragepool.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,56 @@
    # Create the default KVM storage pool for images
    Some distributions create the defaut KVM (libvirt) storage pool for images when they install KVM, others do this upon the creation of the first KVM guest. Creating the default pool from scratch is pretty straightforward. Here's how to do it with virsh.

    First verify there is no existing default pool:

    ```
    $ virsh pool-list --all
    Name State Autostart
    -----------------------------
    ```

    Assuming you want the physical path of the new pool to be /data1/libvirt/images, create that directory (```sudo mkdir -p /data1/libvirt/images```) and run the following command:

    ```
    $ virsh pool-define-as default dir --target /data1/libvirt/images
    ```
    Check the configuration:

    ```xml
    $ virsh pool-dumpxml default
    <pool type='dir'>
    <name>default</name>
    <uuid>a93c414a-5380-4f53-8236-a28b6d1e2ee8</uuid>
    <capacity unit='bytes'>0</capacity>
    <allocation unit='bytes'>0</allocation>
    <available unit='bytes'>0</available>
    <source>
    </source>
    <target>
    <path>/d1/libvirt/images</path>
    </target>
    </pool>
    ```
    Compare this with a pool definition generated on the creation of the first image on another machine:

    ```xml
    <pool type='dir'>
    <name>default</name>
    <uuid>63eb0fa4-6b1e-40e2-92cf-41dced138fc7</uuid>
    <capacity unit='bytes'>3937758330880</capacity>
    <allocation unit='bytes'>836987985920</allocation>
    <available unit='bytes'>3100770344960</available>
    <source>
    </source>
    <target>
    <path>/d1/libvirt/images</path>
    <permissions>
    <mode>0711</mode>
    <owner>64055</owner>
    <group>108</group>
    </permissions>
    </target>
    </pool>
    ```
    You'll notice right away that there a few things missing here, like the capacity values and permissions for the directory. Things should work without these, but what I do is edit the definition to at least set up the permissions.