1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
| --- /usr/bin/lxc-create.orig 2014-11-17 04:16:41.181942000 -0500
+++ /usr/bin/lxc-create 2014-11-17 04:35:27.225942000 -0500
@@ -24,6 +24,7 @@
echo "usage: lxc-create -n <name> [-f configuration] [-t template] [-h] [fsopts] -- [template_options]"
echo " fsopts: -B none"
echo " fsopts: -B lvm [--lvname lvname] [--vgname vgname] [--fstype fstype] [--fssize fssize]"
+ echo " fsopts: -B rbd [--pool poolname] [--rbd rbd] [--fstype fstype] [--fssize fssize]"
echo " fsopts: -B btrfs"
echo " flag is not necessary, if possible btrfs support will be used"
# echo " fsopts: -B union [--uniontype overlayfs]"
@@ -64,7 +65,7 @@
}
shortoptions='hn:f:t:B:'
-longoptions='help,name:,config:,template:,backingstore:,fstype:,lvname:,vgname:,fssize:'
+longoptions='help,name:,config:,template:,backingstore:,fstype:,lvname:,vgname:,pool:,rbd:,fssize:'
localstatedir=/var
lxc_path=${localstatedir}/lib/lxc
bindir=/usr/bin
@@ -119,6 +120,16 @@
vgname=$1
shift
;;
+ --pool)
+ shift
+ pool=$1
+ shift
+ ;;
+ --rbd)
+ shift
+ rbd=$1
+ shift
+ ;;
--fstype)
shift
fstype=$1
@@ -161,7 +172,7 @@
fi
case "$backingstore" in
- lvm|none|btrfs|_unset) :;;
+ lvm|rbd|none|btrfs|_unset) :;;
*) echo "'$backingstore' is not known ('none', 'lvm', 'btrfs')"
usage
exit 1
@@ -216,6 +227,13 @@
echo "please delete it (using \"lvremove $rootdev\") and try again"
exit 1
fi
+elif [ "$backingstore" = "rbd" ]; then
+ which rbd > /dev/null
+ if [ $? -ne 0 ]; then
+ echo "rbd command not found. Please install ceph-common package"
+ exit 1
+ fi
+ rootdev=/dev/rbd/$pool/$rbd
elif [ "$backingstore" = "btrfs" ]; then
mkdir "$lxc_path/$lxc_name"
if ! out=$(btrfs subvolume create "$rootfs" 2>&1); then
@@ -257,6 +275,14 @@
mkfs -t $fstype $rootdev || exit 1
mount -t $fstype $rootdev $rootfs
fi
+
+if [ $backingstore = "rbd" ]; then
+ [ -d "$rootfs" ] || mkdir $rootfs
+ rbd create $pool/$rbd --size=$fssize || exit 1
+ rbd map $pool/$rbd || exit 1
+ mkfs -t $fstype $rootdev || exit 1
+ mount -t $fstype $rootdev $rootfs
+fi
if [ ! -z $lxc_template ]; then
|