Differences between revisions 45 and 46
| Deletions are marked like this. | Additions are marked like this. |
| Line 12: | Line 12: |
| A end user recommendeds the following approach for CentOS-6, using '''livecd-iso-to-disk''' from '''livecd-tools''' with DVD1. This has been tested with livecd-tools-13.4-1.el6 from EPEL. Thanks to forum user '''!AndrewSerk''' for the recommendation in a [https://www.centos.org/modules/newbb/viewtopic.php?topic_id=37395&forum=55&post_id=163379#forumpost163379 forum post]. See also the motation of a need for installation of '''qemu''' in this mailing list [http://lists.centos.org/pipermail/centos/2012-January/122140.html post]. | A end user recommendeds the following approach for CentOS-6, using '''livecd-iso-to-disk''' from '''livecd-tools''' with DVD1. This has been tested with livecd-tools-13.4-1.el6 from EPEL. Thanks to forum user '''!AndrewSerk''' for the recommendation in a [https://www.centos.org/modules/newbb/viewtopic.php?topic_id=37395&forum=55&post_id=163379#forumpost163379 forum post]. See also the notation of a need for installation of '''qemu''' in this mailing list [http://lists.centos.org/pipermail/centos/2012-January/122140.html post]. |
How to Set Up a USB Key to Install CentOS
|
The procedures below have been tested by various users, but may not cover all eventualities. There is not a formal CentOS project recommended approach, as the supported installer is anaconda, or in some cases by a Live CD. Let the installer beware, or at least enjoy experimentation.
Motivation
Many recent systems, particularly netbooks and small notebooks, may not have a CD or DVD drive and a network install may be difficult, impractical, or impossible, depending on network connectivity and installer support for the available network hardware. This procedure allows a CentOS install without network connectivity and with no media other than a bootable USB device and the target system disk.
CentOS-6
A end user recommendeds the following approach for CentOS-6, using livecd-iso-to-disk from livecd-tools with DVD1. This has been tested with livecd-tools-13.4-1.el6 from EPEL. Thanks to forum user AndrewSerk for the recommendation in a forum post. See also the notation of a need for installation of qemu in this mailing list post.
Obsolete method
Building a distribution on a USB key as of CentOS 6.2 - thanks to Mark Roth for the CentOS-6 procedure, and to Yves Bellefeuille on the CentOS-Docs list for several additions and corrections.
Recommended: An 8GB or larger USB key.
- Partition the USB key into two partitions: the first, FAT32, and about 250M; the second, the rest of the drive, and ext3. (An ext3 partition is required because the ISO file, that will later be copied to it, is larger than the maximum file size for a FAT32 or VFAT partition.)
- Mount DVD1, if it isn't automounted (on /media, or /mnt). The following assumes /mnt/USB and /mnt/DVD.
Mount the USB key on /mnt/USB/.
Copy the directory and contents of /mnt/DVD/isolinux to /mnt/USB/.
Rename /mnt/USB/isolinux to /mnt/USB/syslinux
Rename /mnt/USB/syslinux/isolinux.cfg to /mnt/USB/syslinux/syslinux.cfg
Copy the directory and contents of /mnt/DVD/images to /mnt/USB/. (A bug has been filed [ToDo - add link] because as of 11 Jan 2012, the install requires the .iso (see below), but linux rescue requires the contents of images to load and run.)
- Assuming that the USB key is /dev/sdb
syslinux /dev/sdb1
- Unmount the first USB partition, and mount the second
umount /mnt/USB mount /dev/sdb2 /mnt/USB
Copy the .iso file to /mnt/USB. Do not use the LiveCD or LiveDVD. Use DVD1, the minimal CD ISO, or a combined DVD1/DVD2 created following CD to DVD Media. Do not copy the contents - the install now wants the .iso file itself, which it mounts during installation, and follow the upstream Installation_Guide to create an images directory on the same partition. Optionally, add DVD2 if you used DVD1, and need it for the install.
Optional: On /mnt/USB, create a grub.conf. This may be required if your system wants the USB key as the first drive, so that you can later copy it to the hard disk. See HowTos/GrubInstallation section 2 for guidance.
- Umount the USB key, and it's ready to use.
- Boot from the USB media by setting it as the first BIOS boot device, or on some BIOSs by hitting a key such as F12 to select a boot device after POST.
During the installation process, the user is asked "What type of media contains the installation image?" Select the first partition on the USB key, which should appear in the menu under "Hard drive", then /dev/sda1 or whatever device corresponds to the first USB partition.
- After partitioning, the user is asked whether to install the Grub boot loader and where to install it. After booting from the USB key, the BIOS may think that the USB key is the first drive. If the USB is seen as the first device, then to install the Grub boot loader on the hard drive MBR, which is the usual case, the user must change the order of the hard drives using the Grub advanced installation options.
After the Grub installation options, the following error message may appear: "Missing ISO 9660 image: The installer has tried to mount image #1, but cannot find it on the hard drive". The installation program is looking for the ISO file on the first partition of the USB key, but it's on the second partition. Go to a terminal with a shell with Ctrl-Alt-F2, unmount the first partition of the USB
umount /mnt/isodir
mount the second partition on the USB device. This will be the same device used in #14 above - for examplemount -t ext3 /dev/sda2 /mnt/isodir
Return to the installation program (Ctrl-Alt-F6) and choose "Retry".Finish the installation and reboot without the USB device connected. If there are problems booting then it is likely the boot record was written to the wrong device. See How to re-install bootstrap code (GRUB), and if having difficulties determining the correct device, Troubleshooting GRUB Issues.
CentOS-5
Note: The livecd-iso-to-disk from livecd-tools method as recommended above for CentOS-6 may be preferable, but has not been tested by the author.
Prerequisites
- A target system for the installation that supports booting from USB media. This may need to be configured in the BIOS setup.
- A USB key with sufficient capacity to hold the installation media - also known as: memory stick, flash drive, thumb drive, etc. CentOS 5.4 i386 should fit on a 4GB drive, x86_64 requires more than 4GB, a minimal install from CD#1 should be possible with a 1GB drive. The same technique should be usable with a USB hard drive. It is assumed that this procedure is being performed in a GUI (GNOME/KDE/etc.) environment so automounting of the USB media will be performed.
A working Linux system (probably another computer with Linux installed, running from a live CD, or in a Virtual Machine) with syslinux ("yum install syslinux" or install using the native package manager for the distribution, if not already installed). The author encountered problems using the CentOS-5.3/5.4 syslinux package. The package supplied by the CentOS LiveCD Tools repo worked.
- A set of CentOS installation CD ISO images, or DVD ISO image, for the desired architecture.
It may be necessary to change device names, architecture, and/or syslinux paths to match your installation distribution, situation, and preferences.
Use caution when copying/pasting commands below to adjust for your situation!
Procedure
Assume the USB key shows up as /dev/sdg (adjust for your situation - will likely be different) and CentOS 5.4 i386 is being installed.
Become root. Create a small VFAT partition (20 MB should be sufficient) and a big Linux one on the USB media. Make the VFAT partition active.
fdisk /dev/sdg
In fdisk use "m" to see the the menu options. The sequence of commands goes something like the following (without "#" comments):d # delete existing partition - repeat as necessary n # new partition p # primary 1 # partition number <enter> # take the default +20m # add 20 MB t # change the type 1 # partition number b # VFAT n # new partition p # primary 2 # partition number <enter> # take the default <enter> # take the default a # toggle bootable flag 1 # partition number w # write to disk
Should look something like this when done:Disk /dev/sdg: 7948 MB, 7948206080 bytes 81 heads, 10 sectors/track, 19165 cylinders Units = cylinders of 810 * 512 = 414720 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/sdg1 * 1 65 26320 b W95 FAT32 /dev/sdg2 66 19165 7735500 83 Linux
- Make the filesystems:
mkfs.vfat -n BOOT /dev/sdg1 mkfs.ext2 -m 0 -b 4096 -L DATA /dev/sdg2
Unplug/plug the USB media. The partitions should mount under /media/BOOT and /media/DATA. - Copy the CentOS ISO[s] to the ext2 partition. For CD ISOs:
cd /dir/of/iso/images mkdir /media/DATA/centos mkdir /tmp/cdimage mount -ro loop CentOS-5.4-i386-bin-1of6.iso /tmp/cdimage cp *sum* /media/DATA/centos for i in 1 2 3 4 5 6; do cp -v CentOS-5.4-i386-bin-${i}of6.iso /media/DATA/centos/; sync; done cd /media/DATA/centos grep of6 sha1sum.txt | sha1sum -c - CentOS-5.4-i386-bin-?of6.isoFor DVD media replace the "for" loop above and the next two lines withcp -v CentOS-5.4-i386-bin-DVD.iso /media/DATA/centos/; sync cd /media/DATA/centos grep DVD sha1sum.txt | sha1sum -c - CentOS-5.4-i386-bin-DVD.iso
- Install and configure syslinux on the VFAT partition and MBR:
syslinux -s /dev/sdg1 dd if=/usr/share/syslinux/mbr.bin of=/dev/sdg cd /media/BOOT cp -rv /tmp/cdimage/isolinux syslinux mv syslinux/isolinux.cfg syslinux/syslinux.cfg rm -f syslinux/isolinux.bin umount /tmp/cdimage <your-favorite-editor> syslinux/syslinux.cfg
Add to the "append" statements in the various sections:method=hd:sda2:/centos
To use kickstart:ks=hd:sda2:/ks.cfg method=hd:sda2:/centos
- Use the GUI to "Safely Remove" the USB media. Move to the target system, boot and install.
Notes
For general information see the Installation Guide.
During testing of this procedure some MicroSDHC media failed to work and got write errors for all iso images, even after repartitioning and reformatting. Another similar piece of media from a different manufacturer worked fine. If errors are encountered try different media, or reformat and try again. The Windows (unfortunately - sorry) Panasonic SDHC Formatter has proven very useful for non-cooperative SD media. Use the full format option with erase and size adjustment, not the quick option.
Format type - FULL(Erase ON) Format size adjustment ON
- It may be necessary to use the CD ISOs because the DVD image has been reported by some to be corrupted on the USB key. Both the CD and DVD images worked for the author.
- Attempting to install with the USB media write-protected generates numerous errors about the media being write protected. Did not try an install after those warnings.
|
- Using extlinux rather than syslinux may be preferable as that eliminates the need for a FAT partition.
Thanks to John Doe in the following CentOS Users mailing list post for the basic material: http://lists.centos.org/pipermail/centos/2009-June/077860.html
- Additional comments from the OP: Hum, my bad... I am myself using a kickstart file and I forgot I had to use the following line in it (and I use HP raid controlers):
bootloader --driveorder=cciss/c0d0,sda --location=mbr
For the kickstart, I use the following:
- In syslinux/syslinux.cfg:
append initrd=initrd.img ks=hd:sda2:/ks.cfg method=hd:sda2:/centos
- In /media/DATA/ks.cfg (in their respective sections):
harddrive --partition=sda2 --dir=/centos ignoredisk --drives=sda bootloader --driveorder=cciss/c0d0,sda --location=mbr
And, to be honest, I should not really get credit for this; I found most of the info on the web... _
And I also reported earlier that:
- My server HP does not seem to want to boot on a write protected USB key.
- Anaconda tries to fetch the ks.cfg too early... If, once the detection is over (just 2-3 seconds later), I retry, it works.
- There is an error message "cannot mount read/write, will mount read-only" (I like to write protect)
Alternatives
UNetbootin is probably the most popular "outside" method, has both Windows and Linux executables, and allows you to create bootable Live USB drives for a variety of Linux distributions, including CentOS. There was an anaconda bug that could render the media unusable - now closed for Fedora 13 and presumably thus RHEL/CentOS-6. It has been reported on the fora to work with at least the netinstall ISO for CentOS-6. When using the netinstall ISO the full installation media ISO can be copied to the root directory of the USB media and a "Hard Drive" install performed.
- Marcus Moeller recommends:
Much better is livecd-iso-to-disk which can be obtained from git:
http://git.fedorahosted.org/git/?p=livecd;a=blob_plain;f=tools/livecd-iso-to-disk.sh;hb=HEAD
Just download it, chmod +x and run:
./livecd-iso-to-disk.sh /path/to/iso /dev/partition_of_your_usb_stick
You could also add an option like:
--overlay-size-mb 1024
to add some persistent space to the key.
The resulting key could directly be used for installations, without the need of placing the iso manually on the key.
Forum user Al_Stu recommends this procedure.
Forum user ron_l_j recommends a Windows tool iso2usb.
A CentOS ML member recommends Pendrivelinux.com.
Yet another procedure for Building an install disk on a USB key.
An alternative approach if no network is available is to boot from diskboot.img on a USB key as documented in the Installation Guide and do a hard disk install with ISO images on the target computer.
Forum user ixeous describes use of GRUB2 to create a bootable USB for a variety of uses.
Not an endorsement, but OSDisc.com sells various bootable USB media with CentOS at seemingly reasonable prices. A report on the Fora would be appreciated if anyone tries these.
This page created and maintained by PhilSchaffner. Other Wiki contributors with edit rights are invited to make corrections or additions. Other readers with comments can find contact information on my Wiki page.
