Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snf-image-creator
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
itminedu
snf-image-creator
Commits
033007ec
Commit
033007ec
authored
12 years ago
by
Nikos Skalkotos
Browse files
Options
Downloads
Plain Diff
Merge branch 'stable-0.1'
parents
3664c5f5
7f9ecc51
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/overview.rst
+15
-14
15 additions, 14 deletions
docs/overview.rst
image_creator/disk.py
+11
-11
11 additions, 11 deletions
image_creator/disk.py
with
26 additions
and
25 deletions
docs/overview.rst
+
15
−
14
View file @
033007ec
...
...
@@ -2,10 +2,8 @@ Overview
^^^^^^^^
snf-image-creator is a simple command-line tool for creating OS images. The
original media from which the image is created, can be a block device or a
regular file that represents a hard disk. Given a media file, snf-image-creator
will create a snapshot for it and will run a number of system preparation
operations on the snapshot, before the image is created.
original media, the image is created from, can be a block device or a regular
file that represents a hard disk.
Snapshotting
============
...
...
@@ -13,12 +11,13 @@ Snapshotting
snf-image-creator works on snapshots of the original media. Any changes made by
the program do not affect the original media.
Preparation
===========
Image
Preparation
===========
======
Some of the system preparation operations are OS specific. snf-image-creator
will use heuristics to detect the OS of the media and determine which
operations should perform on it. The main purpose of running them is to:
During the image creation, a number of system preparation operations are
applied on the media snapshot. Some of those are OS specific. snf-image-creator
will use heuristics to detect the OS and determine which operations to apply.
Those operations will:
* Shrink the image
* Clear out sensitive user data (passwords, ssh keys, history files, etc.)
...
...
@@ -28,12 +27,14 @@ operations should perform on it. The main purpose of running them is to:
Creation
========
The program can either dump the image file locally or directly upload it to
pithos and register it with `okeanos <http://www.okeanos.grnet.gr>`_.
The program can either dump the image file locally or use
`./kamaki <https://code.grnet.gr/projects/kamaki>`_ to directly upload and
register it on a `Synnefo <https://code.grnet.gr/projects/synnefo>`_
deployment.
Image Format
============
The
images the program creat
es are in diskdump format. This is the recommended
format for
`snf-image <https://code.grnet.gr/projects/snf-image>`_, the Ganeti
OS
Definition used by `Synnefo <https://code.grnet.gr/projects/synnefo>`_.
The
extracted imag
es are in diskdump format. This is the recommended
format for
`snf-image <https://code.grnet.gr/projects/snf-image>`_, the Ganeti
OS
Definition used by `Synnefo <https://code.grnet.gr/projects/synnefo>`_.
This diff is collapsed.
Click to expand it.
image_creator/disk.py
+
11
−
11
View file @
033007ec
...
...
@@ -292,16 +292,17 @@ class DiskDevice(object):
raise
FatalError
(
msg
)
is_extended
=
lambda
p
:
\
self
.
g
.
part_get_mbr_id
(
self
.
guestfs_device
,
p
[
'
part_num
'
])
==
5
self
.
g
.
part_get_mbr_id
(
self
.
guestfs_device
,
p
[
'
part_num
'
])
\
in
(
0x5
,
0xf
)
is_logical
=
lambda
p
:
\
self
.
meta
[
'
PARTITION_TABLE
'
]
!
=
'
msdos
'
and
p
[
'
part_num
'
]
>
4
self
.
meta
[
'
PARTITION_TABLE
'
]
=
=
'
msdos
'
and
p
[
'
part_num
'
]
>
4
partitions
=
self
.
g
.
part_list
(
self
.
guestfs_device
)
last_partition
=
partitions
[
-
1
]
if
is_logical
(
last_partition
):
# The disk contains extended and logical partitions....
extended
=
[
p
for
p
in
partitions
if
is_extended
(
p
)]
[
0
]
extended
=
filter
(
is_extended
,
partitions
)
[
0
]
last_primary
=
[
p
for
p
in
partitions
if
p
[
'
part_num
'
]
<=
4
][
-
1
]
# check if extended is the last primary partition
...
...
@@ -325,7 +326,8 @@ class DiskDevice(object):
self
.
meta
[
'
PARTITION_TABLE
'
]
==
'
msdos
'
and
p
[
'
part_num
'
]
>
4
is_extended
=
lambda
p
:
\
self
.
meta
[
'
PARTITION_TABLE
'
]
==
'
msdos
'
and
\
self
.
g
.
part_get_mbr_id
(
self
.
guestfs_device
,
p
[
'
part_num
'
])
==
5
self
.
g
.
part_get_mbr_id
(
self
.
guestfs_device
,
p
[
'
part_num
'
])
\
in
(
0x5
,
0xf
)
part_add
=
lambda
ptype
,
start
,
stop
:
\
self
.
g
.
part_add
(
self
.
guestfs_device
,
ptype
,
start
,
stop
)
...
...
@@ -375,10 +377,8 @@ class DiskDevice(object):
self
.
g
.
resize2fs_M
(
part_dev
)
out
=
self
.
g
.
tune2fs_l
(
part_dev
)
block_size
=
int
(
filter
(
lambda
x
:
x
[
0
]
==
'
Block size
'
,
out
)[
0
][
1
])
block_cnt
=
int
(
filter
(
lambda
x
:
x
[
0
]
==
'
Block count
'
,
out
)[
0
][
1
])
block_size
=
int
(
filter
(
lambda
x
:
x
[
0
]
==
'
Block size
'
,
out
)[
0
][
1
])
block_cnt
=
int
(
filter
(
lambda
x
:
x
[
0
]
==
'
Block count
'
,
out
)[
0
][
1
])
start
=
last_part
[
'
part_start
'
]
/
sector_size
end
=
start
+
(
block_size
*
block_cnt
)
/
sector_size
-
1
...
...
@@ -394,16 +394,16 @@ class DiskDevice(object):
'
num
'
:
partition
[
'
part_num
'
],
'
start
'
:
partition
[
'
part_start
'
]
/
sector_size
,
'
end
'
:
partition
[
'
part_end
'
]
/
sector_size
,
'
id
'
:
part_get_
(
partition
[
'
part_num
'
]),
'
id
'
:
part_get_
id
(
partition
[
'
part_num
'
]),
'
bootable
'
:
part_get_bootable
(
partition
[
'
part_num
'
])
})
logical
[
-
1
][
'
end
'
]
=
end
# new end after resize
# Recreate the extended partition
extended
=
[
p
for
p
in
partitions
if
self
.
_is_extended
(
p
)]
[
0
]
extended
=
filter
(
is_extended
,
partitions
)
[
0
]
part_del
(
extended
[
'
part_num
'
])
part_add
(
'
e
'
,
extended
[
'
part_start
'
],
end
)
part_add
(
'
e
'
,
extended
[
'
part_start
'
]
/
sector_size
,
end
)
# Create all the logical partitions back
for
l
in
logical
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment