Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
8b7071ec
Commit
8b7071ec
authored
Feb 09, 2012
by
Ubuntu
Committed by
Daniel Lezcano
Feb 26, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add btrfs support to lxc-create
From Scott Moser. Signed-off-by:
Serge Hallyn
<
serge.hallyn@canonical.com
>
Signed-off-by:
Daniel Lezcano
<
dlezcano@fr.ibm.com
>
parent
5eff9886
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
12 deletions
+31
-12
lxc-create.in
src/lxc/lxc-create.in
+31
-12
No files found.
src/lxc/lxc-create.in
View file @
8b7071ec
...
@@ -24,6 +24,8 @@ usage() {
...
@@ -24,6 +24,8 @@ usage() {
echo
"usage: lxc-create -n <name> [-f configuration] [-t template] [-h] [fsopts] -- [template_options]"
echo
"usage: lxc-create -n <name> [-f configuration] [-t template] [-h] [fsopts] -- [template_options]"
echo
" fsopts: -B none"
echo
" fsopts: -B none"
echo
" fsopts: -B lvm [--lvname lvname] [--vgname vgname] [--fstype fstype] [--fssize fssize]"
echo
" fsopts: -B lvm [--lvname lvname] [--vgname vgname] [--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]"
# echo " fsopts: -B union [--uniontype overlayfs]"
# echo " fsopts: -B loop [--fstype fstype] [--fssize fssize]"
# echo " fsopts: -B loop [--fstype fstype] [--fssize fssize]"
# echo " fsopts: -B qemu-nbd [--type qed|qcow2|raw] [--fstype fstype] [--fssize fssize] # Qemu qed disk format"
# echo " fsopts: -B qemu-nbd [--type qed|qcow2|raw] [--fstype fstype] [--fssize fssize] # Qemu qed disk format"
...
@@ -68,7 +70,7 @@ lxc_path=@LXCPATH@
...
@@ -68,7 +70,7 @@ lxc_path=@LXCPATH@
bindir
=
@BINDIR@
bindir
=
@BINDIR@
libdir
=
@LIBDIR@
libdir
=
@LIBDIR@
templatedir
=
@LXCTEMPLATEDIR@
templatedir
=
@LXCTEMPLATEDIR@
backingstore
=
none
backingstore
=
_unset
fstype
=
ext4
fstype
=
ext4
fssize
=
500M
fssize
=
500M
vgname
=
lxc
vgname
=
lxc
...
@@ -163,16 +165,13 @@ if [ "$(id -u)" != "0" ]; then
...
@@ -163,16 +165,13 @@ if [ "$(id -u)" != "0" ]; then
exit
1
exit
1
fi
fi
if
[
$backingstore
!=
"none"
-a
$backingstore
!=
"lvm"
]
;
then
case
"
$backingstore
"
in
echo
"only 'none' and 'lvm' backing stores are known"
lvm|none|btrfs|_unset
)
:
;;
*
)
echo
"'
$backingstore
' is not known ('none', 'lvm', 'btrfs')"
usage
usage
exit
1
exit
1
fi
;;
esac
if
[
!
-r
$lxc_path
]
;
then
echo
"no configuration path defined !"
exit
1
fi
if
[
-d
"
$lxc_path
/
$lxc_name
"
]
;
then
if
[
-d
"
$lxc_path
/
$lxc_name
"
]
;
then
echo
"'
$lxc_name
' already exists"
echo
"'
$lxc_name
' already exists"
...
@@ -180,6 +179,21 @@ if [ -d "$lxc_path/$lxc_name" ]; then
...
@@ -180,6 +179,21 @@ if [ -d "$lxc_path/$lxc_name" ]; then
fi
fi
rootfs
=
"
$lxc_path
/
$lxc_name
/rootfs"
rootfs
=
"
$lxc_path
/
$lxc_name
/rootfs"
if
[
"
$backingstore
"
=
"_unset"
-o
"
$backingstore
"
=
"btrfs"
]
;
then
# if no backing store was given, then see if btrfs would work
if
which btrfs
>
/dev/null 2>&1
&&
btrfs filesystem
df
"
$lxc_path
/"
>
/dev/null 2>&1
;
then
backingstore
=
"btrfs"
else
if
[
"
$backingstore
"
=
"btrfs"
]
;
then
echo
"missing 'btrfs' command or
$lxc_path
is not btrfs"
;
exit
1
;
fi
backingstore
=
"none"
fi
fi
if
[
$backingstore
=
"lvm"
]
;
then
if
[
$backingstore
=
"lvm"
]
;
then
which vgscan
>
/dev/null
which vgscan
>
/dev/null
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
...
@@ -207,6 +221,12 @@ if [ $backingstore = "lvm" ]; then
...
@@ -207,6 +221,12 @@ if [ $backingstore = "lvm" ]; then
echo
"please delete it (using
\"
lvremove
$rootdev
\"
) and try again"
echo
"please delete it (using
\"
lvremove
$rootdev
\"
) and try again"
exit
1
exit
1
fi
fi
elif
[
"
$backingstore
"
=
"btrfs"
]
;
then
mkdir
"
$lxc_path
/
$lxc_name
"
if
!
out
=
$(
btrfs subvolume create
"
$rootfs
"
2>&1
)
;
then
echo
"failed to create subvolume in
$rootfs
:
$out
"
;
exit
1
;
fi
fi
fi
cleanup
()
{
cleanup
()
{
...
@@ -235,7 +255,7 @@ else
...
@@ -235,7 +255,7 @@ else
fi
fi
# Create the fs as needed
# Create the fs as needed
mkdir
$rootfs
[
-d
"
$rootfs
"
]
||
mkdir
$rootfs
if
[
$backingstore
=
"lvm"
]
;
then
if
[
$backingstore
=
"lvm"
]
;
then
lvcreate
-L
$fssize
-n
$lvname
$vgname
||
exit
1
lvcreate
-L
$fssize
-n
$lvname
$vgname
||
exit
1
udevadm settle
udevadm settle
...
@@ -280,8 +300,7 @@ if [ ! -z $lxc_template ]; then
...
@@ -280,8 +300,7 @@ if [ ! -z $lxc_template ]; then
${
templatedir
}
/lxc-
$lxc_template
--path
=
$lxc_path
/
$lxc_name
--name
=
$lxc_name
$*
${
templatedir
}
/lxc-
$lxc_template
--path
=
$lxc_path
/
$lxc_name
--name
=
$lxc_name
$*
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
echo
"failed to execute template '
$lxc_template
'"
echo
"failed to execute template '
$lxc_template
'"
${
bindir
}
/lxc-destroy
-n
$lxc_name
cleanup
exit
1
fi
fi
echo
"'
$lxc_template
' template installed"
echo
"'
$lxc_template
' template installed"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment