Sunday, December 21, 2014

Setting NTFS volume serial number

Source: some site on the net.

Using dd to set or get serial number of a NTFS volume:

assuming taget volume is "sda1" and serial number is stored at file named "serial"

set serial: dd if=serial of=/dev/sda1 bs=1 count=8 seek=72
get serial: dd if=/dev/sda1 bs=1 count=8 skip=72 | hexdump -C

There were a warning also which mentioned
(1st) this method doesn't update the NTFS backup boot sector (which should be last sector of the volume)
(2nd) this may affect the parent/child relationships of the objects in the NTFS volume, so it may not be safe to use on volumes that contain data (not newly formatted).

Speaking of backup partition boot sectors (PBR) unlike NTFS, FAT32 backup PBR is located at 6th sector.

windows 95 on dosbox

A guide to installing windows 95 on dosbox is at: http://www.vogons.org/viewtopic.php?t=24936. After installing two problems (mentioned below) arise. Although the solution is in the guide above it doesn't mention setting these options are mandatory for win 95 to work.

1st Problem: After installing win 95 on boot screen goes blank

  Cause: core is set to auto and dynamic-core (of dosbox) is causing win 95 to fail booting

  Solution: core=normal must be set in dosbox configuration file.
  
2nd Problem: After successfully installing win 95 on dosbox curser looks like large square black area and screen image is distorted

  Cause: cputype is set to auto

  Solution: cputype=pentium_slow must be set in dosbox configuration file.


Since machine type is already set to svga_s3 by default no need to change it. But the options above must be set for win 95 to work on dosbox.



Wednesday, December 10, 2014

How to boot win 7/8 from gpt disk in bios mode (no UEFI, no Hybrid MBR)

 Problem: Boot Win 7/8 from a gpt disk (sorry still requires an mbr style disk to be present)

Windows 7 or 8 can't boot from a gpt disk unless booted from UEFI firmware

Solution:
1- Use UEFI DUET: sufficient explanation and how to is available at http://www.rodsbooks.com/bios2uefi/

Disadvantages: Complicated set up, May not work on AMD cpus

2-Use Hybrid MBR: could be found at http://www.rodsbooks.com/gdisk/booting.html

Disadvantages: Hybrid MBR non-aware partition programs wont work. And each time gpt partitions are modified a specific tool is needed to update the hybrid MBR.

3- Boot from a MBR partitioned second Hard Disk or USB disk: http://www.sevenforums.com/installation-setup/320700-boot-windows-7-8-gpt-bios-system-no-hybrid-mbrs-duet.html

Disadvantages: Requires a second hard drive or USB disk to present at boot.

4- My proposed solution: Rather than using a MBR partitioned second physical disk use a MBR partitioned virtual disk:

Prerequisites:
1- Download GRUB4DOS
2- Linux OS

Steps:

1- Use windows "diskpart" or "disk manager" (gui) to build a virtual disk (winboot.vhd) 20 to 32 MB in size

2- Make partition on virtual disk and assign it active partiton using diskpart

3- Format the partition to FAT16 using either diskpart or windows gui

4- Mount and assign a drive letter to new partition using either diskpart or windows disk manager

5- Now copy boot files using "bcdboot c:\windows /s X: /f BIOS" (X is the newly mounted partitions drive letter)

6- Boot your linux OS and Launch a terminal app enter the directory where you extracted grub4dos. Superuser rights are needed for the following commands, use either ""sudo" or "su"

7- Assuming your disk is /dev/sda and your EFI system partition (FAT32) is /dev/sda1in linux. Mount your efi system partition "mount /dev/sda1 /boot/efi" (you may need to "mkdir /boot/efi" first) and copy grldr from grub4 dos to mounted partition "cp ./grldr /boot/efi"

6-  Now install grub4dos partition boot sector "./bootlace.com --floppy=0 --fat32 /dev/sda1".

7- Build a "menu.lst" file with the following content using your favorite text editor (nano, gedit, vim, ..)

----------------------------------------
title Windows 7/8
root (hd0,1)
map /winboot.vhd (hd2)
map --hook
root (hd2,0)
chainloader /bootmgr
---------------------------------------

Note: second line "root(hd0,1)" is assuming your windows partiton which winboot.vhd is second partition on your gpt disk fallowing EFI system partition if not change it accordingly.

8- Reboot and see if it works (worked for me)

How to build a grub2 core.img that can boot from a gpt partition

Problem: Current core.img in /boot/grub/i386-pc/ can't boot from gpt partition, trying to results in "grub rescue>" prompt

Solution: Build a grub2 core.img that can boot from gpt partition.

Prerequisites:

1- Find and download grub-pc binary for your distribution,  for ubuntu (14.04) it is "grub-pc-bin_2.02~beta2-9_amd64.deb".
2- Extract i386-pc folder from downloaded archive (I extracted the folder to Desktop)

3- Now build the core img:

 grub-mkimage -d ~/Desktop/i386-pc -o core.img --format i386-pc biosdisk part_gpt ext2

4- put generated core.img to /boot/grub/i386-pc

5- Chainload core img from grub4dos (eg.: kernel (hd0,1)/boot/grub/i386-pc/core.img)

To build a fat core.img which isn't necessary (once grub2 reads the partition /boot/grub/ is on rest of the modules could be loaded from there):

"grub-mkimage -d ~/Desktop/i386-pc -o core.img --format i386-pc biosdisk iso9660 multiboot normal ls cat help part_msdos part_gpt ext2 fat fshelp configfile"

configfile module provides source command which can load another grub.cfg from disk part_gpt, ls, cat, help is pretty self explanatory (I think), rest of the modules could be omitted (again, I think)