Friday, June 29, 2012

Install live usb linux

Method IV: w/ GRUB as boot loader

Someone found the above process doesn't work and has documented for others this working process

The Situation:

    Running SLED 10 (Suse)
    The USB key is a 1GB and appears as /dev/sda
    Logged in as root
    The DSL ISO is downloaded to /root/Desktop/dsl-3.3.iso
    Two partitions, the first to use as general USB storage, the second for DSL
    The DSL partition wanted to be ext3 so that Windows doesn't mess it up
    The first partition needs to be the big storage one as Windows doesn't like addressing the second partition on flash drives 

The procedure:

    fdisk /dev/sda
        d - Delete all partitions on the key
        n - Make a partition
            p - Primary partition for general storage
            1 - First partition
            1 - From the first block
            948 - Most of the space, about 933MB 
        n - Make a partition
            p - Primary partition for DSL
            2 - Second partition
            949 - Start from the next available sector
            1012 - To the end of the disk. I give it 64 MB 
        a - Make the partition bootable
            2 - Mark the DSL partition bootable 
        t - Change the partition type
            1 - Change partition 1
            b - Change it to Win95 FAT32 
        w - Write the changes 
    fdisk -l - Gives the following output: 

        Device    Boot      Start         End      Blocks   Id  System
 /dev/sda1               1         948      954131+   b  W95 FAT32
 /dev/sda2   *         949        1012       64416   83  Linux

Your flash drive should now look like this

    mkdir /mnt/iso
    mkdir /mnt/usb
    mount -o loop /root/Desktop/dsl-3.3.iso /mnt/iso
    mkfs.vfat -F 32 /dev/sda1 # use -F 16 for FAT16
    mke2fs /dev/sda2 

Note: If you want to have an ext3 filesystem, add the -j flag: mke2fs -j /dev/sda2

    mount /dev/sda2 /mnt/usb/
    cd /mnt/iso
    tar cvp . | (cd /mnt/usb; tar xp )
    mkdir -p /mnt/usb/boot/grub
    cp /boot/grub/*stage* /mnt/usb/boot/grub/ 

(If your system doesn't boot with grub, try: cp /usr/lib/grub/i386-pc/*stage* /mnt/usb/boot/grub/)

    cat > /mnt/usb/boot/grub/menu.lst << EOF 

   title Damn Small Linux
   root (hd0,1)
   kernel /boot/isolinux/linux24 root=/dev/sda2 ro lang=us toram noeject frugal
   initrd /boot/isolinux/minirt24.gz

    cd /mnt/usb/
    grub-install --no-floppy --root-directory=. /dev/sda 

(In the line above, please note the space character between the dot in the device name)

    cd /root
    umount /mnt/usb
    umount /mnt/iso
    rm -r /mnt/iso
    rm -r /mnt/usb

No comments: