Hello, I know that this is fairly straightforward & supposedly documented elsewhere, but damned if I can find the info using Google. 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? Would the following (paraphrased) command work from RHEL ...? dd if=/dev/sda3 of=/path/to/file.img I understand that certain directories, like /boot, /proc & a couple of others should NOT be in the image. Is there a full list? TIA for any help you are able to provide! Y. _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Nico Kadel-Garcia
2007-Feb-23 00:09 UTC
Re: [Xen-users] Creating a Xen image from HDD partition
Yoav Felberbaum wrote:> Hello, > > I know that this is fairly straightforward & supposedly documented > elsewhere, but damned if I can find the info using Google. > > 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? > > Would the following (paraphrased) command work from RHEL ...? > > dd if=/dev/sda3 of=/path/to/file.imgThis is the suckful way to do it. "dd" copies are inefficient, and rely on the new partitions or files being exactly the same size. It''s vastly faster and more efficient to use "dd" with skip commands to create a file that contains nothing you care about of the designated size, do a mkfs -t ext3 on that file, mount the file as a loop file system, mount the old partition, and do a "cp -a" or a "rsync" between the partitions. Then unmount them both and use the copy.> I understand that certain directories, like /boot, /proc & a couple > of others should NOT be in the image. Is there a full list? > > TIA for any help you are able to provide!They won''t be if you''re not duplicating a live OS, but only a mounted filesystem. _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
----- "Yoav Felberbaum" <mailinglists@mrdini.com> 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.imgYes, 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. Dane _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users