Jump to content











Photo
- - - - -

Linux copy contigious file

imgxp

  • Please log in to reply
4 replies to this topic

#1 ndog37

ndog37

    Member

  • Members
  • 83 posts
  •  
    New Zealand

Posted 15 September 2013 - 01:07 AM

I used VHD_XP_Create by wimb to create a 7GB 'VHD' flat file which I boot windows XP from grub4dos

 

Occasionally the 'VHD' file gets corrupted, so I created 2 menu entries in my grub4dos menu which basically boot into linux, and 'backup' the VHD file or 'restore' the VHD file. This is simply boots into a linux shell and runs a bash script which 'cp -a' the file from my SSD drive between my larger spinning disk backup drive. This covers my needs well.

 

The problem is that almost without fail after restoring the VHD file to the SSD drive, it will be a non contiguous file, so I then have to take an extra step by booting from another windows OS to run wincontig to make the file contiguous again. If possible I would like to restore the VHD and make it contiguous from linux, as I only need three files, the kernel, the ramdisk and my bash script, which are not susceptible to corruption, running totally from RAM,and is very small (I use tinycore <8MB). My bash script is about 5 lines, and beats booting into a winPE, which I should write a batch script then compile, everytime I want to modify it. I can go down the winPE road, however I prefer not to.

 

I tried searching the Linux community but the general stance is Linux does not care about contiguous files. So go figure.

 

Maybe someone here knows? Also I can share any advice or tips if needed...



#2 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13752 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 15 September 2013 - 09:22 AM

There may be two "sets" of issues causing it, one being "multithreaded copy" and  the other could be connected with the use of the SSD as recording media (TRIM, wear leveling, whatever, etc.).

But it seems to me like - unless during it's use you change it's size - that you are using an incorrect method/tool/approach to restore the .vhd. 

Imagine a (very small) .vhd residing (contiguous) on your SSD.

Let's say that it is ten sectors in size and occupies sectors 0-9:

0123456789

ABCDEGHIJK

 

Now the "corruption" will change sector #3 from D to Z:

 

0123456789

ABCZEGHIJK

but the image will still occupy sectors 0-9.

If you simply dd the backup image to the correct start offset, the image will be restored in the same, contiguous space.

 

You can even do that within grub4dos, by using the internal blocklist and dd command, though it is possible that the internal dd of grub4dos will result slower than it's Linux correspondent, you'll have to do some tests with various block sizes, even if it is a tadbit slower it would completely remove the need to boot into the Linux and then reboot to grub4dos.

 

 

:cheers:

Wonko



#3 saddlejib

saddlejib

    Frequent Member

  • Advanced user
  • 270 posts
  •  
    United Kingdom

Posted 15 September 2013 - 10:13 AM

Or could you not keep the vhd file on a partition which is slightly larger than the file itself and just 'quick format' the partition before restoring your file .



#4 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13752 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 15 September 2013 - 10:26 AM

Or could you not keep the vhd file on a partition which is slightly larger than the file itself and just 'quick format' the partition before restoring your file .

Well, that would NOT work :ph34r: if the partition is NTFS (though it will if it is FAT32 or exFAT ;)).

See here why and the (rather complex) procedure to have a NTFS with file structures "at the beginning" of the volume:

http://reboot.pro/to...disk-emulation/

 

:cheers:

Wonko



#5 saddlejib

saddlejib

    Frequent Member

  • Advanced user
  • 270 posts
  •  
    United Kingdom

Posted 16 September 2013 - 10:05 PM

I kinda expected that, so as you say once contiguous dd it off and back on. Nice thread. Love collaberation.

 

http://reboot.pro/to...disk-emulation/

 

as above






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users