grub> displaymem .... Usable RAM: Base: 0x100000000, Length: 0x130000000The length of Usable RAM range at address 4G is 0x130000000 = 5100273664 or 4864M (or 4096M+768M).
I want to create RAM drive that ALMOST FILL UP this range.
The current GRUB4DOS map --mem will allocate RAM with 4KB granularity.
The maximum size that will not fill up the entire range is (4864M - 4K).
I will create image file in fixed size VHD format for ease of use.
Fixed size VHD have 512byte footer. The footer will be included in GRUB4DOS mapped drive.
Maximum size for disk area inside VHD is (4864M - 4K - 512).
If one partition is create at sector LBA 1, maximum partition size is (4864M - 5K).
I chose simple numbers that will be easy to remember/calculate for disk size and partition size.
Virtual disk size will be 4863M=9959424 sectors
with one active partition at offset 1M=2048 sectors and size 4862M=9957376 sectors.
Including footer, VHD file size will be (4863M+512).
When loaded by map --mem it will use (4863M+4K) bytes, leaving 1020K unused RAM above address 4G.
Windows 7 RC 32-bit Setup require 8???M free space in Windows partition, so I needed larger virtual disk.
I used diskpart in Windows 7 to create 9000MB fixed-size VHD and create active primary partition.
C:\>diskpart DISKPART> create vdisk file="c:\data\vw7.vhd" maximum=9000 DISKPART> attach vdisk DISKPART> convert mbr DISKPART> create partition primary DISKPART> format fs=ntfs unit=4096 quick label="vw7" DISKPART> active DISKPART> detach vdiskI examined its partition table. The partition size was 8998M.
I will have to shrink it 4136M after setup to get the desired size 4862M.
I added vw7.vhd to VirtualBox and attach it to a virtual machine.
DVD drive of virtual machine is set to Windows 7 RC 32-bit Setup ISO.
I chose Custom (advanced) installation type and select Disk 0 Partition 1: vw7.
After setup reboot, I made it boot from DVD again and pressed Shift+F10 to bring up cmd.exe.
dir c:\It has 3986141184 bytes free.
The used space is approximately 5197M. I have to decrease the used space by approximately 350M to get below 4862M.
c:\windows\system32\compact.exe /? c:\windows\system32\compact.exe /c /s:c:\windows\winsxs /a /i4,139,460,144 total bytes of data are stored in 2,887,118,792 bytes.
dir c:\5,174,657,024 bytes free
It looks good.
I rebooted virtual machine, booted from hard disk, continue setup.
After Windows desktop appeared, I checked c:\ and found large 1GB page file. It is too larged.
I openned Advanced system settings, decrease paging file size for C: to 200MB and restarted.
After restart I ran diskpart.
DISKPART> selct disk 0 DISKPART> select partition 1 DISKPART> shrink querymax The maximum number of reclaimable bytes is: 3886 MBNot good.
I changed paging file size to 20MB and tried again, reclaimable bytes was 3866 MB. Not good.
I restarted again and boot from Windows Setup DVD.
Pressed Shift+F10 to open cmd.exe.
dir /a c:\ del /a c:\pagefile.sys diskpart DISKPART> select disk 0 DISKPART> select partition 1 DISKPART> detail partition DISKPART> shrink querymax The maximum number of reclaimable bytes is: 5017 MBGood, it is possible to shrink 4136 MB.
DISKPART> shrink desired=4136 DISKPART> detail partitionThe size is 4862 MB as expected.
I restarted virtual machine, boot from hard disk. Windows seemed to work normally. No problem found.
I shutdown virtual machine, opened vw7.vhd in hex editor, verified that partition 1 is at LBA 0x00000800 (1MB) Length 0x0079F000 sectors (4862MB).
Partition 1 end position is at 7993344 sectors = 4863MB = 5099225088 bytes.
I copied 4863MB to a new file vw7s.vhd by using dd for Windows.
And used raw2vhd to append VHD footer to it.
C:\data>c:\util\dd bs=1M count=4863 if=vw7.vhd of=vw7s.vhd C:\data>c:\util\raw2vhd vw7s.vhd
I detached vw7.vhd from virtual machine and attached vw7s.vhd.
I started VM. Windows seems to be OK.
I created another VHD mini1.vhd 128MB. I copied grldr, grldr.mbr into it, installed GRUB4DOS MBR, and copied firadisk 0.0.1.18 + my test-signing certificate in a folder.
I created another VHD mini2.vhd 16MB, created partition, and copied it inside mini1.vhd.
I attached mini1.vhd to VM. (primary master=vw7s.vhd, primary slave=mini1.vhd)
I booted into Windows, install my test-siging certificate, install firadisk and shutdown.
This is x86 version, so I don't have to enable Test Mode.
I changed order of virtual disk. (primary master=mini1.vhd, primary slave=vw7s.vhd)
I started VM. At GRUB4DOS commandline I created a small RAM drive and booted Windows.
map (hd1) (hd0) map (hd0) (hd1) map --mem /mini2.vhd (hd2) map --hook chainloader /bootmgr bootWindows installed drivers for new hardware: FiraDisk and RAM disk.
It seemed to be ready. I shutdown VM.
I installed GRUB4DOS 0.4.5a 2010-01-23 to external hard disk.
I started real machine (with 8GB RAM), told BIOS to boot from external hard disk.
In GRUB4DOS, I loaded vw7s.vhd and booted into Windows.
map --mem (hd1,0)/data/vw7s.vhd (hd0) map --hook chainloader /bootmgr boot
It can boot to desktop on my PC.
Mouse stopped working temporarily a few times while Windows were installing drivers for new hardware.