qemu disk on vfat
Hi,
It seems like qemu 0.8.0 does not accept image file from a vfat partition. Is it a bug ?
Greetings.
Yann Le Doaré.
strace :
open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE) = 7read(7, "", 1024) = 0
close(7) = 0open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE) = 7
_llseek(7, 128, [128], SEEK_SET) = 0 read(7, "", 4) = 0 close(7) = 0
write(2, "qemu: could not open hard disk i"..., 74qemu: could not open hard disk image '/mnt/partitions/windows0/qmeu-disk'
) = 74exit_group(1) = ?
It's more likely a typo in your command line. "qmeu"-disk?
Quoted 24 lines · Yann Le Doaré
Hi,
It seems like qemu 0.8.0 does not accept image file from a vfat partition. Is it a bug ?
Greetings.
Yann Le Doaré.
strace :
open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE)= 7read(7, "", 1024)= 0
close(7) = 0open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE)= 7_llseek(7, 128, [128], SEEK_SET) = 0 read(7, "", 4) = 0 close(7) = 0write(2, "qemu: could not open hard disk i"..., 74qemu: could not open hard disk image '
/mnt/partitions/windows0/qmeu-disk'
) = 74exit_group(1)= ?
my option is "-hda /mnt/partitions/windows0/qmeu-disk"
Quoted 33 lines · André Braga
It's more likely a typo in your command line. "qmeu"-disk?
Quoted 16 lines · Yann Le Doaré
Hi,
It seems like qemu 0.8.0 does not accept image file from a vfat partition. Is it a bug ?
Greetings.
Yann Le Doaré.
strace :
open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE)= 7read(7, "", 1024)= 0
close(7) = 0open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE)= 7Quoted 8 lines
_llseek(7, 128, [128], SEEK_SET) = 0 read(7, "", 4) = 0 close(7) = 0write(2, "qemu: could not open hard disk i"..., 74qemu: could not open hard disk image '
/mnt/partitions/windows0/qmeu-disk'
) = 74exit_group(1)= ?_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel
Are you sure coreect spelling is "qmeu-disk", not "qemu-disk"?
Signature · 8 lines
Alex. "Yann Le Doar�" <[email protected]> wrote in message news:1147084877.5817.25.camel@localhost... my option is "-hda /mnt/partitions/windows0/qmeu-disk" Le dimanche 07 mai 2006 � 05:44 -0300, Andr� Braga a �crit :
Quoted 33 lines
It's more likely a typo in your command line. "qmeu"-disk?
Quoted 16 lines · Yann Le Doar�
Hi,
It seems like qemu 0.8.0 does not accept image file from a vfat partition. Is it a bug ?
Greetings.
Yann Le Doar�.
strace :
open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE)= 7read(7, "", 1024)= 0
close(7) = 0open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE)= 7Quoted 8 lines
_llseek(7, 128, [128], SEEK_SET) = 0 read(7, "", 4) = 0 close(7) = 0write(2, "qemu: could not open hard disk i"..., 74qemu: could not open hard disk image '
/mnt/partitions/windows0/qmeu-disk'
) = 74exit_group(1)= ?_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel
Quoted 16 lines · Yann Le Doaré
Hi,
It seems like qemu 0.8.0 does not accept image file from a vfat partition. Is it a bug ?
Greetings.
Yann Le Doaré.
strace :
open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE)= 7read(7, "", 1024)= 0
close(7) = 0open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE)= 7
Quoted 11 lines
_llseek(7, 128, [128], SEEK_SET) = 0 read(7, "", 4) = 0 close(7) = 0write(2, "qemu: could not open hard disk i"..., 74qemu: could not open hard disk image '
/mnt/partitions/windows0/qmeu-disk'
) = 74exit_group(1)= ?
Hi!
What size is it? Linux only supports vfat (FAT32) partitions with at most 4GB files. A disc image can easily reach that.
If the problem is that, the bug is in the kernel, not in qemu. (Just try to copy it an ext2/3 partition. If is isn't possible, or its size differs, the bug has nothing to do with qemu.)
Miklos Gyozo
ps. ext2/3 is surely better than vfat for disc images, cause it supports holes
Quoted 2 lines · NyOS
What size is it? Linux only supports vfat (FAT32) partitions with at most 4GB files. A disc image can easily reach that.
4GB per file is actually a FAT32 limitation - it can't store larger files (and there's nothing you can do about it).
Signature · 4 lines
< Jernej Simončič ><><><><>< http://deepthought.ena.si/ >
Life is what happens to you while you are making other plans.
-- Knight's LawWith :
qemu-img create /mnt/partitions/windows0/qmeu-disk 4M qemu -hda /mnt/partitions/windows0/qmeu-disk
qemu: could not open hard disk image'/mnt/partitions/windows0/qmeu-disk'
but with on ext3/ext2 or tmpfs, there is no problem.
Quoted 49 lines · NyOS
Quoted 16 lines · Yann Le Doaré
Hi,
It seems like qemu 0.8.0 does not accept image file from a vfat partition. Is it a bug ?
Greetings.
Yann Le Doaré.
strace :
open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE)= 7read(7, "", 1024)= 0
close(7) = 0open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE)= 7Quoted 11 lines
_llseek(7, 128, [128], SEEK_SET) = 0 read(7, "", 4) = 0 close(7) = 0write(2, "qemu: could not open hard disk i"..., 74qemu: could not open hard disk image '
/mnt/partitions/windows0/qmeu-disk'
) = 74exit_group(1)= ?Hi!
What size is it? Linux only supports vfat (FAT32) partitions with at most 4GB files. A disc image can easily reach that.
If the problem is that, the bug is in the kernel, not in qemu. (Just try to copy it an ext2/3 partition. If is isn't possible, or its size differs, the bug has nothing to do with qemu.)Miklos Gyozo
ps. ext2/3 is surely better than vfat for disc images, cause it supports holes
_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel
Am Montag, 8. Mai 2006 21:44 schrieb Yann Le Doaré:
Quoted 9 lines
With :
qemu-img create
/mnt/partitions/windows0/qmeu-disk4M qemu -hda/mnt/partitions/windows0/qmeu-diskqemu: could not open hard disk image'/mnt/partitions/windows0/qmeu-disk'
but with on ext3/ext2 or tmpfs, there is no problem.
Did you check, if the permissions of the mounted vfat filesystem are ok? What happens when you try qemu -hda /mnt/partitions/windows0/qmeu-disk -snapshot?
with -snapshot I have the same error.
vfat options are :
rw,nodiratime,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1
It can use my ext3 partitions, so it is not a problem for me.
Thanks for you responses.
Quoted 19 lines · Jan Marten Simons
Am Montag, 8. Mai 2006 21:44 schrieb Yann Le Doaré:
Quoted 9 lines
With :
qemu-img create
/mnt/partitions/windows0/qmeu-disk4M qemu -hda/mnt/partitions/windows0/qmeu-diskqemu: could not open hard disk image'/mnt/partitions/windows0/qmeu-disk'
but with on ext3/ext2 or tmpfs, there is no problem.
Did you check, if the permissions of the mounted vfat filesystem are ok? What happens when you try qemu -hda
/mnt/partitions/windows0/qmeu-disk-snapshot?_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel
Hi,
Quoted 2 lines · Yann Le Doaré
It seems like qemu 0.8.0 does not accept image file from a vfat partition. Is it a bug ?
No.
You cannot emulate a whole disk by providing only a partition.
Ciao,
Dscho
Quoted 12 lines · Yann Le Doaré
Hi,
It seems like qemu 0.8.0 does not accept image file from a vfat partition. Is it a bug ?
Greetings.
Yann Le Doaré.
strace :
Quoted 8 lines
open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE)= 7read(7, "", 1024)= 0 close(7)= 0 open("/mnt/partitions/windows0/qmeu-disk",O_RDONLY|O_LARGEFILE) = 7
_llseek(7, 128, [128], SEEK_SET)= 0read(7, "", 4)= 0 close(7)
= 0 write(2, "qemu: could not open hard disk i"..., 74qemu: could
not open hard disk image '/mnt/partitions/windows0/qmeu-disk' ) = 74exit_group(1)= ?
It's pretty clear that what's happening is that qemu opening the file and the filesystem is claiming it's an empty file.
So, I recommend you do the following:
First:
du -sh /mnt/partitions/windows0/qmeu-disk
ls -al /mnt/partitions/windows0/qmeu-disk
And make sure both report a non-zero result. If either reports 0 as the size, then you screwed up copying the file to your vfat partition.
Second:
In vl.h, change:
#ifndef O_LARGEFILE
#define O_LARGEFILE 0
#endif
To:
#ifdef O_LARGEFILE
#undef O_LARGEFILE
#endif
#define O_LARGEFILE 0
And if that fixes your problem, then vfat is broken when open()'d with O_LARGEFILE. If that's the case, you should report it as a vfat bug.
Regards,
Anthony Liguori
You are right ! :
sh-2.05b# qemu-img create /mnt/partitions/windows0/qmeu-disk 4M Formating '/mnt/partitions/windows0/qmeu-disk', fmt=raw, size=4096 kB sh-2.05b# ls -al /mnt/partitions/windows0/qmeu-disk
-rwxr-xr-x 1 root root 0 2006-05-09
23:37 /mnt/partitions/windows0/qmeu-disk
sh-2.05b# qemu-img create /mnt/partitions/windows0/qmeu-disk 40M Formating '/mnt/partitions/windows0/qmeu-disk', fmt=raw, size=40960 kB sh-2.05b# ls -al /mnt/partitions/windows0/qmeu-disk
-rwxr-xr-x 1 root root 0 2006-05-09
23:38 /mnt/partitions/windows0
Quoted 64 lines · Anthony Liguori
Quoted 12 lines · Yann Le Doaré
Hi,
It seems like qemu 0.8.0 does not accept image file from a vfat partition. Is it a bug ?
Greetings.
Yann Le Doaré.
strace :
Quoted 8 lines
open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE)= 7read(7, "", 1024)= 0 close(7)= 0 open("/mnt/partitions/windows0/qmeu-disk",O_RDONLY|O_LARGEFILE) = 7
_llseek(7, 128, [128], SEEK_SET)= 0read(7, "", 4)= 0 close(7)
= 0 write(2, "qemu: could not open hard disk i"..., 74qemu: could
not open hard disk image '/mnt/partitions/windows0/qmeu-disk' ) = 74exit_group(1)= ?It's pretty clear that what's happening is that qemu opening the file and the filesystem is claiming it's an empty file.
So, I recommend you do the following:
First:
du -sh
/mnt/partitions/windows0/qmeu-disk
ls -al/mnt/partitions/windows0/qmeu-diskAnd make sure both report a non-zero result. If either reports 0 as the size, then you screwed up copying the file to your vfat partition.
Second:
In
vl.h, change:#ifndef
O_LARGEFILE
#defineO_LARGEFILE0
#endifTo:
#ifdef
O_LARGEFILE
#undefO_LARGEFILE
#endif
#defineO_LARGEFILE0And if that fixes your problem, then vfat is broken when open()'d with
O_LARGEFILE. If that's the case, you should report it as a vfat bug.Regards,
Anthony Liguori
_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel
Quoted 12 lines · Yann Le Doaré
You are right ! :
sh-2.05b# qemu-img create
/mnt/partitions/windows0/qmeu-disk4M Formating '/mnt/partitions/windows0/qmeu-disk', fmt=raw, size=4096 kB sh-2.05b# ls -al/mnt/partitions/windows0/qmeu-disk
-rwxr-xr-x 1 root root 0 2006-05-09
23:37/mnt/partitions/windows0/qmeu-disk
sh-2.05b# qemu-img create/mnt/partitions/windows0/qmeu-disk40M Formating '/mnt/partitions/windows0/qmeu-disk', fmt=raw, size=40960 kB sh-2.05b# ls -al/mnt/partitions/windows0/qmeu-disk
-rwxr-xr-x 1 root root 0 2006-05-09
23:38/mnt/partitions/windows0
IIRC creating a "raw" QEMU disc image makes use of sparse files, a concept not supported under FAT16/32. A qcow disc image should work fine. If you want to create a raw disc image on a FAT partition, use (from your example) dd if=/dev/zero of=/mnt/partitions/windows0/qmeu-disk bs=1024 count=40960
It'll take a bit longer than qemu-img would but then it's having to write out every block in the disc image to the real disc.
Hope that helps.
Quoted 68 lines · Anthony Liguori
Quoted 56 lines · Yann Le Doaré
Quoted 13 lines
Hi,
It seems like qemu 0.8.0 does not accept image file from a vfat partition. Is it a bug ?
Greetings.
Yann Le Doaré.
strace :
Quoted 8 lines
open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE)= 7read(7, "", 1024)= 0 close(7)= 0 open("/mnt/partitions/windows0/qmeu-disk",O_RDONLY|O_LARGEFILE) = 7
_llseek(7, 128, [128], SEEK_SET)= 0read(7, "", 4)= 0 close(7)
= 0 write(2, "qemu: could not open hard disk i"..., 74qemu: could
not open hard disk image '/mnt/partitions/windows0/qmeu-disk' ) = 74exit_group(1)= ?It's pretty clear that what's happening is that qemu opening the file and the filesystem is claiming it's an empty file.
So, I recommend you do the following:
First:
du -sh
/mnt/partitions/windows0/qmeu-disk
ls -al/mnt/partitions/windows0/qmeu-diskAnd make sure both report a non-zero result. If either reports 0 as the size, then you screwed up copying the file to your vfat partition.
Second:
In
vl.h, change:#ifndef
O_LARGEFILE
#defineO_LARGEFILE0
#endifTo:
#ifdef
O_LARGEFILE
#undefO_LARGEFILE
#endif
#defineO_LARGEFILE0And if that fixes your problem, then vfat is broken when open()'d with
O_LARGEFILE. If that's the case, you should report it as a vfat bug.Regards,
Quoted 8 lines
Anthony Liguori
_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel
Quoted 5 lines
_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel
-- Michael "Soruk" McConnell
Eridani Star System
MailStripper - http://www.MailStripper.eu/ - SMTP spam filter Mail Me Anywhere - http://www.MailMeAnywhere.com/ - Mobile email
Quoted 10 lines · Michael McConnell
IIRC creating a "raw" QEMU disc image makes use of sparse files, a concept not supported under FAT16/32. A qcow disc image should work fine. If you want to create a raw disc image on a FAT partition, use (from your example) dd if=/dev/zero of=/mnt/partitions/windows0/qmeu-disk bs=1024 count=40960
It'll take a bit longer than qemu-img would but then it's having to write out every block in the disc image to the real disc.
Hope that helps.
Here is a patch that fixes the raw block driver. It is able to detect when creation of a sparse file failed and failback to using the dd method.
qemu-img works correctly with this patch.
Signature · 2 lines
Infinite complexity begets infinite beauty. Infinite precision begets infinite perfection.
block.c renamed from block.c.orig +23 -1
@@ -756,7 +756,8 @@static int raw_create (const char *filename,int64_t total_size,const char *backing_file,int flags) { -int fd; +int fd, size, i; +unsigned char buf512[512 ];if (flags || backing_file)return -ENOTSUP ;
@@ -767,6 +768,27 @@return -EIO ;ftruncate (fd, total_size *512 );close (fd); + +/* check to see if the filesystem handled sparseness correctly */ + fd =open (filename,O_RDONLY |O_BINARY |O_LARGEFILE ); +if (fd <0 ) +return -EIO ;// some weird badness happened here + size =lseek (fd,0LL ,SEEK_END ); +close (fd); + +if (size) +return 0 ; +printf ("Warning: your filesystem does not appear to support sparse file\nFalling back to pseudo-/dev/zero method\nSit back and enjoy a cup of coffee... This may take a while.\n" ); + + fd =open (filename,O_WRONLY |O_CREAT |O_TRUNC |O_BINARY |O_LARGEFILE , +0644 ); +if (fd <0 ) +return -EIO ; +memset (buf512,0 ,512 ); +for (i =0 ; i < total_size; i++) +write (fd, buf512,512 ); +close (fd); +return 0 ; }
Quoted 9 lines · Jim C. Brown
Quoted 8 lines · Michael McConnell
IIRC creating a "raw" QEMU disc image makes use of sparse files, a concept not supported under FAT16/32. A qcow disc image should work fine. If you want to create a raw disc image on a FAT partition, use (from your example) dd if=/dev/zero of=/mnt/partitions/windows0/qmeu-disk bs=1024 count=40960
It'll take a bit longer than qemu-img would but then it's having to write out every block in the disc image to the real disc.
Quoted 11 lines
Quoted 2 lines
Hope that helps.
Here is a patch that fixes the raw block driver. It is able to detect when creation of a sparse file failed and failback to using the dd method.
qemu-img works correctly with this patch.
Signature · 2 lines
Infinite complexity begets infinite beauty. Infinite precision begets infinite perfection.
This version doesn't try to continue but just bails out when it is unable to make sparse files.
Signature · 2 lines
Infinite complexity begets infinite beauty. Infinite precision begets infinite perfection.
block.c renamed from block.c.orig +16 -1
@@ -756,7 +756,8 @@static int raw_create (const char *filename,int64_t total_size,const char *backing_file,int flags) { -int fd; +int fd, size, i; +unsigned char buf512[512 ];if (flags || backing_file)return -ENOTSUP ;
@@ -767,6 +768,20 @@return -EIO ;ftruncate (fd, total_size *512 );close (fd); + +/* check to see if the filesystem handled sparseness correctly */ + fd =open (filename,O_RDONLY |O_BINARY |O_LARGEFILE ); +if (fd <0 ) +return -EIO ;// some weird badness happened here + size =lseek (fd,0LL ,SEEK_END ); +close (fd); + +if (!size) + { +printf ("Error: your filesystem does not appear to support sparse file\n" ); +return -EIO ; + } +return 0 ; }
Aactually, the bug is in vfat not in qemu-img.
qemu-img correctly uses ftruncate() which is suppose to make the file sparse if the underlying filesystem supports it, but it should fall back to adding zeros to the end of the file. On vfat you aren't able to seek past the end of a file period, so this doesn't work.
Probably qemu-img should just bail out in this case (as the other disk formats should work fine and you can always use dd). The 2nd patch I released does this - the error message just needs to be made more accurate.
Signature · 2 lines
Infinite complexity begets infinite beauty. Infinite precision begets infinite perfection.
Quoted 2 lines · Jim C. Brown
Aactually, the bug is in vfat not in qemu-img.
Not really. POSIX doesn't mandate that ftruncate() increase a file size. This is a Linux-ism and is only valid for filesystems that support holes (which vfat doesn't).
Regards,
Anthony Liguori
Quoted 10 lines
qemu-img correctly uses
ftruncate()which is suppose to make the file sparse if the underlying filesystem supports it, but it should fall back to adding zeros to the end of the file. On vfat you aren't able to seek past the end of a file period, so this doesn't work.Probably qemu-img should just bail out in this case (as the other disk formats should work fine and you can always use dd). The 2nd patch I released does this - the error message just needs to be made more accurate.
Quoted 6 lines · Anthony Liguori
Quoted 1 line · Jim C. Brown
Aactually, the bug is in vfat not in qemu-img.
Not really. POSIX doesn't mandate that
ftruncate()increase a file size. This is a Linux-ism and is only valid for filesystems that support holes (which vfat doesn't).
Actually it isn't a Linux-ism, it's very common unix behavior. Both HPUX and Solaris extend the file, and are documented to do so.
The linux manpages also document that the file is padded with zeros. It's only if you dig into the glibc documentation that you discover this is a lie.
Paul
Quoted 4 lines · Anthony Liguori
Quoted 2 lines · Jim C. Brown
Aactually, the bug is in vfat not in qemu-img.
Quoted 8 lines
Not really. POSIX doesn't mandate that
ftruncate()increase a file size. This is a Linux-ism and is only valid for filesystems that support holes (which vfat doesn't).Regards,
Anthony Liguori
Ok, so in that case this is something qemu-img should handle on its own then. (Since we're not likely to see a "fix" in either glibc or the kernel for this, and it has the potential to be a portability issue.)
Quoted 4 lines · Jim C. Brown
qemu-img correctly uses
ftruncate()which is suppose to make the file sparse if the underlying filesystem supports it, but it should fall back to adding zeros to the end of the file. On vfat you aren't able to seek past the end of a file period, so this doesn't work.
Turns out I was wrong about this too.
http://www.mail-archive.com/[email protected]/msg00556.html
Here is a patch that silently handles the Linux/vfat case using lseek().
Signature · 2 lines
Infinite complexity begets infinite beauty. Infinite precision begets infinite perfection.
block.c +15 -1
@@ -753,6 +753,20 @@close (s->fd); } +int qemu_ftruncate (int fd,off_t length) +/* ftruncate() isn't guarranteed to grow a file, according to POSIX. ** +** This is. */ +{ +int res =ftruncate (fd, length); +if (res && (errno ==EPERM )) + { +if ((lseek ( fd, length -1 ,SEEK_SET ) == (off_t)-1 ) || + (write (fd,"\0" ,1 ) ==-1 )) +return -1 ; + } +return res; +} +static int raw_create (const char *filename,int64_t total_size,const char *backing_file,int flags) {
@@ -765,7 +779,7 @@ 0644);if (fd <0 )return -EIO ; -ftruncate (fd, total_size *512 ); +qemu_ftruncate (fd, total_size *512 );close (fd);return 0 ; }
Quoted 14 lines · Yann Le Doaré
You are right ! :
sh-2.05b# qemu-img create
/mnt/partitions/windows0/qmeu-disk4M Formating '/mnt/partitions/windows0/qmeu-disk', fmt=raw, size=4096 kB sh-2.05b# ls -al/mnt/partitions/windows0/qmeu-disk
-rwxr-xr-x 1 root root 0 2006-05-09
23:37/mnt/partitions/windows0/qmeu-disk
sh-2.05b# qemu-img create/mnt/partitions/windows0/qmeu-disk40M Formating '/mnt/partitions/windows0/qmeu-disk', fmt=raw, size=40960 kB sh-2.05b# ls -al/mnt/partitions/windows0/qmeu-disk
-rwxr-xr-x 1 root root 0 2006-05-09
23:38/mnt/partitions/windows0
FAT filesystems don't do sparse files (files with "holes" in them).
The qemu-img "raw" option attempts to create sparse disk images.
Create the image on a filesystem that does support sparse files and then _copy_ those sparse files to a FAT filesystem and they'll work just fine.
- Ian C. Blenke <[email protected]> http://ian.blenke.com/