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
4737d51a
Commit
4737d51a
authored
Jun 17, 2016
by
Laurent Vivier
Committed by
Stéphane Graber
Jun 27, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lxc-debian: add btrfs support
copied from lxc-ubuntu.in Signed-off-by:
Laurent Vivier
<
laurent@vivier.eu
>
Acked-by:
Serge Hallyn
<
serge@hallyn.com
>
parent
6ffa3291
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
5 deletions
+50
-5
lxc-debian.in
templates/lxc-debian.in
+50
-5
No files found.
templates/lxc-debian.in
View file @
4737d51a
...
...
@@ -253,10 +253,45 @@ configure_debian_systemd()
return
0
}
# Check if given path is in a btrfs partition
is_btrfs
()
{
[
-e
$1
-a
$(
stat
-f
-c
'%T'
$1
)
=
"btrfs"
]
}
# Check if given path is the root of a btrfs subvolume
is_btrfs_subvolume
()
{
[
-d
$1
-a
$(
stat
-f
-c
'%T'
$1
)
=
"btrfs"
-a
$(
stat
-c
'%i'
$1
)
-eq
256
]
}
try_mksubvolume
()
{
path
=
$1
[
-d
$path
]
&&
return
0
mkdir
-p
$(
dirname
$path
)
if
which btrfs
>
/dev/null 2>&1
&&
is_btrfs
$(
dirname
$path
)
;
then
btrfs subvolume create
$path
else
mkdir
-p
$path
fi
}
try_rmsubvolume
()
{
path
=
$1
[
-d
$path
]
||
return
0
if
which btrfs
>
/dev/null 2>&1
&&
is_btrfs_subvolume
$path
;
then
btrfs subvolume delete
$path
else
rm
-rf
$path
fi
}
cleanup
()
{
rm
-rf
$cache
/partial-
$release
-
$arch
rm
-rf
$cache
/rootfs-
$release
-
$arch
try_rmsubvolume
$cache
/partial-
$release
-
$arch
try_rmsubvolume
$cache
/rootfs-
$release
-
$arch
}
download_debian
()
...
...
@@ -303,7 +338,7 @@ openssh-server
| gpg
--import
--no-default-keyring
--keyring
=
${
releasekeyring
}
fi
# check the mini debian was not already downloaded
mkdir
-p
"
$cache
/partial-
$release
-
$arch
"
try_mksubvolume
"
$cache
/partial-
$release
-
$arch
"
if
[
$?
-ne
0
]
;
then
echo
"Failed to create '
$cache
/partial-
$release
-
$arch
' directory"
return
1
...
...
@@ -359,8 +394,18 @@ copy_debian()
# make a local copy of the minidebian
echo
-n
"Copying rootfs to
$rootfs
..."
mkdir
-p
$rootfs
rsync
-Ha
"
$cache
/rootfs-
$release
-
$arch
"
/
$rootfs
/
||
return
1
try_mksubvolume
$rootfs
if
which btrfs
>
/dev/null 2>&1
&&
\
is_btrfs_subvolume
"
$cache
/rootfs-
$release
-
$arch
"
&&
\
is_btrfs_subvolume
$rootfs
;
then
realrootfs
=
$(
dirname
$config
)
/rootfs
[
"
$rootfs
"
=
"
$realrootfs
"
]
||
umount
$rootfs
||
return
1
btrfs subvolume delete
$realrootfs
||
return
1
btrfs subvolume snapshot
"
$cache
/rootfs-
$release
-
$arch
"
$realrootfs
||
return
1
[
"
$rootfs
"
=
"
$realrootfs
"
]
||
mount
--bind
$realrootfs
$rootfs
||
return
1
else
rsync
-Ha
"
$cache
/rootfs-
$release
-
$arch
"
/
$rootfs
/
||
return
1
fi
return
0
}
...
...
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