Package: xen-tools
Version: 3.9-2
Tag: patch

I tried the --partitions option with xen-create-image. It works ok with the
sample-server file provided with the package, but not with my settings.

Here is my partition file :
[root]
size=500M
type=ext3
mountpoint=/
options=sync,errors=remount-ro

[swap]
size=2G
type=swap

[home]
size=1G
type=xfs
mountpoint=/home
options=nodev,nosuid

[tmp]
size=2G
type=xfs
mountpoint=/tmp
options=nodev,nosuid

[usr]
size=10G
type=xfs
mountpoint=/usr
options=nodev

[var]
size=2G
type=xfs
mountpoint=/var
options=nodev,nosuid

[usr-local]
size=5G
type=xfs
mountpoint=/usr/local
options=nodev

Here are some excerpts from a session :
zeus:~# xen-create-image --ip='129.104.3.229' --hostname="ubuntu-i386" 
--arch="i386" --dist=gutsy --mirror='http://fr.archive.ubuntu.com/ubuntu/' 
--partitions daphne --memory 1024 --verbose

General Information
--------------------
Hostname       :  ubuntu-i386
Distribution   :  gutsy
Partitions     :  swap            2G    (swap)
                  /               500M  (ext3)
                  /usr/local      5G    (xfs)
                  /var            2G    (xfs)
                  /usr            10G   (xfs)
                  /tmp            2G    (xfs)
                  /home           1G    (xfs)
Image type     :  full
Memory size    :  1024
Kernel path    :  /boot/vmlinuz-2.6.18-5-xen-amd64
Initrd path    :  /boot/initrd.img-2.6.18-5-xen-amd64

Networking Information
----------------------
IP Address 1   : 129.104.3.229 [MAC: 00:16:3E:F6:3E:1E]
Netmask        : 255.255.255.0
Gateway        : 129.104.3.100

Executing : lvcreate system -L 2G -n ubuntu-i386-swap
[...]
Executing : mount -t ext3 /dev/system/ubuntu-i386-root /tmp/0nNOTFZXmU/
Finished : mount -t ext3 /dev/system/ubuntu-i386-root /tmp/0nNOTFZXmU/ 2>&1 | 
tee --append /var/log/xen-tools/ubuntu-i386.log
Executing : mount -t xfs /dev/system/ubuntu-i386-usr-local 
/tmp/0nNOTFZXmU/usr/local
Finished : mount -t xfs /dev/system/ubuntu-i386-usr-local 
/tmp/0nNOTFZXmU/usr/local 2>&1 | tee --append /var/log/xen-tools/ubuntu-i386.log
Executing : mount -t xfs /dev/system/ubuntu-i386-var /tmp/0nNOTFZXmU/var
Finished : mount -t xfs /dev/system/ubuntu-i386-var /tmp/0nNOTFZXmU/var 2>&1 | 
tee --append /var/log/xen-tools/ubuntu-i386.log
Executing : mount -t xfs /dev/system/ubuntu-i386-usr /tmp/0nNOTFZXmU/usr
Finished : mount -t xfs /dev/system/ubuntu-i386-usr /tmp/0nNOTFZXmU/usr 2>&1 | 
tee --append /var/log/xen-tools/ubuntu-i386.log
Executing : mount -t xfs /dev/system/ubuntu-i386-tmp /tmp/0nNOTFZXmU/tmp
Finished : mount -t xfs /dev/system/ubuntu-i386-tmp /tmp/0nNOTFZXmU/tmp 2>&1 | 
tee --append /var/log/xen-tools/ubuntu-i386.log
Executing : mount -t xfs /dev/system/ubuntu-i386-home /tmp/0nNOTFZXmU/home
Finished : mount -t xfs /dev/system/ubuntu-i386-home /tmp/0nNOTFZXmU/home 2>&1 
| tee --append /var/log/xen-tools/ubuntu-i386.log
[...]
Customization Script Environment:
---------------------------------
        'HOME' = '/root'
        'LANG' = 'en_US.UTF-8'
        'LC_ALL' = 'C'
        'LOGNAME' = 'root'
        'MAIL' = '/var/mail/root'
        'NUMPARTITIONS' = '7'
        'PARTITION1' = 'swap:2G:swap:::phy::/dev/system/ubuntu-i386-swap'
        'PARTITION2' = 
'root:500M:ext3:/:sync,errors=remount-ro:phy::/dev/system/ubuntu-i386-root'
        'PARTITION3' = 
'usr-local:5G:xfs:/usr/local:nodev:phy::/dev/system/ubuntu-i386-usr-local'
        'PARTITION4' = 
'var:2G:xfs:/var:nodev,nosuid:phy::/dev/system/ubuntu-i386-var'
        'PARTITION5' = 'usr:10G:xfs:/usr:nodev:phy::/dev/system/ubuntu-i386-usr'
        'PARTITION6' = 
'tmp:2G:xfs:/tmp:nodev,nosuid:phy::/dev/system/ubuntu-i386-tmp'
        'PARTITION7' = 
'home:1G:xfs:/home:nodev,nosuid:phy::/dev/system/ubuntu-i386-home'
[...]
Unmounting : /tmp/0nNOTFZXmU/var
Executing : umount /tmp/0nNOTFZXmU/var
Finished : umount /tmp/0nNOTFZXmU/var 2>&1 | tee --append 
/var/log/xen-tools/ubuntu-i386.log
Unmounting : /tmp/0nNOTFZXmU/usr/local
Executing : umount /tmp/0nNOTFZXmU/usr/local
Finished : umount /tmp/0nNOTFZXmU/usr/local 2>&1 | tee --append 
/var/log/xen-tools/ubuntu-i386.log
Unmounting : /tmp/0nNOTFZXmU/usr
Executing : umount /tmp/0nNOTFZXmU/usr
Finished : umount /tmp/0nNOTFZXmU/usr 2>&1 | tee --append 
/var/log/xen-tools/ubuntu-i386.log
Unmounting : /tmp/0nNOTFZXmU/tmp
Executing : umount /tmp/0nNOTFZXmU/tmp
Finished : umount /tmp/0nNOTFZXmU/tmp 2>&1 | tee --append 
/var/log/xen-tools/ubuntu-i386.log
Unmounting : /tmp/0nNOTFZXmU/home
Executing : umount /tmp/0nNOTFZXmU/home
Finished : umount /tmp/0nNOTFZXmU/home 2>&1 | tee --append 
/var/log/xen-tools/ubuntu-i386.log
Unmounting : /tmp/0nNOTFZXmU
Executing : umount /tmp/0nNOTFZXmU
Finished : umount /tmp/0nNOTFZXmU 2>&1 | tee --append 
/var/log/xen-tools/ubuntu-i386.log
Can't remove directory /tmp/0nNOTFZXmU/usr/local: Device or resource busy at 
/usr/share/perl/5.8/File/Temp.pm line 898
Can't remove directory /tmp/0nNOTFZXmU/usr: Directory not empty at 
/usr/share/perl/5.8/File/Temp.pm line 898
Can't remove directory /tmp/0nNOTFZXmU: Device or resource busy at 
/usr/share/perl/5.8/File/Temp.pm line 898

The /usr/local partition was mounted before /usr, hence the problem. 


The trouble is at the ordering of the partitions before mounting them, at line
2075 of /usr/bin/xen-create-image. The array @PARTITIONS is sorted by comparing
alphabetically instead of numerically the length of the mountpoint. In my case,
/usr/local is 10 characters long and sorted before /usr which is 4 characters
long.

I attached a simple patch to correct this behavior.


Thank you for providing this option with xen-tools, it is really helpful to
create virtual servers. 

Sincerely yours,

-- 
Stéphane AICARDI
CMLS-CPHT
Ecole Polytechnique
91128 PALAISEAU CEDEX
FRANCE
Tel : 01 69 33 49 56
--- /usr/bin/xen-create-image   2008-02-20 22:27:15.000000000 +0100
+++ /usr/bin/xen-create-image.fix       2008-04-22 15:44:07.000000000 +0200
@@ -2072,7 +2072,7 @@
     #  This makes it easy to mount parent folders first
     # (e.g. /var before /var/tmp)
     #
-    @PARTITIONS = sort { length $a->{'mountpoint'} cmp length 
$b->{'mountpoint'} } @PARTITIONS;
+    @PARTITIONS = sort { length $a->{'mountpoint'} <=> length 
$b->{'mountpoint'} } @PARTITIONS;
 }
 
 

Reply via email to