So I have a laptop with no DVD drive. I wanted to try out Linux From Scratch (LFS), but I couldn't build it without the LiveCD.
I decided to try running the ISO from a usb drive. I found some instructions on how to boot from a usb drive on the LFS LiveCD Documentation page, but they aren't the most clear on how to make the USB drive bootable with grub.
It took me a while to get grub to install on the usb drive. I discovered that you must have at least one partition on the device for it to work. The instructions on the LFS site recommended using grub4dos if you want to create the disk from Windows, but I found it easier to simply boot from an existing Linux distro (I used System Rescue CD) and install grub that way.
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
|