Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boot_clone/root_clone and partitions size #2463

Open
mfatrez opened this issue Feb 14, 2024 · 13 comments
Open

boot_clone/root_clone and partitions size #2463

mfatrez opened this issue Feb 14, 2024 · 13 comments
Assignees

Comments

@mfatrez
Copy link

mfatrez commented Feb 14, 2024

Problem description

when using boot_clone=1 and root_clone=1 size of the partition is not correct :

/dev/loop1p1     2048    43007    40960   20M EFI System
/dev/loop1p2    43008   657407   614400  300M Linux filesystem (boot 1)
/dev/loop1p3   657408  1271807   614400  300M Linux filesystem (boot 2)
/dev/loop1p4  1271808  3368959  2097152    1G Linux filesystem (common part 1)
/dev/loop1p5  3368960  7563263  4194304    2G Linux filesystem (common part 2)
/dev/loop1p6  7563264 40503295 32940032 15.7G Linux filesystem (root 1)
/dev/loop1p7 40503296 67108830 26605535 12.7G Linux filesystem (root 2)

Expected behaviour

/dev/loop1p1     2048    43007    40960   20M EFI System
/dev/loop1p2    43008   657407   614400  300M Linux filesystem (boot 1)
/dev/loop1p3   657408  1271807   614400  300M Linux filesystem (boot 2)
/dev/loop1p4  1271808  3368959  2097152    1G Linux filesystem (common part 1)
/dev/loop1p5  3368960  7563263  4194304    2G Linux filesystem (common part 2)
/dev/loop1p6  7563264 40503295 32940032 15.7G Linux filesystem (same size of the partitions for root_1 and root_2)
/dev/loop1p7 40503296 67108830 26605535 12.7G Linux filesystem (same size of the partitions for root_1 and root_2)

Steps to reproduce the behaviour

<type image="oem" root_clone="1" boot_clone="1" firmware="uefi" filesystem="xfs" bootpartition="true" bootfilesystem="ext4">
        <partitions>
            <partition name="vti_data" size="1G" mountpoint="/opt/myappData" filesystem="xfs"/>
            <partition name="vti_logs" size="2G" mountpoint="/var/log/myappLogs" filesystem="xfs"/>
        </partitions>
        <size unit="G">32</size>
    </type>
</preferences>

OS and Software information

  • KIWI version: 9.24.43 from OBS 2.10
  • Operating system host version: openSUSE Leap 15.5
  • Operating system target version: openSUSE Leap 15.5
  • Open Build Service version (N/A if not using OBS): 2.10
  • Koji version (N/A if not using Koji): N/A
@mfatrez
Copy link
Author

mfatrez commented Feb 14, 2024

by the way, image produced is not usable.

@schaefi
Copy link
Collaborator

schaefi commented Feb 14, 2024

Hmm, I have to check why the root clone differs, that's weird

@schaefi
Copy link
Collaborator

schaefi commented Feb 14, 2024

by the way, image produced is not usable.

why ? does not boot ?

@mfatrez
Copy link
Author

mfatrez commented Feb 14, 2024

Partitions are present but nothing inside. When try to mount it, I have an error:

mount: /mnt/test_clone: wrong fs type, bad option, bad superblock on /dev/mapper/loop0p6, missing codepage or helper program, or other error.

@schaefi
Copy link
Collaborator

schaefi commented Feb 14, 2024

Ok the problem why this is not bootable is not related to the cloning but related to the extra boot partition. See the following build test which also provides an explanation to the issue which is imho not related to kiwi but can be "fixed" as part of the image description.

@schaefi
Copy link
Collaborator

schaefi commented Feb 14, 2024

Partitions are present but nothing inside. When try to mount it, I have an error:

mount: /mnt/test_clone: wrong fs type, bad option, bad superblock on /dev/mapper/loop0p6, missing codepage or helper program, or other error.

That part I don't see, everything is mountable in my test. I copy/paste your type and build my example

