sparse image
Malcolm Kay
malcolm.kay at internode.on.net
Wed Jun 30 16:16:08 UTC 2010
On Wed, 30 Jun 2010 02:49 pm, Aiza wrote:
> Vincent Hoffman wrote:
> > On 23/06/2010 11:26, Aiza wrote:
> >> Is there an equivalent of the MAC sparseimage on FreeBSD?
> >
> > If you mean you would like to make a sparse file and attach
> > it using mdconfg then
> > dd if=/dev/zero of=/path/to/outfile bs=1M seek=1024 count=0
> > This will give you a sparse file that reports a gig in size,
> > but only uses whats actually in use.
> > you can then use mdconfig(8) to allow this to be partitioned
> > formatted and mounted.
> > Example below. see also
> > http://www.freebsd.org/doc/en/books/handbook/disks-virtual.h
> >tml although that example doesnt use a spare file.
> >
> > [root at ostracod /scratch/media]# dd if=/dev/zero of=foo.img
> > bs=1M seek=1024 count=0
> > 0+0 records in
> > 0+0 records out
> > 0 bytes transferred in 0.000066 secs (0 bytes/sec)
> > [root at ostracod /scratch/media]# ls -lh foo.img
> > -rw-r--r-- 1 root wheel 1.0G Jun 23 11:45 foo.img
> > [root at ostracod /scratch/media]# du -h foo.img
> > 48K foo.img
> > [root at ostracod /scratch/media]# mdconfig -a -t vnode -f
> > foo.img md0
> > [root at ostracod /scratch/media]# gpart create -s gpt md0
> > md0 created
> > [root at ostracod /scratch/media]# gpart add -t freebsd-ufs md0
> > md0p1 added
> > [root at ostracod /scratch/media]# newfs /dev/md0p1
> > /dev/md0p1: 1024.0MB (2097084 sectors) block size 16384,
> > fragment size 2048 using 6 cylinder groups of 183.72MB,
> > 11758 blks, 23552 inodes. super-block backups (for fsck -b
> > #) at:
> > 160, 376416, 752672, 1128928, 1505184, 1881440
> > [root at ostracod /scratch/media]# !ls
> > ls -lh foo.img
> > -rw-r--r-- 1 root wheel 1.0G Jun 23 11:46 foo.img
> > [root at ostracod /scratch/media]# !du
> > du -h foo.img
> > 736K foo.img
> > [root at ostracod /scratch/media]# mount /dev/md0p1 /mnt/foo/
> > [root at ostracod /scratch/media]# df -h | grep foo
> > /dev/md0p1 989M 4.0K 910M 0%
> > /mnt/foo [root at ostracod /scratch/media]#
> >
> > Hope this is helpful.
> > Vince
>
> Thanks Vince this was very helpful.
> I was able to create a sparse image jail, but when I used cpio
> to duplicate the sparse file to other jails I lost the
> sparseness of the file. Is there a way to copy a sparse file
> and keep it intact?
rsync with option -S or --sparse claims to handle sparse files
efficiently -- but I'm not sure just what this means. Probably
that it produces a similar sparse copy, but it is possible it
just means an efficient transfer of data or in particular that
data from the sparse areas does not result in large literal
transfers of nulls.
Malcolm
>
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to
> "freebsd-questions-unsubscribe at freebsd.org"
More information about the freebsd-questions
mailing list