Sunday, April 27, 2008

CD/DVD install with no CD/DVD

Want to install a DVD release of Linux but dont have a DVD drive or recorder? Your CD/DVD drive has died but you still want to install a new or updated version of Linux? You can, and you can do it all from your hard drive without burning a single CD or DVD.

To start we need to make a partition for the image to reside on. Two bits of advice, put the partition at the very end of the drive so you can recover the HD space later on if you wish. It's easy to add more room to the end of a partition but nearly impossible to add more room at the beginning of a partition. The second bit is, if you have no working CD/DVD drive at all you will need another way to resize your drives, for this I recommend going to http://www.pendrivelinux.com. They have a great list of thumb drive installs and how-to's, as well as their own version aptly called pendrivelinux which is great. You'll have to install gparted on it but still, very handy and a must have for your toolkit.

Okay, one way or another we now have a way to resize the drive, my personal preference is gparted. For the next step the size of the .iso we will be working with is needed. The one I will be using in this example is 3.9 Gig so I need 3.9 Gig plus a little bit for a fudge factor. A few hundred meg should be sufficient, however in my case I want to also back up some critical data so I bumped it to 5 Gig. You dont have to, but this is a great way to back up things you want to have readily available after you install. The minimum though is .iso size plus a bit, say 10% of .iso size.

You can use gparted to make this partition ext2 or you can issue the following command to do it. As root:

mkfs -t ext2 /dev/sda4

Where /dev/sda4 is the partition you just created, /dev/sda4 was mine. Make sure to change it to the one you actually made.

Next we need to get ready to start putting things together. All of the commands we will be using for this need to be issued as root so you might as well go there and stay there for awhile.

mkdir /mnt/iso
mkdir /mnt/target
mount -t ext2 /dev/sda4 /mnt/target

(note here, /dev/sda4 needs to changed to the one you made)

mount -o loop -t iso9660 /path/to/image /mnt/iso

(note here, for me this would be /home/jim/dls/Sabayon-Linux-x86-3.5-Loop2-r2.iso . Yours will differ, adjust accordingly)

