Windows on RAM disk


    In our age, we all love speed. We love fast transport, fast delivery services, high-speed Internet. And, of course, fast computers. We have the sixth sense by which we detect milli / microsecond delays. Often there is a desire to disperse something.

    But what to disperse? What slows down our work and creates discomfort? Our processors operate at many GHz frequencies, drive electrons at relativistic speeds. The memory with data transfer buses is not far behind them. But as soon as it comes to the periphery ... an unhurried macrocosm lurked here. This is not juggling electrons. Please wait until the disc in the DVD drive is spinning, until the next byte comes from the I / O port, and the HDD brings its read head to the desired location on the plate. Well, we use DVD and COM ports infrequently (if at all), but the HDD ... We still have the OS on it, and there are many thousands of files in it, and who knows at what point they might be needed. Write the log, then load the dll, then the font, then the registry, then something else. And on some HDDs, many simultaneous calls can lead toHabraeffect a significant drop in speed - I observe this on my WD Green.

    It would seem that here a team of glorious defenders of the universe named File Cache, Prefetch, Superfetch, and their assistant ReadyBoost should help us. Yes, they help, but it often happens that they miss - and then you have to watch the wait cursor.

    But what is it? I hear a noise in the hall, they are chanting - SSD! SSD! What can I say, SSD is definitely cool. 200-300mb / s and even higher, almost instant access, no noise ... well, just miracles. But a lot of topics are written about SSDs, and since overclocking ... maybe there is something faster? Hm. Do we have anything faster than flash in SSD? SSD is more expensive? Raid0 from SSD? And even faster? RevoDrive? ABOUT! DDR3! (Who shouted “L1 cache” there? Comedian!)

    We know about RAM disks, sometimes we use them as temporary storage so that it works faster. So if you take yes and move the entire system to RAM? It should work much faster than any SSD, and even more so faster than the HDD, right? Or should the file cache give us a similar effect? Perhaps the difference will not be noticeable. Well, why not give it a try? In my computer 16 GB of RAM, enough for everything and still remains. It would be nice to use the rest. Go!

    0) Checklist:
    - 16 GB of RAM, or more. Although you can try on 8. But 4 is enough unless for XP.
    - Grub4Dos
    - Wincontig
    - BootIce
    - Partition Wizard or something similar for cloning partitions,
    - driverFiradisk
    is a Windows x64 distribution (you can also x86, but there will be no more than 3.5GB of free memory). I tested on WinXP (x86), Win7, Win8. Lightweight versions are highly desirable, because RAM memory is not rubber.
    - installed and working Win7 (or Win8)

    1)Attention! if you have several hard disks - in order to avoid problems, do the following on an HDD other than the system one. It’s better not to touch the system one and disable it if possible, and install Win7 for experiments on another disk. I don’t know your configuration, some actions may break your download. It would be nice to pre-stock the recovery LiveCD / USB, or at least the Windows installation disc and at least roughly understand what you are doing and how to get everything back. To be sure, you can first conduct an experiment in a virtual machine.

    First, a little theory. Grub4Dos is a boot manager for organizing multi-boot systems. Among other things, it can create virtual devices and work with them in the same way as with regular disks. A virtual disk can be mounted on a file, or in memory. When mounted in memory, the contents of the source file are copied to the memory and further work is done from there. You can use .ima files (disk images), .iso files (CD / DVD images), and .img files (RAW HDD images) as a source. The Win7-native .vhd files (fixed-size, non-dynamic, and non-differential) are the same .img files, but with a small header and you can also connect them.
    Virtual disks created using Grub4Dos are available in real mode. Windows will only see them if there is a special driver. Such drivers exist - these are Firadisk (works with disks in memory) and WinVBlock (works with images in files). If the OS has the right driver, it will be able to work with disks created in Grub4Dos. Unfortunately, the drivers are not signed and for their work in the x64 system you need to disable driver signature verification. Thus, the course of action: we prepare VHD with Windows installed, where we turn off signature verification, install Firadisk, then load VHD even before loading Windows through Grub4Dos and forth.

    First install Grub4dos on our machine. Run BootIce, select the drive from which to boot, put Grub4dos in the MBR, put the grldr and menu.lst files in the root of any section.

    In menu.lst we write:

    #Это для загрузки вашей предыдущей Win7
    title Windows (previous)
    find --set-root /bootmgr
    chainloader /bootmgr
    

    The find --set-root command searches for the specified file and makes the first section where this file was found current. Therefore, check to see if you have extra bootmgr files on other partitions. If you know that the system disk is hd0, you can write directly - chainloader (hd0,0) / bootmgr
    Next, through the computer-management of disk devices, we create in the root of our working section a VHD file of a fixed size of 10 gigabytes that way (maybe more, enough for installation), format it in NTFS, disconnect the disk and defragment its file using Wincontig.

    Now you need to get a disk image from this VHD with Windows ready for work, drivers for your hardware and support for downloading from VHD. This can be achieved in many ways.

    Method 1, recommended. For Win7 editions Corporate and Ultimate, and for Win8. Installing the system in VHD using standard tools.
    More details
    After loading the installer, press Shift-F10, and execute:
    diskpart
    select vdisk file="D:\win7.vhd"
    attach vdisk
    

    where "D: \ win7.vhd" is the path to the VHD file. Drive letters may differ from your main system, you can see them by running, for example, notepad and opening the file selection dialog in it.
    Continue, VHD will appear in the list of devices to install. After installation, a new entry will appear in your Windows boot menu and will be the default. This is the download in VHD.

    Method 2. For all systems. Installation in a separate partition on the disk. We install Windows there as standard, and at the very end, after all the preparation, we clone the partition in VHD.

    Method 3. For all systems. We install the system in VHD on a virtual machine, do all the preparation, and then boot from this VHD on real hardware. There is a likelihood of problems with hardware drivers when migrating to real hardware. Better to do sysprep before porting.

    Method 4. For WinXP. We use the WinVBlock driver .
    More details
    In menu.lst we add these three entries.
    title Start -  TXT-mode XP Setup vhd
    find --set-root /winxp.vhd
    map --mem /winvblock.ima (fd1)
    map --mem /winvblock.ima (fd0)
    map /winxp.vhd (hd0)
    map --mem /xp.iso (0xff)
    map --hook
    chainloader (0xff)
    title Continue GUI-mode XP Setup vhd
    find --set-root /winxp.vhd
    map --mem /winvblock.ima (fd1)
    map --mem /winvblock.ima (fd0)
    map /winxp.vhd (hd0)
    map --mem /xp.iso (0xff)
    map --hook
    root (hd0,0)
    chainloader /ntldr
    title Boot XP vhd
    find --set-root /winxp.vhd
    map /winxp.vhd (hd0)
    map --hook
    root (hd0,0)
    chainloader /ntldr
    

    What is being done here:
    -winxp.vhd is connected as a hard disk (the VHD file must be defragmented with WinContig, otherwise Grub4Dos will refuse to connect it)
    -winbblock.ima disk image with WinVBlock drivers is connected, it is loaded into memory.
    - the image of the installation CD xp.iso is connected, loaded into memory.
    There are two entries for installation. WinXP installation consists of 2 stages - text and graphic mode. First, select TXT, on the second boot - the GUI. The only difference is where we are loading - from a CD or HDD.
    - you don’t need to press F6 and select a driver, integrate it into the distribution package too, just have it on the disk image.
    -after installation in Grub4Dos, select Boot and boot into the system that is installed in VHD.

    For Win7, and even more so for x64 editions, this just doesn’t work. Need a special, street magic .
    However, I still couldn’t get WinVBlock to work with Win7. Maybe you can do it.

    Method 5. For Win7 any edition. We use VBoot . This is also a driver that allows you to boot into VHD. It is signed and allows you to install x64 systems. Unfortunately, a paid, but a demo version is available, which is enough for installation.
    More details
    We set the time for 2011. (otherwise, get BSOD at boot)
    Put the VBoot, vbootldr and vbooldr.mbr folders in the root of the disk.
    In vboot \ grub \ grub.cfg we look for Windows 7 VHD and Windows 7 Install entries and change to these like this:
    menuentry "Windows 7 VHD" {
      vboot harddisk=(LABEL=D)/win7.vhd
    }
    menuentry "Windows 7 Install" {
      vboot harddisk=(LABEL=SYS)/win7.vhd cdrom=(LABEL=SYS)/win7.iso boot=cdrom
    }
    

    We change the label of the partition on which the win7.vhd and win7.iso files (Win7 distribution kit) lie to SYS (although it doesn’t matter which one, if only it matches). For me, Vboot for some reason does not want to recognize paths of the form (hd0,1). You can still access by UUID, but tags are easier.

    In menu.lst add the entry:
    title VBoot
    find --set-root /vbootldr.mbr
    chainloader /vbootldr.mbr
    

    Reboot In Grub4Dos, go to Vboot, and in it - to Windows 7 Install. After loading the installer, press shift-F10, run notepad, open the file selection dialog and look at which letter the Vboot disk is located on. Let's say this is D :. We return to the command line and write for 64-bit editions -
    D:\vboot\tools\amd64\vbootctl setup
    or for 32-bit
     D:\vboot\tools\x86\vbootctl setup
    This will install the Vboot driver and mount the virtual devices. Then we continue the installation on the VHD that appears in the list of devices, and boot through the Windows 7 VHD record. After the final configuration (see below), delete Vboot with the vbootctl uninstall command and then you can return the time to the current one.


    And now Windows is installed and booted.
    First, check through Bootice to see if the Grub4Dos installer from MBR demolished us. If demolished - again set.
    Secondly, we will check whether there is a Windows boot loader on the system partition - the bootmgr file and the Boot folder (in the case of Win7 / 8). They have hidden and system attributes, enable their display. If not, then the installer saw this bootloader somewhere else and added the option to load it there, or created a hidden 100mb partition and placed everything there. This is not the case, we need a bootloader on the system partition. Therefore, we create it:
    bcdboot c:\windows /s c: 

    And we disable driver signature verification in it:
    bcdedit /store c:\boot\bcd /set {default} testsigning ON
    bcdedit /store c:\boot\bcd /set {default} nointegritychecks ON
    bcdedit /store c:\boot\bcd /set {default} loadoptions DDISABLE_INTEGRITY_CHECKS
    

    In the current bootloader, we also disable:
    bcdedit /set testsigning ON
    bcdedit /set nointegritychecks ON
    bcdedit /set loadoptions DDISABLE_INTEGRITY_CHECKS
    

    Reboot to enable the test mode and install the Firadisk driver: hdwwiz (hdwwiz.cpl in XP), install manually, all devices, install from the disk and select the .inf file.

    4) Now we perform all the usual manipulations: install the remaining drivers, configure the hardware, network, desktop, install DirectX / .NET / vcredist, and the like. Transfer the swap file to another partition, delete the temporary files and compress the system partition using NTFS. After all, it’s still in our memory to load, every megabyte on the account. I got about 4 GB for Win7.

    Now we squeeze VHD to an acceptable size (I added a couple of GB just in case, it turned out 6). By the way, how to determine the available size? On the Grub4Dos menu screen, the top line has a line like Mem: / 639K / 13582M / 512M.

    These are the available memory areas where it can load the image. But it can only load the entire image in one area, so the size of the new VHD should not exceed the largest value from this line, otherwise you will get an error.

    We load into the previous Win, mount win7.vhd, create another vhd of a finite size and copy one to another through a section editor like Partition Expert. (If you decide to follow installation method 2, now is the time to clone your system partition into VHD) Replace the old file with a new one, again we defragment through Wincontig. Let's try to boot into the new VHD. No problems should arise.
    Instead of all this, you can use a special program for trimming and compressing the already installed Win7 - VHD_W7_Compact. It is claimed that it can cut up to 600mb.

    5) It's time to boot from RAM! Add a few more lines to menu.lst:
    title Boot Win7 from RAM
    map --mem /win7.vhd (hd0)
    map --hook
    chainloader (hd0)/bootmgr
    

    (for XP we write / ntldr instead of / bootmgr)
    And finally we boot by selecting Boot Win7 from RAM.
    A minute or two VHD is copied to memory, a few seconds of loading and ... the desktop appears. Hooray, the seven works without using the HDD, and it seems to work pretty well.



    You can also add a tricky way to boot Win7 directly from VHD with saving changes:
    title Boot Win7 from VHD (Firadisk)
    find --set-root --ignore-floppies /win7.vhd
    map /win7.vhd (hd0)
    map --heads=2 --sectors-per-track=18 --mem (md)0x800+4 (99)
    map --hook
    write (99) [FiraDisk]\nStartOptions=disk,vmem=find:/win7.vhd,boot;\n\0
    rootnoverify (hd0,0)
    chainloader /bootmgr
    

    For this to work, in the .inf file of Firadisk, replace “LoadOrderGroup = Boot Bus Extender” with “LoadOrderGroup = SCSI miniport”.
    Here we force Firadisk to work with the image not in memory, but on disk. It slows down noticeably, so it’s better to use installation method 1 with the native VHD boot.

    Here there is another article about loading Win7 from RAM.

    Well, with Linux you can try like this .

    I have been using this configuration on my home computer since last fall, for more than six months now. I will try to organize subjective impressions:
    Pros:
    + Indeed, it works quickly. Programs from memory are launched instantly (which is obvious). There are no complaints about the stability of the work - the computer works for weeks and months.
    + No extra sounds from the HDD.
    + The concepts of "wear", "the number of read / write cycles" are not essential for RAM.
    + Side plus - the result is an unchangeable, indestructible system. You can once put all sorts of crooked programs (for example, to restore USB flash - they usually install their drivers, which are then difficult to pick out) without risking ruining anything. Reboot and like nothing happened.
    + Side plus - VHD is cool. No more disk partitions, just files that are simply copied / moved / deleted / backed up without any acronyms / paragons / gparted-s.

    Cons:
    - Honestly, the difference with a good SSD in speed is not noticeable. In both cases, there is nowhere to complain about speed.
    “Of course, precious memory is wasted.” Take out and put 6-8 gigabytes. In my case, I have enough of the remaining 10 gigabytes, and if there is not enough, you can boot into VHD mode.
    - 6-8 GB for Windows 7 - still very little. Some Windows Update updates will quickly eat up the whole place. And you also want to install your favorite programs ... for someone, a 100GB system partition may not be enough (and some advocate not to partition the disks at all). In my case, I placed only the most popular programs on the system partition, and I keep everything else in the form of portable versions on the HDD. Still, this is a home computer; there are no monsters hungry for memory and space on the system drive like SQL Server, Visual Studio, Adobe CS, MS Office (the portable LibreOffice is enough). So far so good.
    - temp has to be transferred to another disk. Some installers without asking anyone are unpacked there and there may not be enough free space.
    - I have to disable driver signature verification. There is nothing to be done.
    - Indestructibility has another side. For each change in the settings, for each update, for each installation of the program / driver for constant use, you must reboot into VHD mode - otherwise everything will be lost upon reboot. If some of your programs store something of their own in the profile (for example, games keep the save there) - then it is advisable to transfer the profile to another section.
    - Downloading 6-8GB to memory takes a lot of time - you can’t boast a 10 second download.
    - For obvious reasons, it is impossible to use hibernation. But the system goes into normal sleep and wakes up normally.

    But again I hear screams in the hall. “And what they just won’t come up with if they don’t buy SSD!”, “Yes, this is nonsense, to throw out so much memory for no reason!”, “Do you need to put some left-hand crooked firewood?”, “No need!”. I agree. I will not recommend such an approach. This is more of a fun experiment than a working solution. Thank you for your attention, now you can post pictures with bread trolleybuses.

    PS Many thanks to the developers of Firadisk and WinVBlock - karyonix and Shao Miller, as well as to the reboot.pro forum .

    Also popular now: