HOWTO_LiveUSB_Key

http://www.gentoo-wiki.info/HOWTO_LiveUSB_Key

 

HOWTO_LiveUSB_Key

Merge-arrows.gif It has been suggested that this article be Merged into one article with Live USB stick using GRUB .    (Discuss )

This is the perfect project for that spare 1GB usb key you have laying dormant in your desk drawer.

Contents

Purpose

This HOWTO makes puts the latest Gentoo release onto a USB key and makes it bootable.

Sample reasons to follow this HOWTO include:

  • The latest 2008.0 LiveCD ISO images, at just over 800MB, are larger than the regular CDs you have available.
  • Your computer does not have an optical drive.

The Gentoo Linux LiveUSB HOWTO documents how to emulate a Gentoo Linux 2007.0 LiveCD using a USB flash drive. With 2008.0, Gentoo started to use GRUB as the bootloader for installation media so an updated procedure is required.

Note: As the latest official documentation the HOWTO is still worth reading for background information.

For this HOWTO we choose to use the FAT filesytem and the GRUB bootloader. GRUB because it was chosen by Gentoo Release Engineering for their latest releases, and because it allows for the simplest procedure. We choose FAT because it is ubiquitous on these devices, see Wikipedia

The HOWTO LiveUSB uses the ext3 filesystem and the extlinux bootloader.

Instructions

We will check the partition table, reformat the device, mount it and the install media, copy some files, unmount both, install the bootloader and then test the finished product!

Note: Make sure you don't mix up your architectures. GRUB and the LiveCD must be the same architecture as your target. If you run a 64 bit Linux, you will need to use a 32 bit chroot in order to create a LiveUSB Key for a 32 bit computer.

Check Partition Table

Warning: Important: This HOWTO assumes that the /dev/sdc device node corresponds to your USB flash drive. If you have other SCSI-like devices make sure to use the correct device node.
Note: Refer to the "Preparing the Disks" section of the Gentoo Handbook for additional information about partitioning disks.

To read the partition table use:

fdisk -l /dev/sdc
Code: Sample fdisk Output
Disk /dev/sdc: 2063 MB, 2063597056 bytes
255 heads, 63 sectors/track, 250 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 * 1 250 2008124+ 6 FAT16


The key should contain a single partition using all of the available space. For a key smaller than 4GB the System column should read FAT16; set the type to 6. If your key is 4GB or larger it should be W95 FAT32; partition type b.

Running the fdisk command without the -l switch modifies the partition table:

fdisk /dev/sdc

Format

Formatting the disk ensures a blank slate for the rest of the procedure. Depending on the size of your device, a slightly different filesystem is required. Note that you will need sys-fs/dosfstools emerged to have the mkdosfs command available.

Create a blank FAT file system on your device, if smaller than 4GB:

mkdosfs -F 16 /dev/sdc1 

If 4GB or larger, create a blank FAT file system:

mkdosfs -F 32 /dev/sdc1

Mount Devices

You will need a copy of a 2008.0 ISO image which you can download from the Get Gentoo! page. Here we mount this image and the target USB key onto the local file hierarchy. Replace image.iso below with the filename of your download.

mkdir -p /mnt/cdrom /mnt/usb
mount -o loop image.iso /mnt/cdrom
mount /dev/sdc1 /mnt/usb

Copy Files

The sys-boot/grub package includes GRUB stages which we now copy onto the USB key, later we will install them into the key's MBR.

Copy over the ISO contents and GRUB stages:

cp -r /mnt/cdrom/* /mnt/usb
cp /lib/grub/i386-pc/stage1 /mnt/usb/boot/grub/
cp /lib/grub/i386-pc/stage2 /mnt/usb/boot/grub/
cp /lib/grub/i386-pc/fat_stage1_5 /mnt/usb/boot/grub/

Unmount Devices

All of the required files are now on the USB key, so we can detach the disc image and the USB key from the directory tree.

umount /mnt/cdrom
umount /mnt/usb

Install GRUB

Note: Refer to the "Configuring the Bootloader" section of the Gentoo Handbook for additional information about installing GRUB.

GRUB can be installed onto the USB key in either of two ways: using grub-install or manually. grub-install needs to probe devices so will not work in a chroot.

The Gentoo Grub Error Collection documents some common problems installing GRUB.

Using grub-install
Warning: Check the partition below is correct or you may overwrite your existing distribution's boot loader.
grub-install /dev/sdc1

Manually
grub

Then at the GRUB command line:

Warning: Check that the partition below; (hd1,0), and the device; (hd1), are correct or you may overwrite your existing hard disk boot loader.
grub> root (hd1,0)
grub> setup (hd1)
grub> quit

Test

You should now have a USB key which will run the latest Gentoo release media. Insert it and turn on the the target computer, making sure the BIOS is set to boot from USB. You should now have booted your favorite operating system.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值