cp -rvp /mnt/iso/* /mnt/target

Great almost done, but now your going to have to do a little thinking. We have to get what we just did to boot. Since the example I'm using probably wont be the one you will be using I will point out the changes you need to make. Regardless it's fairly straightforward.

We need to figure out the configuration we need to feed to GRUB to actually fire this up. Luckily 99% of this has already been done for us by whoever released the liveCD/DVD.

cd /mnt/target
ls -l


look around here for either isolinux.cfg or syslinux.cfg, if it is not in this directory

cd isolinux
ls -l


and look for it in this directory.

Once you have found it:

cat isolinux.cfg (syslinux.cfg if thats what you have)

You are going to get a lot of stuff here, we are actually only concerned with a little bit. The line LABEL is what we are looking for, the first one usually but read the LABEL to make sure its the one your looking for. In my case:

LABEL sabayon
menu label ^Start SabayonLinux 3.5 Loop2
kernel /boot/sabayon
append root=/dev/ram0 initrd=/boot/sabayon.igz aufs init=/linuxrc cdroot looptype=squashfs max_loop=64 loop=/livecd.squashfs splash=silent,theme:sabayon vga=791 CONSOLE=/dev/tty1 quiet music --

Is the one I want. When you see the next line that says LABEL, that is a seperate boot entry and you wont need it. Now we need to make a few changes to it, to make it bootable from GRUB.

title sabayon
root (hd0,3)
kernel /boot/sabayon root=/dev/ram0 aufs init=/linuxrc cdroot=/dev/sda4 looptype=squashfs max_loop=64 loop=/livecd.squashfs splash=silent,theme:sabayon vga=791 CONSOLE=/dev/tty1 music quiet --
initrd /boot/sabayon.igz

First you'll see I changed it from LABEL to title and removed the menu label line.

Second you'll see I added root(hd0,3). You'll need to adjust this to match where you extracted the .iso image. GRUB counts from 0 so drive 1 = 0 and partition 4 = 3. sda3 would be (hd0,2) sdb3 would be (hd1,2) and so on.

Third you will see that I left the kernel line alone.

Fourth you will see that I removed the word append and then moved the whole thing up so it follows the original kernel line. Then moved initrd=/boot/sabayon.igz to it's own line at the very bottom. Following that a bit further you will also find that where it says cdroot I added the actual partition where we extracted the .iso.

Note that while it looks complex, and the one you will be looking at will probably look significantly different your only actually making a small handful of changes. Just make the small edits as described leaving the rest alone and you'll be golden.

Okay, lets say you now have your entry figured out. Now you simply have to edit /boot/grub/grub.conf and add it to the very end of that file. This file has to be edited as root, and make sure you dont over write anything that is in there already.

Save the file, reboot, and you should see the entry for the LiveCD/DVD as an option in your boot menu.

Once your done you can safely remove the partition you made and reclaim the space using gparted again, or leave it in place and have an emergency boot, although you will have to add the lines back into GRUB if you overwrote your last one if/when you installed.

I wish I could take full credit for this, however I cant. I was working on making a USB variant of this, and was almost there but was having a few problems with it when jvj posted an almost line for line how to in the sabayon wiki. I want to thank him for pointing out that cdroot needed to be pointed to the partition, which is where I was stuck at. Since we both use Sabayon and Loop2 is the most current beta at the time of the writing that is why so much of his wiki entry and my how to look so similar.

Anyway, thanks jvj, and to the rest of you, happy computing.

~Az

*UPDATE* 07July08

I'm happy to say that Sabayon 3.5 has officially been released and that the above how-to has been tested against it and it worked perfectly. Here is the grub.conf entry I used to get it working on my laptop.

title Sabayon 3.5 Install/LiveDVD

root (hd0,3)
kernel /boot/sabayon root=/dev/ram0 aufs init=/linuxrc cdroot=/dev/sda4 looptype=squashfs max_loop=64 loop=/livecd.squashfs splash=silent,theme:sabayon vga=791 CONSOLE=/dev/tty1 quiet --
initrd /boot/sabayon.igz
Remember you will have to adjust root (hd0,3) and cdroot=/dev/sda4 to reflect your actual system as explained in the above article. Due to formatting issues of the blog I should point out that everything from kernel /boot/sabayon to quiet -- is actually one long line.

**UPDATE** 17Oct08
I finally did a write up for how to make a bootable USB from a DVD image. If you have a 4 Gig or larger thumbdrive handy give it a try.
Again, Happy Computing
~Az

Wednesday, April 9, 2008

Linux and Ipod Video Conversion

Okay, lets face it, I'm lazy ... really really lazy. When I picked up my new iPod (yes I finally joined the iLemming crowd) it took me only a few minutes to figure out that gtkpod was probably going to be my best bet for my 5G 30 Gig music toy. I promptly spent the following week using all my spare time feeding my computer CD after CD and still coming up with a heck of alot of unused space.

I knew that the wonder toy could do video as well, and that gtkpod could manage the video files as well, just not on the fly conversion to what ever format it wanted to be fed. Thus started my research project and my headache. It can do video, but it is supremely picky about just what it will take as far as bitrate, aspect ratio, and file type.

I started the project thinking to use transcode and command line. After this decision and alot of language that is not ever to be used in the presence of women, children, or fish, I was amazed that I had any hair left. The next step was a little more research and deciding to try it with ffmpeg. 2 days later and some blood, sweat, and more colorful invective, success. I made a (singular) video that my ipod would accept and play, rapidly followed by 2 more that wouldn't.
This was frustrating to say the least. So I attacked google once again and much to my delight I ran across 'convert2videomp4' at kdeapps.org. A simple little utility that adds an encoding option to the KDE menu. Right click on the file you want to convert ... any video file your computer can play and select the final file output you want. The rest happens automagically.



So now with this handy little collection of scripts in an easy to use menu, I can go back to being as lazy as I want to be. Right click, convert, load to iPod. On a side note I highly recommend that you edit the meta tags on these files either before or after you get them onto the iPod. If nothing else set the Genre of it to Movie. The first one I put on I could not take back off because I could not find it using gtkpod for a half an hour or so. Very frustrating, but lesson learned, always always always edit the meta tags the minute you transfer the file. Also if using gtkpod, add the video's one at a time and save the changes between each one, it doesn't seem to like batch transferring movie files.

This little gem can be found at www.kde-apps.org, the instructions for installing are very straight forward and simple, just a little script to be run as a normal user, as long as you have the prerequisite codecs already installed. They are listed on the main page where I linked to.

p.s. Sorry Steve, this isn't the article I was discussing with you, but it is still in the back of my mind.