Easiest way to get a small VM disk image?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Easiest way to get a small VM disk image?

Kamila Součková
Hello,

I want to build an OpenNebula[1]-compatible VM image of FreeBSD 11.1. One
requirement for my use case is that the image should initially be small
(not as in "take up little physical space", but as in "the size of the
virtual disk as visible in the VM should be small". Specifically, I want
the virtual disk size to be no more than 3GB (which should not be a
problem, as the default installation of FreeBSD takes a lot less than 3G).

The VM images available in the official downloads have a virtual size of
20GB. Therefore I need to somehow build my own image (or shrink the
existing ones). Here are the approaches I have thought about:

- Create and partition an empty disk image, rsync the contents of the
official image into it. Problems: AFAIK requires a FreeBSD host to build
(in order to be able to create a UFS filesystem); requires juggling around
with loopback mounts and such. Probably still the most feasible option, but
I am not sure, which is why I'm asking.
- Create an empty image, boot it in a VM and install from an installation
ISO. Problem: not sure how to automate; might not get 1:1 parity with the
official VM image
- Somehow shrink the existing image. Problem: How?
- Find out how the official images are built and do that with a smaller
size. This is where this list comes in :-)

Which (of these, or any other) is the easiest way to get a small image?

Thanks a lot!

Kamila

[1] https://opennebula.org/
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Easiest way to get a small VM disk image?

Rodney W. Grimes-4
> Hello,
>
> I want to build an OpenNebula[1]-compatible VM image of FreeBSD 11.1. One
> requirement for my use case is that the image should initially be small
> (not as in "take up little physical space", but as in "the size of the
> virtual disk as visible in the VM should be small". Specifically, I want
> the virtual disk size to be no more than 3GB (which should not be a
> problem, as the default installation of FreeBSD takes a lot less than 3G).
>
> The VM images available in the official downloads have a virtual size of
> 20GB. Therefore I need to somehow build my own image (or shrink the
> existing ones). Here are the approaches I have thought about:
>
> - Create and partition an empty disk image, rsync the contents of the
> official image into it. Problems: AFAIK requires a FreeBSD host to build
> (in order to be able to create a UFS filesystem); requires juggling around
> with loopback mounts and such. Probably still the most feasible option, but
> I am not sure, which is why I'm asking.
> - Create an empty image, boot it in a VM and install from an installation
> ISO. Problem: not sure how to automate; might not get 1:1 parity with the
> official VM image
> - Somehow shrink the existing image. Problem: How?
> - Find out how the official images are built and do that with a smaller
> size. This is where this list comes in :-)
>
> Which (of these, or any other) is the easiest way to get a small image?
>
> Thanks a lot!

Thought it still requires a FreeBSD host to do, somethink along the
lines of:
truncate -s 2G NEW_FreeBSD_vm_image
mdconfig -f OFFICIAL_FreeBSD_vm_image -u 100
mdconfig -f NEW_FreeBSD_vm_image -u 101
#You have to fdisk, bsdlabale and newfs /dev/md101 here to your needs
mkdir /tmp/output
mount /dev/md101s1 /tmp/output
cd /tmp/output
dump 0Bf 2000000 - /dev/md100s1 | restore rf - && rm restoresymtable

This was hand written here in vi, so probably has lots of sharp edges.

--
Rod Grimes                                                 [hidden email]
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Easiest way to get a small VM disk image?

Ondra Knezour
In reply to this post by Kamila Součková
Dne 23.03.2018 v 16:42 Kamila Součková napsal(a):
> [...]
> The VM images available in the official downloads have a virtual size of
> 20GB. Therefore I need to somehow build my own image (or shrink the
> existing ones). Here are the approaches I have thought about:
>
> [...]
> - Create an empty image, boot it in a VM and install from an installation
> ISO. Problem: not sure how to automate; might not get 1:1 parity with the
> official VM image

This is way I use. Create VM, install what I want, use as template. For
automation, search firstboot in rc(8) [1] - generally you may want to
delete keys for the sshd daemon to recreate new ones for each VM, maybe
set hostname and/or IP addresses if not provided by DHCP etc.

> - Somehow shrink the existing image. Problem: How?

AFAIK there is no way to shrink a UFS partition. Only create new one,
smaller and dump & restore.

> - Find out how the official images are built and do that with a smaller
> size. This is where this list comes in :-)

See the FreeBSD Release Engineering article [2] and release(7) [3] man
page. Search VMFORMATS and/or CLOUDWARE on the later one.

There are also other tools which may give you some insight how can be
FreeBSD image building customized, search Google for nanobsd, picobsd,
chrochet, freebsd wifi build

>
> Which (of these, or any other) is the easiest way to get a small image?

[1]
https://www.freebsd.org/cgi/man.cgi?query=rc&apropos=0&sektion=8&manpath=FreeBSD+11.1-RELEASE&arch=default&format=html
[2]https://www.freebsd.org/doc/en_US.ISO8859-1/articles/releng/article.html#release-build
[3]
https://www.freebsd.org/cgi/man.cgi?query=release&apropos=0&sektion=0&manpath=FreeBSD+11.1-RELEASE&arch=default&format=html#end
--
S pozdravem

Ondra Knezour


smime.p7s (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Easiest way to get a small VM disk image?

Allan Jude-9
In reply to this post by Kamila Součková
On 03/23/2018 11:42, Kamila Součková wrote:

> Hello,
>
> I want to build an OpenNebula[1]-compatible VM image of FreeBSD 11.1. One
> requirement for my use case is that the image should initially be small
> (not as in "take up little physical space", but as in "the size of the
> virtual disk as visible in the VM should be small". Specifically, I want
> the virtual disk size to be no more than 3GB (which should not be a
> problem, as the default installation of FreeBSD takes a lot less than 3G).
>
> The VM images available in the official downloads have a virtual size of
> 20GB. Therefore I need to somehow build my own image (or shrink the
> existing ones). Here are the approaches I have thought about:
>
> - Create and partition an empty disk image, rsync the contents of the
> official image into it. Problems: AFAIK requires a FreeBSD host to build
> (in order to be able to create a UFS filesystem); requires juggling around
> with loopback mounts and such. Probably still the most feasible option, but
> I am not sure, which is why I'm asking.
> - Create an empty image, boot it in a VM and install from an installation
> ISO. Problem: not sure how to automate; might not get 1:1 parity with the
> official VM image
> - Somehow shrink the existing image. Problem: How?
> - Find out how the official images are built and do that with a smaller
> size. This is where this list comes in :-)
>
> Which (of these, or any other) is the easiest way to get a small image?
>
> Thanks a lot!
>
> Kamila
>
> [1] https://opennebula.org/
> _______________________________________________
> [hidden email] mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "[hidden email]"
>

You should be able to generate a version of the official images easily:

do an svn checkout, then:

make -j <#cpus> buildworld buildkernel
cd release
make VMSIZE=2944M SWAPSIZE=128M VMFORMATS=raw DESTDIR=/tmp -DNOSRC
-DNOPORTS -DNOPKG -DWITH_VMIMAGES vm-install

Will create the image in /tmp/vmimages

VMFORMATS can also be qcow2, vmdk, or vhd

--
Allan Jude
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Easiest way to get a small VM disk image?

Kamila Součková
Big thank you to everyone, your suggestions have been very informative! I
will go with Allan's solution, as it is simple and should work for future
releases too. If you happen to need an OpenNebula image, let me know :-)

Best,
Kamila

On Fri, Mar 23, 2018 at 8:47 PM Allan Jude <[hidden email]> wrote:

> On 03/23/2018 11:42, Kamila Součková wrote:
> > Hello,
> >
> > I want to build an OpenNebula[1]-compatible VM image of FreeBSD 11.1. One
> > requirement for my use case is that the image should initially be small
> > (not as in "take up little physical space", but as in "the size of the
> > virtual disk as visible in the VM should be small". Specifically, I want
> > the virtual disk size to be no more than 3GB (which should not be a
> > problem, as the default installation of FreeBSD takes a lot less than
> 3G).
> >
> > The VM images available in the official downloads have a virtual size of
> > 20GB. Therefore I need to somehow build my own image (or shrink the
> > existing ones). Here are the approaches I have thought about:
> >
> > - Create and partition an empty disk image, rsync the contents of the
> > official image into it. Problems: AFAIK requires a FreeBSD host to build
> > (in order to be able to create a UFS filesystem); requires juggling
> around
> > with loopback mounts and such. Probably still the most feasible option,
> but
> > I am not sure, which is why I'm asking.
> > - Create an empty image, boot it in a VM and install from an installation
> > ISO. Problem: not sure how to automate; might not get 1:1 parity with the
> > official VM image
> > - Somehow shrink the existing image. Problem: How?
> > - Find out how the official images are built and do that with a smaller
> > size. This is where this list comes in :-)
> >
> > Which (of these, or any other) is the easiest way to get a small image?
> >
> > Thanks a lot!
> >
> > Kamila
> >
> > [1] https://opennebula.org/
> > _______________________________________________
> > [hidden email] mailing list
> > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> > To unsubscribe, send any mail to "
> [hidden email]"
> >
>
> You should be able to generate a version of the official images easily:
>
> do an svn checkout, then:
>
> make -j <#cpus> buildworld buildkernel
> cd release
> make VMSIZE=2944M SWAPSIZE=128M VMFORMATS=raw DESTDIR=/tmp -DNOSRC
> -DNOPORTS -DNOPKG -DWITH_VMIMAGES vm-install
>
> Will create the image in /tmp/vmimages
>
> VMFORMATS can also be qcow2, vmdk, or vhd
>
> --
> Allan Jude
> _______________________________________________
> [hidden email] mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "[hidden email]"
>
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"