lsblk /dev/loop0 
NAME      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
loop0       7:0    0   32G  0 loop 
├─loop0p1 254:0    0    2M  0 part 
├─loop0p2 254:1    0   20M  0 part 
├─loop0p3 254:2    0  300M  0 part 
├─loop0p4 254:3    0  300M  0 part 
├─loop0p5 254:4    0    1G  0 part 
├─loop0p6 254:5    0    2G  0 part 
├─loop0p7 254:6    0 15.7G  0 part 
└─loop0p8 254:7    0 12.7G  0 part

and I can mount all of them (except 0p1 which is expected)

@schaefi
Copy link
Collaborator

schaefi commented Feb 14, 2024

but the size for root is wrong, I'm looking into that part first

@schaefi
Copy link
Collaborator

schaefi commented Feb 14, 2024

blkid /dev/mapper/loop0p6 
/dev/mapper/loop0p6: LABEL="VTI_LOGS" UUID="3611f127-0ae6-4cf6-bb55-29e806de8137" BLOCK_SIZE="512" TYPE="xfs" PARTLABEL="p.lxvti_logs" PARTUUID="dfedb146-aaf9-4b4c-8849-db27119f0105"

looks expected

@schaefi
Copy link
Collaborator

schaefi commented Feb 14, 2024

ok I found the issue. The problem is that you did not had specified a size for the root partition. Without a size for the root part kiwi estimates the size needed for the root part and assigns the rest to the clone. It will never be the exact same and that's bad. Actually we should have a runtime check to indicate this issue.

So if you specify your type as follows the cloning will be correct:

<type image="oem" root_clone="1" boot_clone="1" firmware="uefi" filesystem="xfs" bootpartition="true" bootfilesystem="ext4">
            <partitions>
                <partition name="vti_data" size="1G" mountpoint="/opt/veintree" filesystem="xfs"/>
                <partition name="vti_logs" size="2G" mountpoint="/var/log/veintree" filesystem="xfs"/>
            </partitions>
            <oemconfig>
                <!-- set root partition to 2048MB -->
                <oem-systemsize>2048</oem-systemsize>
                <oem-resize>false</oem-resize>
            </oemconfig>
            <size unit="G">32</size>
        </type>

The system booted up looks like this then

localhost login: root
Password: 
Have a lot of fun...
localhost:~ # lsblk 
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
fd0      2:0    1    4K  0 disk 
sda      8:0    0   32G  0 disk 
├─sda1   8:1    0    2M  0 part 
├─sda2   8:2    0   20M  0 part /boot/efi
├─sda3   8:3    0  300M  0 part 
├─sda4   8:4    0  300M  0 part /boot
├─sda5   8:5    0    1G  0 part /opt/veintree
├─sda6   8:6    0    2G  0 part /var/log/veintree
├─sda7   8:7    0    2G  0 part 
└─sda8   8:8    0    2G  0 part /
sr0     11:0    1 1024M  0 rom  

The overall disk has 32G, the two root partitions have 2G this also means at the end of your disk there is plenty space free

Hope this helps

@schaefi schaefi self-assigned this Feb 14, 2024
@schaefi
Copy link
Collaborator

schaefi commented Feb 14, 2024

Also important to mention, if you clone root, we no longer support resize. This is because you can only resize the last partition of the root clone and the other would not be resizable without destroying data. Thus resize is disabled

@Vogtinator
Copy link
Collaborator

ok I found the issue. The problem is that you did not had specified a size for the root partition. Without a size for the root part kiwi estimates the size needed for the root part and assigns the rest to the clone

kiwi could also use half of the remaining space for each of the root clones.

@schaefi
Copy link
Collaborator

schaefi commented Feb 14, 2024

yes true, but needs a refactor and half of something could be an issue regarding the end of disk and the partition alignment

@schaefi
Copy link
Collaborator

schaefi commented Feb 14, 2024

if you want 100% clone exactly bytewise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants