Articles

[HOWTO] Boot from a hard disk image file

Howto install porteus or other live cd/usb to NTFS or linux partition with original bootmenu.

NOTE: This article was written for an older version of Porteus, so some of the information (e.g., cheatcodes) are now out of date; this information is left here for reference purposes, if you have any troubles implementing this, please inquire on the Porteus forums.

Tested in slax-remix-v08 and porteus-v01-alpha.

If you are working in porteus-v01-alpha, please restart your system with 'max_loop=50' cheatcode before installation.

First step: create a directory called xlive in your favorite partition - in my case, this is NTFS /mnt/sda1/xlive.
Create a directory called porteus-v01-alpha in xlive - e.g. '/mnt/sda1/xlive/porteus-v01-alpha'.

Download the porteus.iso and extract it using the mount tool.

In console:

mkdir /mnt/tmp

mount -o loop /patchtoisofile/porteus.iso /mnt/tmp

 


Go to /mnt/tmp directory and copy the porteus directory to /mnt/sda1/xlive/porteus-v01-alpha.
Copy the boot directory to /root

In console:

umount /mnt/tmp

 


Download hard disk image (with syslinux 3.85) http://www.mediafire.com/file/oilhql3sgf7z42u/hd5M.img.tar.gz copy to /root directory and unpack:
tar -xvzf hd5M.img.tar.gz

Rename the file hd5M.img to porteus-alpha.img

In console:

cd /root

mkdir tmp
mount -o loop,offset=32256 porteus-alpha.img tmp

 


Go to the /root directory and copy the boot directory to tmp, then go to /root/tmp/boot and edit the porteus.cfg file to add the cheatcode parameters:
from_dev=/dev/sda1 from_dir=/xlive/porteus-v01-alpha.  For example, this is my porteus.cfg

LABEL xconf

MENU LABEL Graphics mode (KDE).
KERNEL /boot/vmlinuz
APPEND initrd=/boot/initrd.xz vga=791 autoexec=xconf;telinit~4 nomodeset from_dev=/dev/sda1 from_dir=/xlive/porteus-v01-alpha max_loop=50
TEXT HELP
Run Porteus the best way we can.
Try to autoconfigure graphics
card and use the maximum
allowed resolution
ENDTEXT
 
LABEL lxde
MENU LABEL Graphics mode (LXDE).
KERNEL /boot/vmlinuz
APPEND initrd=/boot/initrd.xz vga=791 autoexec=lxde;xconf;telinit~4 nomodeset from_dev=/dev/sda1 from_dir=/xlive/porteus-v01-alpha max_loop=50
TEXT HELP
Run Porteus the same as above.
Lightweight LXDE to be
launched as default desktop
ENDTEXT
 
LABEL fresh
MENU LABEL Always Fresh
KERNEL /boot/vmlinuz
APPEND initrd=/boot/initrd.xz autoexec=xconf;telinit~4 nomodeset from_dev=/dev/sda1 from_dir=/xlive/porteus-v01-alpha max_loop=50
TEXT HELP
Normally Porteus saves all changes
to the
on the boot media (if writable)
and restores them next boot.
Use this option to start a fresh
system, no changes are neither
read nor written anywhere
ENDTEXT
 
LABEL cp2ram
MENU LABEL Copy To RAM
KERNEL /boot/vmlinuz
APPEND initrd=/boot/initrd.xz vga=791 copy2ram autoexec=xconf;telinit~4 nomodeset from_dev=/dev/sda1 from_dir=/xlive/porteus-v01-alpha max_loop=50
TEXT HELP
Run Porteus the same as above,
but first copy all data to RAM
to get huge speed (needs >300MB)
ENDTEXT
 
LABEL startx
MENU LABEL Graphics VESA mode
KERNEL /boot/vmlinuz
APPEND initrd=/boot/initrd.xz autoexec=telinit~4 nomodeset from_dev=/dev/sda1 from_dir=/xlive/porteus-v01-alpha max_loop=50
TEXT HELP
Run Porteus with KDE, but skip
gfx-card config. Force 1024x768
using standard VESA driver
ENDTEXT
 
