Persistent Disk Storage Tutorial

Prerequisites

To use the command line interface, it must be installed on your machine. Please use the referenced package stratuslab-cli-user-1.9* or later for working with the Persistent Disk Storage. Note: The StratusLab command line interface requires Python 2.6 or later.

Create persistent disk

Before creating persistent disks, you should provide the persistent disk storage endpoint in your $HOME/.stratuslab/stratuslab-user.cfg,

or set the environment variable STRATUSLAB_PDISK_ENDPOINT with the persistent disk storage endpoint you want to use,

or pass it as argument to stratus-create-volume command when creating one.

Create a persistent disk with the following properties :

  • size = 5GB
  • tag = myprivate-disk
PROMPT> stratus-create-volume --size=5 --tag=myprivate-disk
DISK 9c5a2c03-8243-4a1b-a248-0f0d22d948c2

stratus-create-volume return the UUID (in the above command: 9c5a2c03-8243-4a1b-a248-0f0d22d948c2) of the created persistent disk. By default all the persistent disks are private, which means they could be read, written and deleted only by their owner.

If you want other users have access (read and write only ) to your persistent disks, set it to be public.

To create public persistent disk, pass –public argument to stratus-create-volume.

PROMPT> stratus-create-volume --public --size=10 --tag=mypublic-disk
DISK d955fda6-bf9c-4aa8-abc4-5bbcdb83021b

List persistent disks

stratus-describe-volumes allow you to query the list of all your public and private persistent disks, and also all the public peristent disks created by other users.

here is an example

PROMPT> stratus-describe-volumes 
:: DISK a4324f26-39e0-4965-8c8f-3287cd0936e5
        created: 2011/07/20 16:37:10
        visibility: public
        tag: mypublic-disk
        owner: testor2
        size: 5
        users: 0
:: DISK 9c5a2c03-8243-4a1b-a248-0f0d22d948c2
        created: 2011/07/20 16:10:37
        visibility: private
        tag: myprivate-disk
        owner: testor1
        size: 5
        users: 0
:: DISK d955fda6-bf9c-4aa8-abc4-5bbcdb83021b
        created: 2011/07/20 16:26:31
        visibility: public
        tag: mypublic-disk
        owner: testor1
        size: 5
        users: 0

The above command list 'testor1' public and private persistent disks, and also testor2 public ones.

Using Persistent Disks

Workflow:

  • Launch a virtual machine instance referencing a persistent disk.
  • Format (mkfs) the disk via the running VM
  • Store data to the disk as usual
  • Dismount the disk or halt the machine instance
  • Disk with persistent data is available for use by another VM

To Launch a VM we will be using the ttylinux-9.7 image identifier GOaxJFdoEXvqAm9ArJgnZ0_ky6F from StratusLab Marketplace (default one).

–persistent-disk=UUID option when used with stratus-run-instance, tell StratusLab to attach the referenced persistent disk(UUID) to the VM.

Instantiate ttylinux-9.7 image with reference to your private persistent disk 9c5a2c03-8243-4a1b-a248-0f0d22d948c2.

stratus-run-instance --persistent-disk=9c5a2c03-8243-4a1b-a248-0f0d22d948c2 GOaxJFdoEXvqAm9ArJgnZ0_ky6F

 :::::::::::::::::::::::::
 :: Starting machine(s) ::
 :::::::::::::::::::::::::
 :: Starting 1 machine
 :: Machine 1 (vm ID: 3)
        Public ip: 134.158.75.35

Log into your VM using ssh, depending in the linux kernel and distribution version of your VM, your persistent disk will be referenced as /dev/hdc or /dev/sdc.

In ttylinux9-7, it will be /dev/hdc.

Make sure that your disk was attached to your VM

ssh root@134.158.75.35
# fdisk -l 
.........
Disk /dev/hdc: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
.........

Format your disk

# mkfs.ext3 /dev/hdc

Mount your disk and store data, store data into and dismount it

# mount /dev/hdc /mnt
# echo "Testing Persistent Disk" > /mnt/test_pdisk
# umount /mnt 

Your persistent disk is ready to use by another VM.

Instantiate new VM ttylinux-9.7 with the same reference to your private persistent disk 9c5a2c03-8243-4a1b-a248-0f0d22d948c2.

stratus-run-instance --persistent-disk=9c5a2c03-8243-4a1b-a248-0f0d22d948c2 GOaxJFdoEXvqAm9ArJgnZ0_ky6F

 :::::::::::::::::::::::::
 :: Starting machine(s) ::
 :::::::::::::::::::::::::
 :: Starting 1 machine
 :: Machine 1 (vm ID: 4)
        Public ip: 134.158.75.36

