Here are the steps (tested with version x86-6.3-r2160 of LFS)
- Boot from an existing Linux distro
- Download the LFS LiveCD iso from http://www.linuxfromscratch.org/livecd/download.html
- Insert your flash disk but don't mount it
- Partition your usb disk (ERASING ALL DATA) with the command echo ",,b,*" | sfdisk /dev/sdX
- sdX should be replaced with the block device name of your usb drive
- Use the command dmesg if you need help finding it
- Ignore the "If you created or changed a DOS..." message
- Format the newly partitioned disk with mkfs.vfat /dev/sdX1
- Create a folder for mounting the new disk with mkdir /mnt/lfs-usb
- Mount the new partition with mount /dev/sdX1 /mnt/lfs-usb
- Create a directory to mount the LFS LiveCD iso with the command mkdir /mnt/iso
- Mount the iso with the command mount -o ro,loop lfslivecd-x86-6.3-r2160.iso /mnt/iso
- Change lfslivecd-x86-6.3-r2160.iso to match the iso file you downloaded
- mkdir /mnt/lfs-usb/boot
- cp /mnt/iso/boot/isolinux/linux /mnt/lfs-usb/boot
- cp /mnt/iso/boot/isolinux/initramfs_data.cpio.gz /mnt/lfs-usb/boot
- umount /mnt/iso
- cp lfslivecd-x86-6.3-r2160.iso /mnt/lfs-usb/lfslivecd.iso
- Change lfslivecd-x86-6.3-r2160.iso to match the iso file you downloaded
- echo "lfslivecd-x86-6.3-r2160" > /mnt/lfs-usb/VERSION
- This is just to record what version you have
- Change lfslivecd-x86-6.3-r2160 to match the name of the iso
- mkdir /mnt/lfs-usb/boot/grub
- cp /boot/grub/{stage1,stage2,fat_stage1_5} /mnt/lfs-usb/boot/grub
- Create a file named /mnt/lfs-usb/boot/grub/menu.lst with the following content
default 0
title LFS USB
root (hd0,0)
kernel /boot/linux root=iso:/dev/disk/by-uuid/48F4-6515:/lfslivecd.iso rootfstype=vfat rootdelay=20
initrd /boot/initramfs_data.cpio.gz
- You must change the UUID (48F4-6515 above) to match your disk UUID
- Use the command blkid to determine the UUID
- Unmount your usb key with umount /mnt/lfs-usb
- Start grub with the command grub
- Determine your grub device mapping name for your usb key with the grub command find /lfslivecd.iso
- Enter the grub command root (hdX,Y)
- You should get a response "Filesystem type is fat, partition type 0xb
- Enter the grub command setup (hdX)
- Note that you do NOT include the Y partition number
- Enter the grub command quit
- You are done. Try booting from the key now
More reference:
http://www.linuxfromscratch.org/hints
/downloads/files/lfscd-remastering-howto.txt
http://www.linuxfromscratch.org/
pipermail/lfs-support/2010-April/038468.html
http://www.rodneybeede.com/
Booting_the_Linux_From_Scratch_LiveCD
_from_a_usb_key_drive.html