HOWTO use Ubuntu live-cd on ntfs hd subdir with grub4dos

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

HOWTO use Ubuntu live-cd on ntfs hd subdir with grub4dos

#1 Post by mcewanw »

This howto documents how I installed lubuntu live-cd to the third partition of my ntfs formatted harddrive (hd0,2, which is /dev/sda3) using grub4dos and a casper-rw file for persistent also stored on the ntfs formatted harddrive /dev/sda3. Note that this howto is for the case of using a casper-rw file for persistence (i.e. frugal install) rather than a separate casper-rw partition. It is intended as an exemplar on how to boot live-cd iso's in that frugal-like manner using grub4dos more generally.

All linux configuration was done using Puppy Guydog 501, which is the main distribution I run on this machine. For completeness, the grub4dos menu.lst details below include the stanza to boot my frugal Puppy Guydog, which you do not of course require to boot Lubuntu.


BACKGROUND

It is reasonably well-known and documented how to use grub4dos to boot a live-cd iso (plus file or partition for persistence) when the various required parts are stored on usb and on ext or fat-type partitions. For example:

http://www.rmprepusb.com/tutorials/72-- ... o-maintain.
http://murga-linux.com/puppy/viewtopic. ... 458#682458.
http://www.murga-linux.com/puppy/viewto ... =122987820.

This howto documents some extra steps when storing the required parts on hd and particularly for the more tricky case of an ntfs formatted hard drive partition. Note that the described details only require a working install of grub4dos and do not require the use of Easy2Boot or similar.

Most of the configuration details were found at http://www.rmprepusb.com/tutorials/ubuntu. I did not, however, download or use the program RMprepUSB at all, but did download and use "wincontig" from http://wincontig.mdtzone.it/en/, which allowed me to make sure the lubuntu live-cd iso, and the casper-rw persistence file I created, were stored contiguously (i.e. defragmented) on the underlying ntfs filesystem. Furthermore, this howto documents a few subtle extra details I found by trial and error regarding the creation of casper-rw, specifically required when stored on ntfs, which I did not find documented elsewhere, and the possibility of locating the casper-rw file in a subdirectory of the partition.


COMPUTER CONFIGURATION USED FOR THE INSTALLATION

The machine I'm doing this installation on is an emachines (Acer) netbook, which comes preinstalled with Win 7 Starter OS on ntfs formatted partition /dev/sda3, which it boots using bcd via preinstalled ntfs partition /dev/sda2. In addition, it uses ntfs partition /dev/sda1 to hold images required to rebuild the OS to factory default should that ever be required. There is thus only one unused partition entry in the MBR; that for /dev/sda4 (hd0,3), which is the one I use, via grub4dos partnew, in the menu.lst below to point to where the lubuntu casper-rw persistence file is being stored.

Note that I earlier installed grub4dos (grldr and grldr.mbr) at root of partition /dev/sda3 using bcdedit in the method nicely described on ICPUG's Lin'N'Win site (albeit not particularly for /dev/sda3 installation): http://www.icpug.org.uk/national/linnwin/step2-7.htm.

Steps Required (assuming installation to /dev/sda3 and grub4dos already successfullly installed and basically working on your machine):

1. Make directory /frugal-lubuntu on partition sda3 (which in my Guydog frugal installation was my /mnt/home).

2. Download the lubuntu live-cd iso (I used lubuntu-13.10-desktop-i386.iso) from lubuntu.net and store it in /frugal-lubuntu.
(At this stage I opened up the iso by clicking on it in the filemanager, extracted vmlinuz and initrd.lz and copied them into /frugal-lubuntu. However, that extra step is only required if booting lubuntu using Method1 in menu.lst below. It is not required for Method2).

3. Open a terminal at directory /frugal-lubuntu and create a 1 GiB ext2 formatted casper-rw file inside that directory by entering the commands:

Code: Select all

