XenServer will create sparse disks for your VMs only on NFS based volumes. If you are using ISCSI or local storage, it will fully allocate each disk. This is less of a problem when you have a thinly provisioned ISCSI volume which is also compressed (such as those provided by Nexenta/OpenSolaris), but when you have a limited amount of local storage, it's unfortunate that XenServer doesn't give you the option to create sparse disks.
Luckily, XenServer is just CentOS 5 under the hood, and we can turn the local storage into an NFS volume.
First we will need to delete the current Local Storage, which involves quite a few steps.
2 --- Logical volume ---
3 LV Name /dev/VG_XenStorage-877a1f66-59dd-b1ba-0de3-d8a753d0a0b2/MGT
4 VG Name VG_XenStorage-877a1f66-59dd-b1ba-0de3-d8a753d0a0b2
5 LV UUID HlifV3-7B6J-rVCp-pAxP-Rc7e-viEQ-Tt819a
6 LV Write Access read/write
7 LV Status NOT available
8 LV Size 4.00 MB
9 Current LE 1
10 Segments 1
11 Allocation inherit
12 Read ahead sectors auto
2uuid ( RO) : e06a37a5-e1e6-4415-134e-f5ae4f7f7c17
3 host-uuid ( RO): 99ae2c2e-b992-4b4d-a09d-15cba5483225
4 sr-uuid ( RO): fc8c8fc5-4a06-18b9-517d-f19a18e50820
5 device-config (MRO): location: /dev/xapi/cd
6 currently-attached ( RO): true
7
8
9uuid ( RO) : 7a75d1b9-9aa5-d5f7-6b85-50d1175054c8
10 host-uuid ( RO): 99ae2c2e-b992-4b4d-a09d-15cba5483225
11 sr-uuid ( RO): a6db482a-5446-3fc3-6513-6933eb9d7915
12 device-config (MRO): location: /dev/xapi/block
13 currently-attached ( RO): true
14
15
16uuid ( RO) : 6c1eeeb0-3c05-fbee-4dca-e7490e007504
17 host-uuid ( RO): 99ae2c2e-b992-4b4d-a09d-15cba5483225
18 sr-uuid ( RO): f663b0ec-56b0-72dc-d546-4e0fc9be7ef6
19 device-config (MRO): location: /opt/xensource/packages/iso; legacy_mode: true
20 currently-attached ( RO): true
21uuid ( RO) : 825bc0eb-8ec9-01ab-e249-21146d66dd9a
22 host-uuid ( RO): 99ae2c2e-b992-4b4d-a09d-15cba5483225
23 sr-uuid ( RO): 877a1f66-59dd-b1ba-0de3-d8a753d0a0b2
24 device-config (MRO): device: /dev/disk/by-id/scsi-SATA_WDC_WD800JD-75M_WD-WMAM9AJ38489-part3
25 currently-attached ( RO): true
As we can see, it's the last one. Now we unplug it and destroy it.
2#xe pbd-destroy uuid=825bc0eb-8ec9-01ab-e249-21146d66dd9a
Now lets destroy the storage repository attached to it. First we get a list of the repositories.
2uuid ( RO) : a6db482a-5446-3fc3-6513-6933eb9d7915
3 name-label ( RW): Removable storage
4 name-description ( RW):
5 host ( RO): xenserver-ueyqfddq
6 type ( RO): udev
7 content-type ( RO): disk
8
9
10uuid ( RO) : fc8c8fc5-4a06-18b9-517d-f19a18e50820
11 name-label ( RW): DVD drives
12 name-description ( RW): Physical DVD drives
13 host ( RO): xenserver-ueyqfddq
14 type ( RO): udev
15 content-type ( RO): iso
16
17
18uuid ( RO) : 877a1f66-59dd-b1ba-0de3-d8a753d0a0b2
19 name-label ( RW): Local storage
20 name-description ( RW):
21 host ( RO): <not in database>
22 type ( RO): lvm
23 content-type ( RO): user
24
25
26uuid ( RO) : f663b0ec-56b0-72dc-d546-4e0fc9be7ef6
27 name-label ( RW): XenServer Tools
28 name-description ( RW): XenServer Tools ISOs
29 host ( RO): xenserver-ueyqfddq
30 type ( RO): iso
31 content-type ( RO): iso
At this point it will be forgotten and disappear from XenCenter.
Now, lets delete it from LVM.
2 --- Volume group ---
3 VG Name VG_XenStorage-877a1f66-59dd-b1ba-0de3-d8a753d0a0b2
4 System ID
5 Format lvm2
6 Metadata Areas 1
7 Metadata Sequence No 3
8 VG Access read/write
9 VG Status resizable
10 MAX LV 0
11 Cur LV 1
12 Open LV 0
13 Max PV 0
14 Cur PV 1
15 Act PV 1
16 VG Size 66.85 GB
17 PE Size 4.00 MB
18 Total PE 17113
19 Alloc PE / Size 1 / 4.00 MB
20 Free PE / Size 17112 / 66.84 GB
21 VG UUID 2PJJkR-ULpa-1F6f-8H65-N22A-o11C-f0KkGa
Now lets remove it.
2Do you really want to remove volume group "VG_XenStorage-877a1f66-59dd-b1ba-0de3-d8a753d0a0b2" containing 1 logical volumes? [y/n]: y
3 Logical volume "MGT" successfully removed
4 Volume group "VG_XenStorage-877a1f66-59dd-b1ba-0de3-d8a753d0a0b2" successfully removed
2 "/dev/sda3" is a new physical volume of "66.86 GB"
3 --- NEW Physical volume ---
4 PV Name /dev/sda3
5 VG Name
6 PV Size 66.86 GB
7 Allocatable NO
8 PE Size (KByte) 0
9 Total PE 0
10 Free PE 0
11 Allocated PE 0
12 PV UUID ZK23c0-UvDg-A4MB-TWKi-YfNW-hWUK-uoyqdo
2 Labels on physical volume "/dev/sda3" successfully wiped
Now lets create a filesystem for us to use.
2mke2fs 1.39 (29-May-2006)
3Filesystem label=
4OS type: Linux
5Block size=4096 (log=2)
6Fragment size=4096 (log=2)
78765440 inodes, 17526915 blocks
80 blocks (0.00%) reserved for the super user
9First data block=0
10Maximum filesystem blocks=0
11535 block groups
1232768 blocks per group, 32768 fragments per group
1316384 inodes per group
14Superblock backups stored on blocks:
1532768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
164096000, 7962624, 11239424
17
18Writing inode tables: done
19Creating journal (32768 blocks): done
20Writing superblocks and filesystem accounting information: done
21
22This filesystem will be automatically checked every 33 mounts or
23180 days, whichever comes first. Use tune2fs -c or -i to override.
Now lets set up a folder for it and make sure it gets mounted at boot time.
2LABEL=root-cjfffcbq /ext3 defaults 1 1
3/var/swap/swap.001swap swap defaults 0 0
4none/dev/pts devpts defaults 0 0
5none/dev/shm tmpfs defaults 0 0
6none/proc proc defaults 0 0
7none/sys sysfs defaults 0 0
We need to add our directory to automatically mount at boot time. Lets add this entry
This is how my file looked like at the end.
2/var/swap/swap.001swap swap defaults 0 0
3none/dev/pts devpts defaults 0 0
4none/dev/shm tmpfs defaults 0 0
5none/proc proc defaults 0 0
6none/sys sysfs defaults 0 0
7/dev/sda3 /data ext3 defaults 1 2
Now lets try mounting it.
If you get no output, that means it probably worked.
Lets check that it mounted successfully.
2lost+found
Now lets create our directories that we will export.
2#mkdir /data/iso
Lets edit the exports file.
2/data/iso 127.0.0.1(ro,no_root_squash,sync)
Save the file, and now lets start the nfs and portmap services.
2Starting NFS services: [ OK ]
3Starting NFS daemon: [ OK ]
4Starting NFS mountd: [ OK ]
5#service portmap start
6Starting portmap: [ OK ]
Lets make sure that the portmap and nfs services start at boot.
2#chkconfig --level 345 portmap on
Lets verify that our directories are being exported.
2/data/iso 127.0.0.1
3/data/vm 127.0.0.1
Now we can add the Storage Repository. We can do it through XenCenter. Right click on the server in XenCenter, and click "New Storage Repository". Select "NFS VHD" as the type, and enter the following parameters.
2Share Name: 127.0.0.1:/data/vm
3Leave the checkbox on "Create a New SR" and click "Finish".
Lets add an ISO SR as well. Right click on the server in XenCenter, and click "New Storage Repository". Select "NFS ISO" as the type, and enter the following parameters.
2Share Name: 127.0.0.1:/data/iso
3Leave the checkbox on "Create a New SR" and click "Finish".
Now we reboot and if everything comes back up, we are done. Now when we create VMs, the Virtual Hard Disks will be allocated sparsely, and VMs created from templates, will all use the same base VHD and only store the changes in their own disk.
#1 by Andrew on 8/5/09 - 3:34 PM
otherwise its perfect!!!!
#2 by Ruslan Sivak on 8/17/09 - 8:24 PM
#3 by Joe on 8/20/09 - 12:20 PM
#4 by Bogdan Dumitru on 9/20/09 - 3:13 AM
I already tried this and it gives me " NFS Version Not Supported " in XenCenter for the VHD datastore.
I can mount the ISO datastore though.
#5 by Karl Wiggins on 10/6/09 - 7:52 PM
Great post. Very useful. Would it be possible for you to post the steps to take to reverse this process and set the disk back to Local Storage only (no NFS shares)?
Thanks!
#6 by c.monty on 10/29/09 - 11:02 AM
#7 by Karl Wiggins on 10/29/09 - 5:16 PM
It does not appear that Ruslan is monitoring this thread any more. The only postings since I posed my question on 10/6 have been from worthless spammers. Obviously this blog is not very well monitored.
#8 by silver on 11/7/09 - 3:49 AM
Great Stuff! Can you tell us how to complete this convert to NFS if we were using multiple drives as well? Do we have to then mount each drive as an NFS Volume on its own?
#9 by dfo gold on 11/8/09 - 10:20 PM
#10 by dfo gold on 11/20/09 - 3:32 AM
#11 by dungeon fighter gold on 11/20/09 - 3:32 AM
#12 by allods gold on 3/23/10 - 8:07 PM
#13 by battery on 4/29/10 - 2:22 AM
http://www.u-battery.co.uk/model.php/1_APPLE APPLE Laptop Battery
http://www.u-battery.co.uk/model.php/1_DELL DELL Laptop Battery
http://www.u-battery.co.uk/model.php/1_HP HP Laptop Battery
#14 by battery on 4/30/10 - 5:14 AM
<a href="http://www.u-battery.co.uk/battery.php/HP-Pavilion... Pavilion DV1000 battery </a>
<a href="http://www.u-battery.co.uk/battery.php/HP-Pavilion... Pavilion ZD7000 Battery</a>
<a href="http://www.u-battery.co.uk/battery.php/COMPAQ-Pres... Presario 2100 battery </a>
<a href="http://www.u-battery.co.uk/battery.php/COMPAQ-Pres... Presario r3000 Battery</a>
<a href="http://www.u-battery.co.uk/battery.php/IBM-ThinkPa... ThinkPad T40 battery </a>
#15 by linda on 5/5/10 - 6:09 AM
#16 by linda on 5/5/10 - 6:11 AM
#17 by vibram five fingers[ on 6/23/10 - 5:56 AM
#18 by rimless glasses on 7/28/10 - 3:56 AM
#19 by bifocal glasses on 7/28/10 - 3:58 AM
#20 by bifocals on 7/28/10 - 4:04 AM
#21 by vogue eyewear on 7/28/10 - 4:06 AM
#22 by polarised sunglasses on 7/28/10 - 4:15 AM
#23 by reading sunglasses on 7/28/10 - 4:17 AM
#24 by glasses store on 7/28/10 - 4:18 AM
#25 by reading glasses on 7/28/10 - 4:19 AM
#26 by rimless glasses on 7/28/10 - 4:22 AM
#27 by bifocal glasses on 7/28/10 - 4:23 AM
#28 by bifocal glasses on 7/28/10 - 4:25 AM
#29 by titanium eyeglass on 7/28/10 - 4:26 AM
#30 by bifocals on 7/28/10 - 4:30 AM
#31 by vogue eyewear on 7/28/10 - 4:31 AM
#32 by polarised sunglasses on 7/28/10 - 4:31 AM
#33 by reading sunglasses on 7/28/10 - 4:33 AM
#34 by vibram fivefingers on 7/28/10 - 4:35 AM
#35 by five finger shoes on 7/28/10 - 4:37 AM
#36 by vibram finger on 7/28/10 - 4:39 AM
#37 by five fingers sprint on 7/28/10 - 4:40 AM
#38 by five finger shoes on 7/28/10 - 4:41 AM
#39 by vibram kso on 7/28/10 - 4:42 AM
#40 by vibram classic on 7/28/10 - 4:42 AM
#41 by vibram fivefingers on 7/28/10 - 4:48 AM
#42 by five finger shoes on 7/28/10 - 4:48 AM
#43 by vibram finger on 7/28/10 - 4:49 AM
#44 by vibram kso on 7/28/10 - 4:50 AM
#45 by vibram sprint on 7/28/10 - 4:50 AM
#46 by vibram classic on 7/28/10 - 4:51 AM
#47 by vibram fivefingers on 7/28/10 - 4:56 AM
#48 by vibram finger on 7/28/10 - 4:56 AM
#49 by five fingers sprint on 7/28/10 - 4:56 AM
#50 by five finger shoes on 7/28/10 - 4:57 AM
#51 by vibram kso on 7/28/10 - 4:57 AM
#52 by vibram classic on 7/28/10 - 4:57 AM
#53 by dragonfu on 7/29/10 - 8:48 AM
#54 by tiffany outlet on 8/3/10 - 9:53 AM
i like it!
thanks you!
i like this websit
#55 by chanel flap on 8/5/10 - 11:12 AM
#56 by UGG Boots on 8/8/10 - 12:28 PM
#57 by UGG Boots on 8/8/10 - 12:28 PM
#58 by hollister clothing on 9/10/10 - 2:37 AM
#59 by bailey ugg boots uk on 9/20/10 - 6:26 AM
#60 by Kamil on 10/6/10 - 4:17 PM
I am new in xen enviroment, but this look like useful.
But I have problem with mkdir /data command.
I recieve a message : mkdir: cannot create directory `/data': Read-only file system
Please can someone help me or explain me?
Thanks
#61 by blow up doll on 12/16/10 - 10:06 AM
#62 by Emal on 6/30/11 - 5:35 AM
#63 by www.sunglassesblack.net on 7/9/11 - 12:20 AM
http://www.sunglassesblack.net]sunglasses 2011
http://www.sunglassesblack.net]Oakleys Sunglasses
http://www.sunglassesblack.net]Oakleys Sunglasses Outlet
http://www.sunglassesblack.net]top sunglasses
#64 by www.mlb-2011.com on 7/9/11 - 12:22 AM
http://www.mlb-2011.com]mlb jerseys
http://www.mlb-2011.com]cheap mlb jerseys
http://www.mlb-2011.com]mlb shop
http://www.mlb-2011.com]mlb baseball
#65 by www.cheapest-belts.com on 7/9/11 - 12:22 AM
http://www.cheapest-belts.com]Cheap Belts Online
http://www.cheapest-belts.com]belts for women
http://www.cheapest-belts.com]work belts
http://www.cheapest-belts.com]buy belts
#66 by ugg boots on 7/19/11 - 7:46 AM
#67 by beats by dre on 8/1/11 - 6:49 AM
http://www.monstersbeatsbydre.org/ monster beats
http://www.monstersbeatsbydre.org/ beats by monster
http://www.monstersbeatsbydre.org/ monster beats by dre
http://www.monstersbeatsbydre.org/ monster headphone
#68 by buy mbt shoes on 8/11/11 - 2:00 AM
http://cheapestguccioutlet.com/ cheap gucci bags
http://cheapestguccioutlet.com/ cheap gucci shoes
#69 by sooojerseys on 10/25/11 - 7:45 AM
http://www.ravensfansjerseys.com Baltimore Ravens Jerseys
http://www.cardinalsfansshop.com Darnell Dockett Jerseys