Log into your VM using ssh, verify existence of your persistent disk

ssh root@134.158.75.35
# fdisk -l
...........
Disk /dev/hdc: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
...........

Mount your persistent disk

# mount /dev/hdc /mnt
# ls /mnt
lost+found  test_pdisk
# cat /mnt/test_pdisk 
Testing Persistent Disk

Hot-plug Persistent Disks

StratusLab storage also provides hot-plug feature for persistent disk. With stratus-attach-instance you can attach a volume to a running machine and with stratus-detach-instance you can release it.

To use the hot-plug feature, the running instance needs to have acpiphp kernel module loaded. Image like ttylinux doesn't have this feature, you have to use base image like Ubuntu, CentOS or Fedora.

Before hot-plugin a disk, make sure acpiphp is loaded. In your VM execute:

 modprobe acpiphp

This will launch the module if it was not running.

To attach two volumes to the VM ID 24, the first with the UUID 1e8e9104-681c-4269-8aae-e513c6723ac6 and the second with the UUID 5822c376-9ce1-434e-95d1-cdaa240cd47c:

 PROMPT> stratus-attach-volume -i 24 1e8e9104-681c-4269-8aae-e513c6723ac6 5822c376-9ce1-434e-95d1-cdaa240cd47c
 ATTACHED 1e8e9104-681c-4269-8aae-e513c6723ac6 in VM 24 on /dev/vda
 ATTACHED 5822c376-9ce1-434e-95d1-cdaa240cd47c in VM 24 on /dev/vdb  

You can use the fdisk -l command as above to see the newly attached disks.

Make sure to unmount any file systems on the device within your operating system before detaching the volume. Failure to unmount file systems, or otherwise properly release the device from use, can result in lost data and will corrupt the file system.

 umount /dev/vda
 umount /dev/vdb

When you finish using your disks, you can detach them from the running VM:

 PROMPT> stratus-detach-volume -i 24 1e8e9104-681c-4269-8aae-e513c6723ac6 5822c376-9ce1-434e-95d1-cdaa240cd47c
 DETACHED 1e8e9104-681c-4269-8aae-e513c6723ac6 from VM 24 on /dev/vda
 DETACHED 5822c376-9ce1-434e-95d1-cdaa240cd47c from VM 24 on /dev/vdb

Perhaps you have already try to detach a disk that you have attach at start-up. The detach command throws you an error message if you do so:

 PROMPT> stratus-detach-volume -i 41 2a17226f-b006-45d8-930e-13fbef3c6cdc
 DISK 2a17226f-b006-45d8-930e-13fbef3c6cdc: Disk have not been hot-plugged

If you have attached the volume at instance start-up, it cannot be detached while the instance is in the ‘running’ state. To detach the volume, stop the instance first.

Delete Persistent Disks

To delete a persistent disk you can use the stratus-delete-volume command, note that you can delete only yours.

To delete myprivate-disk (UUID=9c5a2c03-8243-4a1b-a248-0f0d22d948c2)

PROMPT> stratus-delete-volume 9c5a2c03-8243-4a1b-a248-0f0d22d948c2
DELETED 9c5a2c03-8243-4a1b-a248-0f0d22d948c2

List the existing persitent disks

PROMPT> stratus-describe-volumes 
:: DISK a4324f26-39e0-4965-8c8f-3287cd0936e5
        created: 2011/07/20 16:37:10
        visibility: public
        tag: mypublic-disk
        owner: testor2
        users: 0
        size: 5
:: DISK d955fda6-bf9c-4aa8-abc4-5bbcdb83021b
        created: 2011/07/20 16:26:31
        visibility: public
        tag: mypublic-disk
        owner: testor1
        users: 1
        size: 5

Now try to delete mypublic-disk testor2 persitent disk

PROMPT> stratus-delete-volume a4324f26-39e0-4965-8c8f-3287cd0936e5
  [ERROR] Service error: Not enough rights to delete disk

You aren't the owner, so you don't have rights to do.

  • Bookmark at
  • Bookmark "Persistent Disk Storage Tutorial" at del.icio.us
  • Bookmark "Persistent Disk Storage Tutorial" at Digg
  • Bookmark "Persistent Disk Storage Tutorial" at Reddit
  • Bookmark "Persistent Disk Storage Tutorial" at Google
  • Bookmark "Persistent Disk Storage Tutorial" at StumbleUpon
  • Bookmark "Persistent Disk Storage Tutorial" at Facebook
  • Bookmark "Persistent Disk Storage Tutorial" at Twitter