dd if=/dev/zero of=casper-rw bs=1M count=1024

followed by

mkfs.ext2 -b 4096 -F -L casper-rw casper-rw
NOTE WELL: The above mkfs.ext2 command line does not contain a typo. The casper-rw name is typed twice as shown. I discovered that whilst a casper-rw file created simply using "mkfs.ext2 -F casper-rw" was detected and worked perfectly well when stored on an ext2 or fat partition on a usb stick, it was not detected when stored on the hd ntfs partition! By trial and error I found that I needed to create a volume label for the casper-rw using the extra "-L casper-rw" above; that was one of the secrets to getting the file recognised for lubuntu persistence when stored on the ntfs partition.

4. Assuming you have downloaded wincontig and extracted it on an underlying MSWindows OS partition, reboot into that OS now, run wincontig from wherever you have placed it, and defragment both lubuntu-13.10-desktop-i386.iso and your newly created casper-rw file. Then reboot back to Guydog or whatever linux distribution you are using to configure this lubuntu installation.

5. Create the following grub4dos menu.lst (or extract the bits you need...). My grub4dos menu.lst is stored in root of /dev/sda3 along with grldr and grldr.img. You will need to modify this to match the partition you are using on your own machine for this lubuntu live-cd-iso installation. I am using hd0,2 (i.e. /dev/sda3) here. WARNING: Be careful with the grub4dos partnew command line entry. Make sure (carefully check) that on your system you use it to refer to a partition entry that is definitely not being used because partnew does write the new partition information so would overwrite anything already there! (personally, for my own safety, I make a backup, using dd, of my mbr/partition table before starting, though I don't document how to do that here). Use any of this at your own risk :) :

Code: Select all

###############################################
	color black/cyan yellow/cyan
	timeout=5
	default=0

title Puppy GuyDog
	kernel (hd0,2)/guydog/vmlinuz PMEDIA=idehd PDEV1=sda3 psubdir=guydog pfix=copy
	initrd (hd0,2)/guydog/initrd.gz

# Method1 requires you to extract vmlinuz and initrd.lz from the lubuntu live-cd iso and put them in subdir /frugal-lubuntu on hd0,2 (/dev/sda3)
title Frugal Lubuntu with persistence Method1
  partnew (hd0,3) 0x0 (hd0,2)/frugal-lubuntu/casper-rw
  kernel (hd0,2)/frugal-lubuntu/vmlinuz boot=casper persistent iso-scan/filename=/frugal-lubuntu/lubuntu-13.10-desktop-i386.iso splash --
  initrd (hd0,2)/frugal-lubuntu/initrd.lz

# Method2 does not require extraction of vmlinuz and initrd.lz from the iso
title Frugal Lubuntu with persistence Method2
  partnew (hd0,3) 0x0 (hd0,2)/frugal-lubuntu/lubuntu-rw
  find --set-root /frugal-lubuntu/lubuntu-13.10-desktop-i386.iso
  map /frugal-lubuntu/lubuntu-13.10-desktop-i386.iso (0xff) || map --mem /frugal-lubuntu/lubuntu-13.10-desktop-i386.iso (0xff)
  map --hook
  root (0xff)
  kernel /casper/vmlinuz  file=/cdrom/preseed/lubuntu.seed noprompt boot=casper persistent iso-scan/filename=/frugal-lubuntu/lubuntu-13.10-desktop-i386.iso quiet splash --
  initrd /casper/initrd.lz

# The following is just for my own machine, which I'm just including here as a record for my own use.
title Default Win 7 Boot code on HD 0,1 (/dev/sda2) which on the emachines (Acer) netbook I am using boots the win 7 installation on /dev/sda3
	rootnoverify (hd0,1)
	chainloader +1
	boot
	
######################################################
Final Notes:

a. With the above method, you can later rename the casper-rw to, for example, lubuntu-rw, but you must still create it as shown in step 3 above to use the internal volume label (-L) casper-rw. The advantage of using an alternative file name to casper-rw is that you can then use different persistence file names should you be multi-booting from a number of possible live-cd-isos. Putting the persistence file in separate subdirectories, as above, also usefully separates any alternative casper-rw files, without necessarily needing to name them differently. If you do rename casper-rw to lubuntu-rw, the menu.lst Method2 (for example) entry must also be changed to:

Code: Select all

# Method2 does not require extraction of vmlinuz and initrd.lz from the iso
title Frugal Lubuntu with persistence Method2
  ### the following line changed to refer to lubuntu-rw rather than casper-rw
  partnew (hd0,3) 0x0 (hd0,2)/frugal-lubuntu/lubuntu-rw
  find --set-root /frugal-lubuntu/lubuntu-13.10-desktop-i386.iso
  map /frugal-lubuntu/lubuntu-13.10-desktop-i386.iso (0xff) || map --mem /frugal-lubuntu/lubuntu-13.10-desktop-i386.iso (0xff)
  map --hook
  root (0xff)
  kernel /casper/vmlinuz  file=/cdrom/preseed/lubuntu.seed noprompt boot=casper persistent iso-scan/filename=/frugal-lubuntu/lubuntu-13.10-desktop-i386.iso quiet splash --
  initrd /casper/initrd.lz
b. I mentioned above at step 5 (menu.lst creation) that you need to be careful with the grub4dos partnew command because it writes to the partition table so you need to carefully check the entry is previously unused/empty prior to using partnew. Once all has been tested as working (lubuntu working and with persistence), you can in fact remove the partnew command lines from your menu.lst since the partition tables will after that already have been updated to point to where your casper-rw (or lubuntu-rw) file is located and you are then less likely to accidentally later overwrite anything in your mbr partition table should you be editing your menu.lst file for some reason.

c. Had I had a second unused partition table entry, such as that for hd0,1 (which I didn't since that /dev/sda2 ntfs partition was also occupied) I could have used a second instance of partnew to avoid the need in Method2 above for the menu.lst line:

Code: Select all

find --set-root /frugal-lubuntu/lubuntu-13.10-desktop-i386.iso
In particular I could have used the following line instead:

Code: Select all

partnew (hd0,1) 0x0 (hd0,2)/frugal-lubuntu/lubuntu-13.10-desktop-i386.iso
d. In practice, I am using Method2 of menu.lst above. That does however, require the live-cd-iso to be stored contiguously (i.e. defragmented using, for example, wincontig). Method1 seemed to boot successfully even when live-cd-iso was fragmented (I didn't however check the effect of using a casper-rw that wasn't defragmented).

e. Assuming lubuntu-13.10-desktop-i386.iso has been defragmented (stored contiguously in the ntfs partition):

Code: Select all

map /frugal-lubuntu/lubuntu-13.10-desktop-i386.iso (0xff) || map --mem /frugal-lubuntu/lubuntu-13.10-desktop-i386.iso (0xff)
could be simply replaced with:

Code: Select all

map /frugal-lubuntu/lubuntu-13.10-desktop-i386.iso (0xff)
The map --mem part causes the whole iso to be copied into RAM contiguously should the underlying iso itself be non-contiguous. That wastes a lot of RAM in practice. However, I just leave it in as a safeguard since it is never used anyway if lubuntu-13.10-desktop-i386.iso has been defragmented, whereupon the map before the || (or) applies instead.
Last edited by mcewanw on Tue 26 Jul 2016, 00:50, edited 1 time in total.
github mcewanw

rmprep
Posts: 17
Joined: Sun 06 Jan 2013, 15:08

#2 Post by rmprep »

Nice write-up :-)
P.S. partnew requires the file to be contiguous (both .iso and ext2 file).
Visit [url]http://www.rmprepusb.com[/url] for over 100 USB boot tutorials!

Post Reply