Jump to content











Photo
- - - - -

Rawcopy was slow, switched to 7z!


  • Please log in to reply
3 replies to this topic

#1 kwiqshter

kwiqshter
  • Members
  • 1 posts
  •  
    United States

Posted 10 May 2012 - 09:27 PM

This method isn't a solution to everyone, however if you don't need an exact image of the disk this is most likely going to be quicker. It was for me!

Problem: My startups were taking way too long. The drive would take 1-5m to show up on a fresh boot. My shutdowns also took between 30s - 1m.

After I switched to storing my drive contents in a 7z archive my shutdowns took about 5s and my drive was instantly available on startup.

Below is a step by step guide on how to use 7z archives with ImDisk for auto-save on shutdown and load on startup.

Let me know if I missed anything! This is very similar to another guide I seen, the main/only difference is the code for the scripts.


Step 1. Install 7-Zip: http://www.7-zip.org/

Step 2. Add the 7-Zip installation directory to your PATH
Right click on My Computer -> Properties -> Advanced system settings

At the bottom of this window click Environment Variables.

Under system variables go to "Path".
Double click on this string.

Directories are separated with a semi colon ( ; ). If there isn't a semi colon at the end, add one then type out the directory to your 7-Zip installation. You will need to re-open any command prompts you have open to use the updated Path.

Step 3. Create a "startup" script (.bat or .cmd) that creates the virtual disk and loads an archive onto the new disk.

Here's an example. This creates a drive in virtual memory and assigns in the letter G. It then extracts the archive E:\RAMDISK\GDRIVE.7z to G:\


imdisk -a -t vm -s 1536M -p "/fs:ntfs /q /y" -m G:

7z x GDRIVE.7z -oG:\


7z = 7zip
x = extract files, preserve directories
-o = extract files to this path (IE: -oC:\Extract\to\here\)

Step 4. Create a "shutdown" script (.bat or .cmd) that will simple store the contents of your drive in a 7z archive.

Here's an example.


7z a -mx0 e:\RAMDISK\GDRIVE.7z G:\


7z = 7zip
a = archive files
-mx0 = the compression level. mx0 is NO compression, it just stores the files in an archive. (Read More [scroll down to "Example -m switch"])

Step 5. Add these new scripts (the .bat or .cmd files) to the task scheduler.

Right-click My Computer -> Manage

On the left go to Task Scheduler -> Task Scheduler Library

At the top go to Action -> Create Task.

Under the General tab make sure the User is set to SYSTEM and check "Run with highest privileges" and "Hidden" at the very bottom.

Go to the Trigger tab. Click the New button

For Startup
Begin the task: At Startup
Make sure "Enabled" is checked at the bottom then click OK

For Shutdown
Begin the task: On an event
Tick "Basic"
Log: System
Source: USER32
Event ID: 1074

Make sure "Enabled" is checked at the bottom then click OK

Now go to the actions tab. Click new.
Action: Start a program
Program/script: Point it to the .cmd or .bat file you made for either shutdown or startup.
Leave Arguments and "Start in" blank unless you use those.

Make sure nothing is checked in the Conditions tab.

Go to the Settings tab.
Check "Allow task to be run on demand"
Check "Run task as soon as possible .."
You can leave "If the task fails, .." unchecked.
You can leave "Stop the task if it runs longer than .." unchecked. Feel free to configure this.
Uncheck "If the running task does not end when requested, force it to stop"
Uncheck "If the task is not scheduled to run again, .."
Set to Do not start a new instance

(The startup and shutdown tasks are identical except for the triggers)

:thumbsup:
  • Brito likes this

#2 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

  • Developer
  • 1448 posts
  • Location:Borås, Sweden
  •  
    Sweden

Posted 10 May 2012 - 09:50 PM

Thanks for a great guide!

I strongly agree that many people seem to do a lot of unnecessary image copying when it comes to RAM disks. I myself prefer, in most cases, to use file synchronization in one way or another. As an alternative to your 7-zip solution one can use for example robocopy, or my strarc utility to copy for example changed files from a RAM disk to permanent storage at shutdown and to copy all files from permanent storage to RAM disk at startup.

:thumbsup: :cheers:

#3 bilou_gateux

bilou_gateux

    Frequent Member

  • Expert
  • 230 posts
  •  
    France

Posted 22 January 2013 - 02:54 PM

Step 1. Install 7-Zip: http://www.7-zip.org/ Step 2. Add the 7-Zip installation directory to your PATH Right click on My Computer -> Properties -> Advanced system settings At the bottom of this window click Environment Variables. Under system variables go to "Path". Double click on this string. Directories are separated with a semi colon ( ; ). If there isn't a semi colon at the end, add one then type out the directory to your 7-Zip installation. You will need to re-open any command prompts you have open to use the updated Path.

 

 

small script (I'm not the author but i've lost the source link) to install 7-zip x86 and add to path.

(works fine with windows XP Professional 32bit, can't say with newer OS)

may not work with 64bit OS because of  script check install path using strProgramFiles variable

 

 

@echo off&&Setlocal enabledelayedexpansion
set strProgramFiles=%ProgramFiles%
if not "%ProgramFiles(x86)%" == "" set strProgramFiles=%ProgramFiles(x86)%

:__install
FOR /F "delims=" %%I in ('echo %strProgramFiles%\7-Zip') do (
  set "path_to_add=%%~sI"
  for /f "tokens=*" %%J in ('dir /b 7z*.exe') do (
    %%~nxJ /S >NUL 2>&1
    )
  )
SET path_var=
FOR /F "usebackq tokens=2 delims==" %%a IN (`WMIC Environment WHERE ^(Name^='PATH' AND SystemVariable^='True'^) GET VariableValue /FORMAT:LIST`) DO (
    FOR /F "tokens=* delims=" %%b IN ("%%a") DO (
        SET path_var=!path_var!%%b
    )
)

SET test_var=!path_var:%%=%%%%!
SET test_var="!test_var!"
SET test_var=!test_var:;=","!
CALL :test_path !test_var!

IF "!dupe!" EQU "no" (
    ECHO !path_msg!
    SET path_var=!path_var!;%path_to_add%
    WMIC Environment WHERE ^(Name^='PATH' AND SystemVariable^='True'^) SET VariableValue='!path_var!'
) ELSE (
    ECHO !path_msg!
)
EXIT /B

:test_path
SET dupe=no
SET path_msg=Adding to %%path%%: "%path_to_add%"
:loop
SET var=%1
IF DEFINED var (
    SET var=!var:"=!
    IF "!var!" EQU "%path_to_add%" (
        SET dupe=yes
        SET path_msg=Already found in %%path%%: "%path_to_add%"
    )
    SHIFT
    GOTO loop
)
GOTO :EOF


#4 MedEvil

MedEvil

    Platinum Member

  • .script developer
  • 7771 posts

Posted 22 January 2013 - 04:25 PM

Just a hint.
There's no reason to add anything to the path variable, if the complete path to 7z.exe is used in the command.

:cheers:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users