12.5.4. Creating an iSCSI-based Storage Pool with virsh
Use pool-define-as to define the pool from the command line
Storage pool definitions can be created with thevirsh
command line tool. Creating storage pools withvirsh
is useful for systems administrators using scripts to create multiple storage pools.Thevirsh pool-define-as
command has several parameters which are accepted in the following format:virsh pool-define-as name type source-host source-path source-dev source-name target
virsh pool-define-as name type source-host source-path source-dev source-name target
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The parameters are explained as follows:- type
- defines this pool as a particular type, iscsi for example
- name
- must be unique and sets the name for the storage pool
- source-host and source-path
- the host name and iSCSI IQN respectively
- source-dev and source-name
- these parameters are not required for iSCSI-based pools, use a - character to leave the field blank.
- target
- defines the location for mounting the iSCSI device on the host physical machine
The example below creates the same iSCSI-based storage pool as the previous step.virsh pool-define-as --name scsirhel6guest --type iscsi \ --source-host server1.example.com \ --source-dev iqn.2010-05.com.example.server1:iscsirhel6guest
# virsh pool-define-as --name scsirhel6guest --type iscsi \ --source-host server1.example.com \ --source-dev iqn.2010-05.com.example.server1:iscsirhel6guest --target /dev/disk/by-path Pool iscsirhel6guest defined
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the storage pool is listed
Verify the storage pool object is created correctly and the state reports asinactive
.virsh pool-list --all
# virsh pool-list --all Name State Autostart ----------------------------------------- default active yes iscsirhel6guest inactive no
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Start the storage pool
Use the virsh commandpool-start
for this.pool-start
enables a directory storage pool, allowing it to be used for volumes and guest virtual machines.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Turn on autostart
Turn onautostart
for the storage pool. Autostart configures thelibvirtd
service to start the storage pool when the service starts.virsh pool-autostart iscsirhel6guest
# virsh pool-autostart iscsirhel6guest Pool iscsirhel6guest marked as autostarted
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the iscsirhel6guest pool has autostart set:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the storage pool configuration
Verify the storage pool was created correctly, the sizes reported correctly, and the state reports asrunning
.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
An iSCSI-based storage pool is now available.