LABEL text
MENU LABEL Text mode
KERNEL /boot/vmlinuz
APPEND initrd=/boot/initrd.xz nomodeset from_dev=/dev/sda1 from_dir=/xlive/porteus-v01-alpha max_loop=50
TEXT HELP
Run Porteus in textmode and start
command prompt only
ENDTEXT

 


Save your porteus.cfg and in your console run:

umount tmp

 

 Now your porteus-alpha.img is ready to boot, first create boot directory in /mnt/sda1/xlive copy this image to /mnt/sda/xlive/boot


How to boot this image? With grub or Grub4Dos. If you are using grub, find your menu.lst and add:

title Porteus-v01-alpha from NTFS partition

fallback 1
map --mem (hd0,0)/xlive/boot/porteus-alpha.img (hd0)
map --hook
chainloader (hd0)+1
rootnoverify (hd0)
map --harddrives=1
boot

 


If you use only windows XP/vista/2008/7 you can download Grub4Dos here: http://sourceforge.net/projects/grub4dos/
Extract it and then copy the following to your C:\ directory:
grldr
menu.lst

Then edit your menu.lst.  Here is mine:

# This is a sample menu.lst file. You should make some changes to it.

# The old install method of booting via the stage-files has been removed.
# Please install GRLDR boot strap code to MBR with the bootlace.com
# utility under DOS/Win9x or Linux.
 
color blue/green yellow/red white/magenta white/magenta
timeout 30
default /default
 
title Porteus-v01-alpha from NTFS partition
fallback 1
map --mem (hd0,0)/xlive/boot/porteus-alpha.img (hd0)
map --hook
chainloader (hd0)+1
rootnoverify (hd0)
map --harddrives=1
boot
 
title slax-remix-v08 from NTFS partition
fallback 1
map --mem (hd0,0)/xlive/boot/remix-v08.img (hd0)
map --hook
chainloader (hd0)+1
rootnoverify (hd0)
map --harddrives=1
boot
 
title find and load NTLDR of Windows NT/2K/XP
fallback 2
find --set-root --ignore-floppies /ntldr
chainloader /ntldr
savedefault --wait=2
 
title find and load BOOTMGR of Windows VISTA
fallback 3
find --set-root --ignore-floppies /bootmgr
chainloader /bootmgr
savedefault --wait=2
 
title find and load CMLDR, the Recovery Console of Windows NT/2K/XP
fallback 4
find --set-root --ignore-floppies /cmldr
chainloader /cmldr
#####################################################################
# write string "cmdcons" to memory 0000:7C03 in 2 steps:
#####################################################################
# step 1. Write 4 chars "cmdc" at 0000:7C03
write 0x7C03 0x63646D63
# step 2. Write 3 chars "ons" and an ending null at 0000:7C07
write 0x7C07 0x00736E6F
savedefault --wait=2
 
title back to dos
quit
 
title reboot
reboot
 
title halt
halt

 

Last operation if you use windows XP you must edit boot.ini file.  Here is mine:

[boot loader]

timeout=5
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Home Edition" /noexecute=optin /fastdetect
c:\grldr="Start Grub4Dos"

For windows vista/2008/7 look at this excelent solution: http://diddy.boot-land.net/grub4dos/files/install_windows.htm

Porteus is now ready to boot from NTFS partition with the original bootmenu.  If you want to edit porteus.cfg please use mount tool.

If you want to add another livecd distro you must create another directory in xlive eg. slax-remix-v08 and copy to this directory only the slax folder with all subfolders, and then create slax-remix-v08.img image file for boot.  My menu.lst example above shows an entry for slax-remix-v08.

How to create a hard disk image file?

dd if=/dev/zero of=hd.img bs=1024k count=5

Creates a 5 MB hd.img file for adding syslinux.  I use qemu and win98.img floppy image.