This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


Re: [Xen-users] Creating a Xen image from HDD partition

To: xen-users@xxxxxxxxxxxxxxxxxxx
Subject: Re: [Xen-users] Creating a Xen image from HDD partition
From: Dane Miller <dane@xxxxxxxxxxxxxxxx>
Date: Fri, 23 Feb 2007 16:47:04 -0800 (PST)
Delivery-date: Fri, 23 Feb 2007 16:47:00 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <9299F09F-8D36-4860-8E9F-11C3D87E7434@xxxxxxxxxx>
List-help: <mailto:xen-users-request@lists.xensource.com?subject=help>
List-id: Xen user discussion <xen-users.lists.xensource.com>
List-post: <mailto:xen-users@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx
----- "Yoav Felberbaum" <mailinglists@xxxxxxxxxx> wrote:
> I have a "stock" CentOS 4.4 installed on /dev/sda3 (with a RHEL  
> install on /dev/sda2). How should I create a xen-usable loop image  
> from the CentOS partition?

First, boot into your RHEL installation so that /dev/sda3 is not in use.
> Would the following (paraphrased) command work from RHEL ...?
> dd if=/dev/sda3 of=/path/to/file.img

Yes, but it will use lots of disk space.  Try this instead (as root) ...

  # make a sparse file and put a filesystem on it
  dd of=/path/to/file.img count=0 bs=1M seek=##size in megabytes##
  mkfs.ext3 /path/to/file.img

  # mount the partition and the sparse file
  mkdir -p /media/sda3 && mkdir -p /media/file.img
  mount /dev/sda3 /media/sda3
  mount -o loop /path/to/file.img /media/file.img

  # transfer the files via tar-over-pipe
  cd /media/sda3
  tar cf - * | (cd /media/file.img; tar xvpf -)
  umount /media/file.img

When this is done, compare the sparse file size as reported by ls and by du...
   ls -lh /path/to/file.img
   du -sh /path/to/file.img

The difference between these two numbers is how much space you saved.


Xen-users mailing list

<Prev in Thread] Current Thread [Next in Thread>