From owner-freebsd-hackers@freebsd.org Fri Mar 23 15:55:38 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 30FC3F53E06 for ; Fri, 23 Mar 2018 15:55:38 +0000 (UTC) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 902627B533 for ; Fri, 23 Mar 2018 15:55:37 +0000 (UTC) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w2NFtYNB031889; Fri, 23 Mar 2018 08:55:34 -0700 (PDT) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd-rwg@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w2NFtYqw031888; Fri, 23 Mar 2018 08:55:34 -0700 (PDT) (envelope-from freebsd-rwg) From: "Rodney W. Grimes" Message-Id: <201803231555.w2NFtYqw031888@pdx.rh.CN85.dnsmgr.net> Subject: Re: Easiest way to get a small VM disk image? In-Reply-To: To: =?UTF-8?Q?Kamila_Sou=C4=8Dkov=C3=A1?= Date: Fri, 23 Mar 2018 08:55:34 -0700 (PDT) CC: "freebsd-hackers@freebsd.org" X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Mar 2018 15:55:38 -0000 > 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 rgrimes@freebsd.org