The grub4dos code shown below allows you to make partitions invisible to Windows (and linux probably too?).
The normal built-in grub4dos command 'hide' will set bit 4 of the partition type in the partition table of the Master Boot Record (MBR) or the Extended MBRs used for logical partition table entries - e.g. for a FAT32 Type 0C hex partition: hide (hd0,1) Partition type is now 1C hex (hidden FAT32)
However, in many cases the partition and the files inside it will still be accessible to Windows (for instance, if the volume was previously assigned a drive letter by Windows). This is because the partition is still present and still valid. Linux may also be able to access the partition and the files within it, if hidden in this way.
We can however hide the files in the partition from any operating system, by also making the PBR invalid (it would appear to the OS to be unformatted). In this way the file contents cannot be seen by any OS but still works fine with grub4dos which can access all files as normal.
The following grub4dos batch file is for a True Hide, it changes the PBR data to make the format 'semi-invalid' and thus invisible to Windows.
Note: this is the new revised version which hides FAT16/FAT32 and NTFS/exFAT partitions from Windows but leaves them still accessible to grub4dos. The lines in green can be omitted if you don't want the information displayed.
if not "%PTN:~0,1%"=="(" echo -e \n %0 %1 - BAD ARGUMENT! && pause --wait=3 && goto :eof
These menus assume you have set the grub variable to your path where the .g4b files are located - e.g. set grub=grub/utils
iftitle [parttype (hd0,1) &; set /A [email protected]% &; if not %p%==0x0F && calc %p%&0x10^0x10] TRUE HIDE HD0,1\n Hide 2nd partition on first hard disk
call /%grub%/true_hide.g4b (hd0,1)
# Reload main menu
iftitle [parttype (hd0,1) &; set /A [email protected]% &; if not %p%==0x0F && calc %p%&0x10] TRUE UNHIDE HD0,1\n Unhide 2nd partition on first hard disk
call /%grub%/true_unhide.g4b (hd0,1)
# Reload main menu
Note that the menu entry will only be listed if the partition exists and is in the correct hidden/unhidden state, so only one of the above menu items will be displayed at any one time (or neither of them, if there is no partition present or it is the Extended Partition 0F entry).
Note: A modernish (2014+) version of grub4dos is required for this menu as it uses the newish &; operator, calc and iftitle!
For this menu which uses 'iftitle', It is necessary to reload the menu after the partition has been altered so that the 'wrong' menu entry will no longer be listed in the menu. e.g. if you actually run the 'True Hide' menu entry, when the menu is reloaded the 'True Unhide' menu entry will be present, instead of the 'True Hide' menu entry.
To suppress the display text that is output by the call, redirect the call to nul like this:
call /%grub%/true_hide.g4b (hd0,1) > nul
I have added a True_Hide_Unhide.mnu sample menu file to Easy2Boot and the two grub4dos batch files true_hide.g4b and true_unhide.g4b are now included in E2B too.
Add a Password
You could add a password prompt too so that the partition can only be unhidden if you know the correct password is fred, e.g.
iftitle [parttype (hd0,1) &; set /A [email protected]% &; if not %p%==0x0F && calc %p%&0x10] TRUE UNHIDE HD0,1\n Unhide 2nd partition on first hard disk password fred || configfile /menu.lst echo call /%grub%/true_unhide.g4b (hd0,1) pause # Reload main menu configfile /menu.lst