mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-18 21:27:56 +00:00
tool/run: improve disk image size automatic
Set disk size to 1.5 times the run folder size and shrinked later to real content. Thanks to Roland for the patch.
This commit is contained in:
parent
108fe84f5a
commit
18c5f1e90d
@ -17,6 +17,7 @@
|
||||
|
||||
#define boot_cpu_has(bit) 0
|
||||
#define static_cpu_has(bit) boot_cpu_has(bit)
|
||||
#define static_cpu_has_bug(bit) static_cpu_has((bit))
|
||||
#define cpu_has(value, bit) ( (void)value, 0 )
|
||||
|
||||
#endif /* defined(__KERNEL__) && !defined(__ASSEMBLY__) */
|
||||
|
@ -27,13 +27,11 @@ proc run_image { {unused ""} } {
|
||||
set size_header [expr [regsub {\s.*} [exec du -b [run_dir].header] {}]]
|
||||
set size_run [expr [regsub {\s.*} [exec du -skL [run_dir]] {}]]
|
||||
|
||||
# try to compensate ext2 overhead in disk size
|
||||
set ext2_overhead 768
|
||||
|
||||
if {[image_disk_size] > 0} {
|
||||
set disk_size_kb [expr [image_disk_size] * 1024]
|
||||
} else {
|
||||
set disk_size_kb [expr ($size_run + $ext2_overhead) / 32 * 32]
|
||||
# set disk size to 1.5 times the run folder size; will be shrinked later
|
||||
set disk_size_kb [expr ($size_run * 3 / 2) / 32 * 32]
|
||||
}
|
||||
|
||||
# setup partition with content
|
||||
@ -54,6 +52,13 @@ proc run_image { {unused ""} } {
|
||||
}
|
||||
}
|
||||
|
||||
if {[image_disk_size] == 0} {
|
||||
# resize image to only needed size and get size of resized image
|
||||
exec resize2fs -M [run_dir].partition 2>/dev/null
|
||||
set disk_size_b [expr [regsub {\s.*} [exec wc -c [run_dir].partition] {}]]
|
||||
set disk_size_kb [expr $disk_size_b / 1024]
|
||||
}
|
||||
|
||||
# calculate start/end sector of content partition
|
||||
set first_sector [expr $size_header / 512]
|
||||
set last_sector [expr ((($size_header + ($disk_size_kb * 1024)) / 512) - 1)]
|
||||
|
Loading…
Reference in New Issue
Block a user