From owner-freebsd-questions@freebsd.org Mon Oct 3 17:22:29 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D43D2AF3CF8 for ; Mon, 3 Oct 2016 17:22:29 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de (mx01.qsc.de [213.148.129.14]) (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 608A19B6 for ; Mon, 3 Oct 2016 17:22:29 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de (port-92-195-151-121.dynamic.qsc.de [92.195.151.121]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx01.qsc.de (Postfix) with ESMTPS id 168E63CF24; Mon, 3 Oct 2016 19:22:19 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id u93HMJbY002348; Mon, 3 Oct 2016 19:22:19 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Mon, 3 Oct 2016 19:22:18 +0200 From: Polytropon To: Warren Block Cc: "lokadamus@gmx.de" , FreeBSD Questions Subject: Re: Clone a FBSD system with something in the likes of ghost Message-Id: <20161003192218.51a7f402.freebsd@edvax.de> In-Reply-To: References: <57EC9527.7020202@rcn.com> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Oct 2016 17:22:29 -0000 On Mon, 3 Oct 2016 10:49:06 -0600 (MDT), Warren Block wrote: > In the old MBR days, there was no serious problem with partition tables, > because there was only one partition table at the start of the disk. > GPT puts one at the start of the disk and the end of the disk, so binary > copying a smaller disk to a larger one puts the secondary partition > table somewhere before the end of the larger disk. It's not really > possible to copy a larger disk to a smaller one with dd(1), so that > problem does not come up. Isn't it _technically_ possible to capture the 2nd GPT table (at the end of the source disk) and calculate its proper position in relation to the size of the target disk, and then put it there? Initial state: empty disk: /dev/da0 -------------------- Image smaller than this disk, including two GPT tables (1 and 2): source.img 1#######2 Copy the image: # dd if=source.img of=/dev/da0 /dev/da0 1#######2----------- Get the 2nd GPT table # dd if=source.img of=gpt2.img skip=1000 bs=1M count=1 gpt2.img 2 Put it at the end of the disk (the skip= value has to be calculated from the disk size): # dd if=gpt2.img of=/dev/da0 skip=1000 /dev/da0 1#######2----------2 Optional step: remove (useless or confusing) 2nd GPT table left behind by the image: # dd if=/dev/zero of=/dev/da0 skip=1000 bs=1M count=1 /dev/da0 1#######-----------2 Tadaa! I assume that a 2nd GPT table somewhere inside the free space is not a problem (otherwise I'd suggest to add the additional step to overwrite it with zero bytes). However, even if this might work, it's a very ugly thing. Putting things "at the end of the disk" in the age of virtualized and easily resizable disks doesn't look very clever... > I recommend backing up first, then setting up the target disk partitions > and bootcode: > http://www.wonkity.com/~wblock/docs/html/disksetup.html > > Then use dump/restore to copy from the original: > http://www.wonkity.com/~wblock/docs/html/backup.html That's the easier approach, as it makes sure that all GPT data is going to be located at where it belings, but it involves more steps than the desired "clone" (in _one_ step). > [...] or that it is one of the earlier FreeBSD versions > that did not boot at all if the secondary GPT table was not correct. And _this_ is exactly where the oh so modern and comfortable GPT is going to shoot users in the foot. ;-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...