Re: [systemd-devel] systemd-nspawn image

2017-04-12 Thread poma
On 12.04.2017 11:05, Lennart Poettering wrote:
> On Tue, 11.04.17 17:22, poma (pomidorabelis...@gmail.com) wrote:
> 
>> Hello
>>
>> The title doesn't quite work;
>>
>> # qemu-img --version
>> qemu-img version 2.6.2 (qemu-2.6.2-7.fc24), Copyright (c) 2004-2008 Fabrice 
>> Bellard
>>
>> # qemu-img convert fedora25.qcow2 fedora25.raw
>>
>> # file fedora25.*
>> fedora25.qcow2: QEMU QCOW Image (v3), 21474836480 bytes
>> fedora25.raw:   DOS/MBR boot sector
>>
>> # fdisk -l fedora25.raw
>> Disk fedora25.raw: 20 GiB, 21474836480 bytes, 41943040 sectors
>> Units: sectors of 1 * 512 = 512 bytes
>> Sector size (logical/physical): 512 bytes / 512 bytes
>> I/O size (minimum/optimal): 512 bytes / 512 bytes
>> Disklabel type: dos
>> Disk identifier: 0x13bd2a55
>>
>> DeviceBoot   Start  End  Sectors Size Id Type
>> fedora25.raw1 *   2048  2099199  2097152   1G 83 Linux
>> fedora25.raw2  2099200  6293503  4194304   2G 82 Linux swap / Solaris
>> fedora25.raw3  6293504 41943039 35649536  17G 83 Linux
>>
>> # systemd-nspawn --version
>> systemd 229
>> +PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP 
>> +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN
>>
>> # systemd-nspawn --machine Fedora25 --image fedora25.raw
>> Spawning container Fedora25 on /indian/cocos/fedora25.raw.
>> Press ^] three times within 1s to kill container.
>> Timezone Indian/Cocos does not exist in container, not updating container 
>> timezone.
>> execv() failed: No such file or directory
>> Container Fedora25 failed with error code 1.
>>
>> What could be a brake?
> 
> I am not sure what kind of image that is, but have you checked it
> contains a proper /bin/sh and everything? Try "strace -o log -f
> -s500 systemd-nspawn ..." to see the binaries it ries to execv() and
> can't find...
> 

It's rather standard disk image, part of the libvirt installation.

> If you invoke npsawn with those parameters it will execute a shell in
> the container, but that shell must be installed as /bin/sh in its
> image. And that doesn't appear to be the case for you...
> 
> Note that nspawn doesn't really support MBR parition tables with
> multiple bootable Linux partitions anyway, because we don't know which
> one would be the root partition of that. This is explicitly documented
> btw, in the "--image=" bit of the man page.
> 

In fact it seems that it supports, but of course in the context, see below

> My educated guess is that partition 1 of your image is a boot
> partition, and it is marked with the MBR bootable flag. nspawn uses
> that as root partition, but can't find /bin/sh hence.
> 
> Use an image with GPT partition table, or an image containing a single
> MBR partition marked "bootable" of type 83, or even an image
> containing not partition at all and just a file system.
> 
> Lennart
> 

This will do the trick:

# sfdisk -A fedora25.raw
fedora25.raw1
# sfdisk -A fedora25.raw 3
The bootable flag on partition 1 is disabled now.
The bootable flag on partition 3 is enabled now.

The partition table has been altered.
Syncing disks.
# sfdisk -A fedora25.raw
fedora25.raw3


# man 1 systemd-nspawn
...
OPTIONS
   ...
   -i, --image=
   Disk image to mount the root directory for the container from. Takes 
a path to a regular file or to a block device node. The file
   or block device must contain either:

   ยท   An MBR partition table with a single partition of type 0x83 that 
is marked bootable.

   ...

However,
considering the actual relevance of the active "root" partition,
i.e. since this also works:

# sfdisk -A fedora25.raw
fedora25.raw3

# sfdisk -A fedora25.raw 1 3
The bootable flag on partition 3 is disabled now.
The bootable flag on partition 1 is enabled now.
The bootable flag on partition 3 is enabled now.

The partition table has been altered.
Syncing disks.
# sfdisk -A fedora25.raw
fedora25.raw1
fedora25.raw3

