On Booting ISO's

by Kholddagger | 10:34 PM in | comments (0)

I'd like to take an article by a fellow blogger, here, to explain the problems with booting ISO's, even with the loopback feature of GRUB2. In recent news, I have managed to put GRUB2 on a flash drive from a 64-bit installation of Arch Linux. Tutorial coming soon...?

In #grub one of the most asked questions is if GRUB can boot iso9660 images. Or better: how GRUB should do this, people don’t even think about if it would be possible or not. Of course this annoys many people and “GRUB can not boot CDROM images” is nowadays the most important line in the topic.

Actually, GRUB can read ISO9660(”iso”) images. It can for example loads the first few sectors and boot it. But most people do not realize is “what then?”. What would the loaded operating system do? It will most likely look for a CDROM, which it won’t find and fail.

A while ago I wrote a “loopback” command for GRUB 2. It makes it possible to load files from filesystem images. Think for example of a kernel and an initrd. But even this is not enough. The loaded kernel is not able to access the ISO9660 image just like that. The operating system needs support to deal with this. Somehow you need to pass the path of the ISO9660 image to the kernel and the kernel should loopback mount this image and use it.

So in order to use it I need an operating system that supports this. Sidux is one of those operating systems that do. The advantage of using GRUB 2 is that you do not need to extract the kernel+initrd manually, but can do this at boot time. So all you need is the ISO9660 image.

I managed to boot Sidux using GRUB 2 and the following commands (after renaming the .iso file):

loopback loop (hd0,7)/sidux.iso
linux (loop)/boot/vmlinuz boot=fll quiet vga=791 fromiso=/sidux.iso
initrd (loop)/boot/miniroot.gz
boot

This works perfectly and all you need is GRUB 2 and an the file
sidux-2007-02-200705281503-tartaros-kde-full.iso

I of course tried to do the same with Knoppix. It has a bootfrom option, but according to some forum post I found it doesn’t work when not booting from a CDROM. So I would have to wait until knoppix is fixed before this would work. I also hope Debian, Red Hat, etc will eventually make this possible.

