Pages

Saturday, July 5, 2008

Creating a persistent USB boot image of Fedora 9

(commands in bold are ones you enter)


STEP1: Reformatting the USB stick is optional, however it will provide assurance
that the install will complete successfully. If you do not reformat the
USB stick continue onto
STEP1.1 if you did reformat continue onto
STEP2.


If you do/did not reformat the USB stick
continue onto
STEP1.1
if you did reformat continue onto
STEP2


To reformat the USB stick completely, erasing all data on it, perform the following steps which will create a clean FAT16 filesystem upon which the Live image will boot:



[root@CIO11-6305X /]# fdisk /dev/sdb


Command (m for help): d


Selected partition 1

Command (m for help): n

Command action


e extended


p primary partition (1-4)



p


Partition number (1-4): 1


First cylinder (1-987, default 1): [ENTER]


Using default value 1


Last cylinder or +size or +sizeM or +sizeK (1-987, default 987): [ENTER]



Using default value 987



Command (m for help): t


Selected partition 1


Hex code (type L to list codes): 6


Changed system type of partition 1 to 6 (FAT16)




Command (m for help): a


Partition number (1-4): 1



Command (m for help): w


The partition table has been altered!




Calling ioctl() to re-read partition table.



WARNING: Re-reading the partition table failed with error 16: Device or resource busy.


The kernel still uses the old table.


The new table will be used at the next reboot.




WARNING: If you have created or modified any DOS 6.x


partitions, please see the fdisk manual page for additional


information.


Syncing disks.



[root@CIO11-6305X /]# mkdosfs -n usbdisk /dev/sdb1



mkdosfs 2.11 (12 Mar 2005)


mkdosfs: /dev/sdb1 contains a mounted file system.



NOTE: If you get the above error you must umount the usb stick first.



[root@CIO11-6305X /]# umount /dev/sdb1




[root@CIO11-6305X /]# mkdosfs -n usbdisk /dev/sdb1






Output of fdisk /dev/sdb should show:




Device Boot Start End Blocks Id System


/dev/sdb1 * 1 987 1989760+ 6 FAT16






STEP1.1: Ensure the USB is bootable and contains a valid filesystem, valid filesystem(s)
include: FAT16/VFAT or EXT3




If you get following message, you need to mark the partition bootable.




# livecd-iso-to-disk Fedora-<release>-Live-i686.iso /dev/sdb1
Partition isn't marked bootable!
You can mark the partition as bootable with
# /sbin/parted /dev/sdb
(parted) toggle N boot
(parted) quit
Cleaning up to exit...
#



To mark the partition bootable,



# parted /dev/sdb
GNU Parted 1.8.6
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.

(parted)
print
Model: Imation Flash Drive (scsi)
Disk /dev/sdb: 1062MB

Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
1 32.3kB 1062MB 1062MB primary fat16


(parted)
toggle 1 boot
(parted)
print
Model: Imation Flash Drive (scsi)
Disk /dev/sdb: 1062MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos









Number Start End Size Type File system Flags
1 32.3kB 1062MB 1062MB primary fat16 boot


(parted)
quit
Information: Don't forget to update /etc/fstab, if necessary.
#


STEP2: Creation of LiveUSB and test case using qemu



Install the necessary rpms:



yum install livecd-tools qemu




Download the ISO LiveCD file from one of the Fedora mirrors or website/ftp (www.fedoraproject.org)



Run the livecd commands to copy the live image (assuming you downloaded the LiveCD iso to /home/)




NOTE: You may wish to create a persistant overlay file upon which data will be stored to be present even after the Live ISO is stopped (yes, that is right, if you save a file during the Live session it will be saved onto the USB to be available for the next session!). Add the following options to the below command: --overlapy-size-mb XXX where XXX is a size in MB. Usually good idea if this USB is only to be used for a Live boot of Fedora9 to make the overlay the capacity of the USB stick minus 1024 unless you are using a 1GB usb then make overlay 512.



Command to create the LIVEusb:

livecd-iso-to-disk [--overlay-sze-mb 1024] /home/Fedora-9-x86_64-Live.iso /dev/sdb1


Verifying image...


/home/BradS/Desktop/Fedora-9-x86_64-Live.iso: aafb1741096157a6aa5356bcd0bf7955



Fragment sums: 88923d32288f257c11bbc9d999ddebb73da46a3fbff2a2aaef3d2d44acf7

Fragment count: 20

Checking: 100.0%

The media check is complete, the result is: PASS.



It is OK to use this media.



Copying live image to USB stick


Updating boot config file


Installing boot loader


USB stick set up as live image!







To test the bootable image: You can either reboot if you did not or don't want to install/run QEMU or if you have this package installed run, as user root:


qemu -hda /dev/sdb1 -m 256 -std-vga



REMEMBER TO umount /dev/sdb1 before removing the usbstick from the drive as it may corrupt the image if you do not.

No comments: