pmb/install: have size_boot, size_root in MB
Prepare for a future patch, that adds reserved space in MB, by changing size_boot and size_root from bytes to MB everywhere. This is what we need most of the time and allows to drop some /1024**2 statements.
This commit is contained in:
parent
9da12415b8
commit
3f1f21add5
|
@ -135,8 +135,8 @@ def chroot(args):
|
|||
|
||||
# Install blockdevice
|
||||
if args.install_blockdev:
|
||||
size_boot = 128 * 1024 * 1024 # 128 MB
|
||||
size_root = 4096 * 1024 * 1024 # 4 GB
|
||||
size_boot = 128 # 128 MB
|
||||
size_root = 4096 # 4 GB
|
||||
pmb.install.blockdevice.create_and_mount_image(args, size_boot,
|
||||
size_root)
|
||||
|
||||
|
|
|
@ -34,17 +34,17 @@ def get_subpartitions_size(args):
|
|||
Calculate the size of the boot and root subpartition.
|
||||
|
||||
:returns: (boot, root) the size of the boot and root
|
||||
partition as integer in bytes
|
||||
partition as integer in MB
|
||||
"""
|
||||
boot = int(args.boot_size) * 1024 * 1024
|
||||
boot = int(args.boot_size)
|
||||
|
||||
# Estimate root partition size, then add some free space. The size
|
||||
# calculation is not as trivial as one may think, and depending on the
|
||||
# file system etc it seems to be just impossible to get it right.
|
||||
chroot = args.work + "/chroot_rootfs_" + args.device
|
||||
root = pmb.helpers.other.folder_size(args, chroot)
|
||||
root = pmb.helpers.other.folder_size(args, chroot) / 1024 / 1024
|
||||
root *= 1.20
|
||||
root += 50 * 1024 * 1024
|
||||
root += 50
|
||||
return (boot, root)
|
||||
|
||||
|
||||
|
|
|
@ -58,8 +58,8 @@ def create_and_mount_image(args, size_boot, size_root, split=False):
|
|||
"""
|
||||
Create a new image file, and mount it as /dev/install.
|
||||
|
||||
:param size_boot: size of the boot partition in bytes
|
||||
:param size_root: size of the root partition in bytes
|
||||
:param size_boot: size of the boot partition in MB
|
||||
:param size_root: size of the root partition in MB
|
||||
:param split: create separate images for boot and root partitions
|
||||
"""
|
||||
|
||||
|
@ -79,7 +79,7 @@ def create_and_mount_image(args, size_boot, size_root, split=False):
|
|||
pmb.chroot.root(args, ["rm", img_path])
|
||||
|
||||
# Make sure there is enough free space
|
||||
size_mb = round((size_boot + size_root) / (1024**2))
|
||||
size_mb = round(size_boot + size_root)
|
||||
disk_data = os.statvfs(args.work)
|
||||
free = round((disk_data.f_bsize * disk_data.f_bavail) / (1024**2))
|
||||
if size_mb > free:
|
||||
|
@ -88,8 +88,8 @@ def create_and_mount_image(args, size_boot, size_root, split=False):
|
|||
# Create empty image files
|
||||
pmb.chroot.user(args, ["mkdir", "-p", "/home/pmos/rootfs"])
|
||||
size_mb_full = str(size_mb) + "M"
|
||||
size_mb_boot = str(round(size_boot / (1024**2))) + "M"
|
||||
size_mb_root = str(round(size_root / (1024**2))) + "M"
|
||||
size_mb_boot = str(round(size_boot)) + "M"
|
||||
size_mb_root = str(round(size_root)) + "M"
|
||||
images = {img_path_full: size_mb_full}
|
||||
if split:
|
||||
images = {img_path_boot: size_mb_boot,
|
||||
|
@ -117,8 +117,8 @@ def create(args, size_boot, size_root):
|
|||
"""
|
||||
Create /dev/install (the "install blockdevice").
|
||||
|
||||
:param size_boot: size of the boot partition in bytes
|
||||
:param size_root: size of the root partition in bytes
|
||||
:param size_boot: size of the boot partition in MB
|
||||
:param size_root: size of the root partition in MB
|
||||
"""
|
||||
pmb.helpers.mount.umount_all(
|
||||
args, args.work + "/chroot_native/dev/install")
|
||||
|
|
|
@ -45,10 +45,10 @@ def partition(args, size_boot):
|
|||
"""
|
||||
Partition /dev/install and create /dev/install{p1,p2}
|
||||
|
||||
size_boot: size of the boot partition in bytes.
|
||||
size_boot: size of the boot partition in MB
|
||||
"""
|
||||
# Convert to MB and print info
|
||||
mb_boot = str(round(size_boot / 1024 / 1024)) + "M"
|
||||
mb_boot = str(round(size_boot)) + "M"
|
||||
logging.info("(native) partition /dev/install (boot: " + mb_boot +
|
||||
", root: the rest)")
|
||||
|
||||
|
|
Loading…
Reference in New Issue