What would be even better is that all CDROMs come with a multiboot bootloader as a file on the CDROM. For example /multiboot-IA32 for a PC CDROM (suggested by Robert Millan on #grub). This will make it possible to load some multiboot (multiboot2 perhaps?) kernel from the CDROM or CDROM image. That kernel (which can also be GRUB 2) will load a grub.cfg specific for the CDROM and boot it. To be able to load a ISO9660 image the multiboot-IA32 bootloader will need the path. The advantage of multiboot is that you can pass this path to the bootloader. If all distributions agree on this filename and agree on the argument to pass to the kernel to be “iso=”, it would be easy to boot such CDROMs without any legacy BIOS support, we can use ISO9660 images and perhaps even LinuxBIOS+GRUB2. Your firmware doesn’t even need CDROM support in the long term, GRUB2 just needs it and will get this support in the short term. And this can even be used on other architectures. Please let me know if this sounds like a good idea that will be supported. Perhaps we just need to create a new CDROM boot “standard” out of this :-).


This is from http://mgerards.net/blog/ if you're interested.

Where have I been?

by Kholddagger | 12:27 AM in , , | comments (0)

Well, thank you for asking my imaginary reader. I have actually been in school. Working. Slave labor. To my death. Anyway, I survived, and it's AP week, so of course I have studying and a billion projects to do. Needless to say, I finally found a reason to come back to my blog.

Here's what's changed:

Elive went to crap. I can't get it to work with my graphics card. I have finally given up and deleted the partition. (I then had to recreate my menu.lst by hand... Thank G-d I put GRUB on my flash drive! It really did save me.)

Onto GRUB. GRUB2 that is. Yes, it's time to move onto the new generation of GRUB, along with all the pretty bells and whistles and painfully slow performance. Meh. Half of you out there probably still have Vista on some computer at home, so you have built-in tolerance for losing 99% of performance just so that the thing can look pretty. And look pretty it does. GRUB2 that is. Can you put GRUB2 on your flash drive? Heck, most people can't manage to get it on their computer. If I could write that guide... I'd be a genius. But what do you know? I am an egotistical maniac, so I am working on it.

In the rest of my spare time, I went back to Arch Linux for the 6th time, and finally everything works (except samba, which I'm still fixing). Also, I use a highly customized version of FVWM called FVWM-Crystal. It has a lot of pseudo-transparency and looks really nice. I learned its scripting language by trial and error. It is my first programming experience ever. Yes, thank you very much. Anyway, it looks sick. I'll post some pictures after I finish developing my "recipe," which is how my desktop looks. Between that, GRUB2, and splashy - which generates a splash screen during boot, my computer is very pleasing to the eye - however not so minimalist anymore. I gave up my 15 second boot time for ease of use. Despite the complex look, just about anyone could learn how to use my setup quickly, thanks to a lot of gnome-integration starting with nautilus. I tried other desktop managers such as ROX, but the simplicity of nautilus is just so nice.

Anyway, be just like me (because I'm perfect). In other words, give up on Elive until some more development is done, and then develop yourself! I'll be doing just that and making a very professional looking tutorial for installing GRUB2 to a flash drive. Computers are all different, but hopefully I will be able to make the first comprehensive GRUB2 installation tutorial. I might even learn how to make packages myself. I don't know about RPMs, but I'll likely make a PKGBUILD and a DEB by the end of the school year.

Words of encouragement will definitely speed me up, so send away, my one still imaginary reader.

Delay

by Kholddagger | 10:05 PM in , , , | comments (0)

Sorry, my tiny audience. The "Persistent Elive on USB from an ISO" is coming soon. Currently I'm splitting my time between two projects. The first is called ISOLOADER, which is a "parasitic" initramfs that extracts any iso and siphons its initrd/initramfs to combine them and effectively boot any livecd from its raw iso file. Second, I'm performing a massive surgery on my iPhone in order to get MMS working.

As for now, I'll use the fact that e17-compiz is going through massive changes and needs at least one or two more releases until it's back to where it used to be.

Splashimage Troubleshooting

by Kholddagger | 12:02 AM in , | comments (0)

Here are some errors I forgot to mention. You may have trouble with splashimages when you set up GRUB in Debian/Elive/etc. This is because the version of GRUB installed is too old and does not include support. You can fix this by finding a newer DEB to install or compile the newest GRUB version from source.

Otherwise if your image does not work, double check that it is indexed to 14 colors and that your (hdX,X) points to the correct partition of your flash drive. For me, upon booting from USB, my flash drive is named (hd0), but depending on your computer and its BIOS version, this could be different. Experiment or search.

Although I haven't used Ubuntu much in the past few months, while I've been on a spree of trying out every Linux distro out there, I was just reading a few of the newest posts on Pendrivelinux.com. If you noticed, I just put an icon up to the right linking to the great website. Still, I had to wonder, why not dynamic?


Ubuntu is great for getting people into using Linux. If it weren't for Ubuntu, I'm sure I would have been almost as frustrated as when I used Vista and deleted my Linux partition instead of my Windows one. In that case, I would still be dealing with ridiculous file transfer times to my flash drive.

Still, to get to my point, Ubuntu has taken a great step forward with the release of 8.10 due to its program for installing to a flash drive persistently. Yet, while simpler, it does not do it as well as Sabayon. Sabayon has XsistenCe instead of Casper. XsistenCe allows users to have a loop file to persistently save their changes onto, and this file is always about the right size to fit the files. (Mine, for example, only wastes 5MB of space.) In Ubuntu, however, the file stays one size and therefore causes the installation of the flash drive to take a much longer time than it needs to and it wastes exorbitant amounts space on the flash drive.

Futher, this is the same technology used by Puppy for years! Surely we've made it past this time. Linux-on-USB technology has been so rapidly increasing lately, all distros should try to use the best tech, because it is out there! 

This is why I propose creating scripts for a new type of persistence based on Xsistence called Vigilance.

Vigilance will, just like XsistenCe, search for a flash drive/partition with a blank file with a certain name, possibly vigilance.ext2, much like GRUB's find command. Then it will use dd and mkfs to create a loop file to store the contents of /home onto upon shutdown, since the OS will be using either UnionFS or AUFS. Since this file will most likely only be a few MBs if it just holds settings, simple commands to read the size of /home will help the scripts make a new loop file each time the minimum necessary size to hold the contents. Then upon booting, the contents can be copied to the ramdisk or mounted as a /home partition.

If anyone has any ideas on how to go about making these scripts, tell me. I am trying to discern the contents of initrd files. Elive has in its eli script a setting for booting from different loop files such as iso's and even directories. I plan on basing my scripts off of these, but there might be a better way. I am in the midst of learning to script myself. Luckily I have books at home on more than 15 languages.


As a disclaimer, I have not actually tried out Ubuntu's flash installer yet. I'll tell you how it goes when I do.

Giving GRUB a Custom Background

by Kholddagger | 11:11 PM in , , | comments (0)

Sorry, I will post my rant on the lack of functionality out there common to all operating systems that allows you to boot with a file or folder as the root partition soon. First I want to give you all another customization method for GRUB, which you now know how to put on your flash drive.

One fun and easy way to customize GRUB is to add your own background to it. I personally use the famous deep space photograph from the Hubble Space Telescope with all the different galaxies as mine because dark backgrounds work very well and it doesn't have a large range of colors. Since the images used have to be 640x480 resolution and only 14 colors, having a detailed photo with important color shading doesn't work very well after conversion.

Anyway, let's get started.

If you have ImageMagick installed on your computer, try this easy way to convert your favorite images into horribly mangled versions that can be used as a background for GRUB.

If you have funnypic.jpg stored in your "Pictures" folder, do this.

$ cd ~/Pictures
$ convert -resize 640x480 -colors 14 funnypic.jpg splash.xpm
$ gzip splash.xpm
$ mv splash.xpm.gz /media/disk/boot/grub/

Now add the following line to the top portion of your menu.lst file.

splashimage (hd0,0)/boot/grub/mybootsplash.xpm.gz
assuming that your boot directory is in the first partition, if not change the number after the comma

If you already have a splashimage line or gfxmenu line, you'll have to delete it.

You can also convert your image easily in GIMP if you like to take a more graphical approach. Just open your image in GIMP and resize it to 640x480. You can convert the image to 14 colors by going into the menus on the image window. Go Image > Mode > Indexed and change the max number of colors to 14. Now you can see how your image will look. Save it as an xpm then gzip it just as above. Move it to your flash drive and edit your menu.lst to finish up your work, and you're ready to try it out. If it didn't work, make sure that it is only 14 colors and ends in .xpm.gz and not anything else.

If you don't like the hassle of choosing and editing your own image, there are plenty of good premade ones you can download on lots of other websites and blogs. So try lots of images out and have fun with your customized GRUB menu!

While there are always the syslinux or extlinux (or even LILO etc.) bootloaders for your flash drive, nothing beats the great flexibility (use almost any type of formatting) and sometimes just familiarity of having GRUB on your flash drive. That is, of course, assuming that you want to run multiple operating systems on your flash drive, but I'll just assume that's why you're here.

To start off, familiarize yourself with the 'grub shell' and its commands. It has a very limited set of commands. This is one of my biggest problems with it. I wish you could use the mount and umount commands in it, but that is for another post. What you can do in it, however, is set the root partition, search for files, install GRUB, and setup GRUB, to name a few (most).

First:
$ cd /media/disk
assuming that that's where your flash drive is mounted
$ sudo mkdir -p ./boot/grub
$ sudo cp /boot/grub/* ./boot/grub

This will setup your GRUB on your flash drive just like how it is on your computer, assuming that you are working from the partition on which you booted from or if you have a shared /boot partition.

Before entering the GRUB shell, make a file to help you locate which drive is your flash drive.

$ touch ./boot/grub/here.txt

Now enter the GRUB shell.

$ sudo grub

Find your drive...

> find /boot/grub/here.txt
(Below should appear your drive)
> root (hd1,0)
or whatever was the result of the above
> setup (hd1)
Use the first part of the above. (hd2) etc.
> exit
That's it!

While this technically completes your simplified installation of GRUB, let me take a minute to explain the output of the setup command. If you encountered an error here, this may help you troubleshoot.

A healthy message returned from setup on a flash drive formatted in FAT (as most are) will look like this:

Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/fat_stage1_5" exists... yes
Running "embed /boot/grub/fat_stage1_5 (hd1)"... 18 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd1) (hd1)1+18 p (hd1,0)/boot/grub/stage2
/boot/grub/menu.lst"... succeeded
Done.

If the LiveCD you've copied your OS for USB booting from already has a /boot/grub directory, you may want to keep what files are already in there. If so, don't copy your hard drive's menu.lst file and simply edit the one that's already there. Also, if there is a file called stage2_eltorito, you can delete it (then copy the stage2 from your HDD), keep it, or even rename stage2 and use it instead, it makes no difference in the end.

If you don't have either a stage 1 or stage 2 file, setup will fail, so that's why you need to copy stage 1 over. Also, there is a file for each partition format type, which you need to have the correct one in order for GRUB to setup correctly. In this case, that was fat_stage1_5. Stage 1.5 is just a transition from 1 to 2. 1 is very short and 2 does all the work, but as for how GRUB works beyond this, you can look up for yourself.

Of course there are plenty of other things you want to do to make your flash drive work as you want it to. To start off, you want to customize the menu.lst file that is on your flash drive. Currently it won't work at all.

If you just want it to boot the operating systems on your home computer, for example, just change all the root lines from (hd0,X) to (hd1,X), since your flash drive will become (hd0) when booted from.

If you want to boot OS's on your flash drive from GRUB - and this is the true beauty of GRUB - just search google for the normal grub menu.lst file for that specific OS and copy and paste that. Then you can delete the root entry line and change the kernel and initrd lines to give whatever location vmlinuz and initrd are actually stored.

Here's a good example.

The regular GRUB entry for Puppy Linux would be:

title Puppy Linux 4.12
root (hd0,0)
kernel /pup412/vmlinuz PMEDIA=idehd psubdir=pup412
initrd /pup412/initrd.gz

If you have Puppy stored in a folder called "puppy" in the root of your flash drive, just change it to:

title Puppy Linux 4.12
kernel /puppy/vmlinuz root=/dev/ram0 PMEDIA=usbflash
initrd /puppy/initrd.gz

I changed a few other things, but even if you hadn't, it most likely would have worked well enough. Always check for specific USB configurations in OS documentation.

Now you have a working dual-purpose OS-booting/file-storing amazing chimera of a flash drive; all without formatting or partitioning it, I may add.

(By the way, I chose Puppy Linux because it can easily be stored in a folder and booted from there. Most operating systems are not this convenient, so my next post will mostly address this problem.)