i.e.
# fdisk -l fedora25.raw | tail -n4
DeviceBoot   Start  End  Sectors Size Id Type
fedora25.raw1 *   2048  2099199  2097152   1G 83 Linux
fedora25.raw2  2099200  6293503  4194304   2G 82 Linux swap / Solaris
fedora25.raw3 *6293504 41943039 35649536  17G 83 Linux

...
perhaps systemd-nspawn.1 should state:
"An MBR partition table with a '/' partition of type 0x83 that is marked 
bootable."

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemd-nspawn image

2017-04-12 Thread Lennart Poettering
On Tue, 11.04.17 17:22, poma (pomidorabelis...@gmail.com) wrote:

> Hello
> 
> The title doesn't quite work;
> 
> # qemu-img --version
> qemu-img version 2.6.2 (qemu-2.6.2-7.fc24), Copyright (c) 2004-2008 Fabrice 
> Bellard
> 
> # qemu-img convert fedora25.qcow2 fedora25.raw
> 
> # file fedora25.*
> fedora25.qcow2: QEMU QCOW Image (v3), 21474836480 bytes
> fedora25.raw:   DOS/MBR boot sector
> 
> # fdisk -l fedora25.raw
> Disk fedora25.raw: 20 GiB, 21474836480 bytes, 41943040 sectors
> Units: sectors of 1 * 512 = 512 bytes
> Sector size (logical/physical): 512 bytes / 512 bytes
> I/O size (minimum/optimal): 512 bytes / 512 bytes
> Disklabel type: dos
> Disk identifier: 0x13bd2a55
> 
> DeviceBoot   Start  End  Sectors Size Id Type
> fedora25.raw1 *   2048  2099199  2097152   1G 83 Linux
> fedora25.raw2  2099200  6293503  4194304   2G 82 Linux swap / Solaris
> fedora25.raw3  6293504 41943039 35649536  17G 83 Linux
> 
> # systemd-nspawn --version
> systemd 229
> +PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP 
> +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN
> 
> # systemd-nspawn --machine Fedora25 --image fedora25.raw
> Spawning container Fedora25 on /indian/cocos/fedora25.raw.
> Press ^] three times within 1s to kill container.
> Timezone Indian/Cocos does not exist in container, not updating container 
> timezone.
> execv() failed: No such file or directory
> Container Fedora25 failed with error code 1.
> 
> What could be a brake?

I am not sure what kind of image that is, but have you checked it
contains a proper /bin/sh and everything? Try "strace -o log -f
-s500 systemd-nspawn ..." to see the binaries it ries to execv() and
can't find...

If you invoke npsawn with those parameters it will execute a shell in
the container, but that shell must be installed as /bin/sh in its
image. And that doesn't appear to be the case for you...

Note that nspawn doesn't really support MBR parition tables with
multiple bootable Linux partitions anyway, because we don't know which
one would be the root partition of that. This is explicitly documented
btw, in the "--image=" bit of the man page.

My educated guess is that partition 1 of your image is a boot
partition, and it is marked with the MBR bootable flag. nspawn uses
that as root partition, but can't find /bin/sh hence.

Use an image with GPT partition table, or an image containing a single
MBR partition marked "bootable" of type 83, or even an image
containing not partition at all and just a file system.

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] systemd-nspawn image

2017-04-11 Thread poma
Hello

The title doesn't quite work;

# qemu-img --version
qemu-img version 2.6.2 (qemu-2.6.2-7.fc24), Copyright (c) 2004-2008 Fabrice 
Bellard

# qemu-img convert fedora25.qcow2 fedora25.raw

# file fedora25.*
fedora25.qcow2: QEMU QCOW Image (v3), 21474836480 bytes
fedora25.raw:   DOS/MBR boot sector

# fdisk -l fedora25.raw
Disk fedora25.raw: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x13bd2a55

DeviceBoot   Start  End  Sectors Size Id Type
fedora25.raw1 *   2048  2099199  2097152   1G 83 Linux
fedora25.raw2  2099200  6293503  4194304   2G 82 Linux swap / Solaris
fedora25.raw3  6293504 41943039 35649536  17G 83 Linux

# systemd-nspawn --version
systemd 229
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP 
+GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN

# systemd-nspawn --machine Fedora25 --image fedora25.raw
Spawning container Fedora25 on /indian/cocos/fedora25.raw.
Press ^] three times within 1s to kill container.
Timezone Indian/Cocos does not exist in container, not updating container 
timezone.
execv() failed: No such file or directory
Container Fedora25 failed with error code 1.

What could be a brake?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel