Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
CentOS 7 Linux Server Cookbook, Second Edition

You're reading from   CentOS 7 Linux Server Cookbook, Second Edition Get your CentOS server up and running with this collection of more than 80 recipes created for CentOS 7 - essential for Linux fans!

Arrow left icon
Product type Paperback
Published in Jan 2016
Publisher
ISBN-13 9781785887284
Length 326 pages
Edition 2nd Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Jonathan Hobson Jonathan Hobson
Author Profile Icon Jonathan Hobson
Jonathan Hobson
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Installing CentOS FREE CHAPTER 2. Configuring the System 3. Managing the System 4. Managing Packages with YUM 5. Administering the Filesystem 6. Providing Security 7. Building a Network 8. Working with FTP 9. Working with Domains 10. Working with Databases 11. Providing Mail Services 12. Providing Web Services 13. Operating System-Level Virtualization 14. Working with SELinux 15. Monitoring IT Infrastructure Index

Creating USB installation media on Windows or OS X

In this recipe, we will learn how to create a USB installation media on Windows or OS X. Nowadays, more and more server systems, desktop PCs, and laptops get shipped without any optical drive. Installing a new operating system, such as CentOS Linux using USB devices gets essential for them as no other installation option is available, as there is no other way to boot the installation media. Also, installing CentOS using USB media can be considerably faster than using the CD/DVD approach.

Getting ready

Before we begin, it is assumed that you have followed the previous recipe in which you were shown how to download a minimal CentOS image and confirm the checksum of the relevant image files. It is also assumed that all the downloads (including the downloaded ISO file) are stored on Windows in your C:\Users\<username>\Downloads folder or if using a OS X system, in the /Users/<username>/Downloads folder. Next, you will need a free USB device which can be discovered by your operating system, with enough total space, and which is empty or with data on it that can be discarded. The total space of the USB device needed for preparing as an installation media for CentOS 7 for the minimal version must be roughly 700 megabyte. If you are working on a Windows computer, you will need a working Internet connection to download additional software. On OS X, you need an administrator user account.

How to do it...

To begin this recipe, start up your Windows or OS X operating system, then connect a free USB device with enough capacity, and wait until it gets discovered by File Manager under Windows or Finder under OS X.

  1. On a Windows based system, we need to download an additional software called dd. Visit http://www.chrysocome.net/dd in your favorite browser. Now download the latest dd-XX.zip file you can find there, with XX being the latest stable version number. For example, dd-0.5.zip.
  2. On Windows, navigate to your Downloads folder using File Manager. Here you will find the dd-05.zip file. Right-click on it and click on Extract All, and extract the dd.exe file without creating any subdirectory.
  3. On Windows, open the command prompt (typically found at Start | All Programs | Accessories | Command Prompt) and type the following commands:
    cd downloads
    dd.exe --list
    
  4. On OS X, open the program Finder | Applications | Utilities | Terminal, and then type the following commands:
    cd ~/Downloads
    diskutil list
    
  5. On Windows, to spot the name of the right USB device you want to use as installation media, look into the output of the command under the removable media section. Below that, you should find a line starting with Mounting on and then a drive letter, for example, \.\e:. This cryptic written drive letter is the most important part we need in the next step, so please write it down.
  6. On OS X, the device path can be found in the output of the former command and has the format of /dev/disk<number>, where number is a unique identifier of the disk. The disks are numbered, starting with zero (0). Disk 0 is likely to be the OS X recovery disk, and disk 1 is likely to be your main OS X installation. To identify your USB device, try to compare the NAME, TYPE, and SIZE columns to the specifications of your USB stick. If you have identified the device name, write it down, for example, /dev/disk3.
  7. On Windows, type the following command, assuming your USB device selected as a installation media has the Windows device name \\.\e: (change this as required and be careful what you type – this can create tremendous data loss). Also, substitute XXXX with the correct iso file version number in the next command:
    dd.exe if=CentOS-7-x86_64-Minimal-XXXX.iso of=\\.\e: bs=1M
    
  8. On OS X, you need two commands which will ask for the administrator password (replace XXXX and disk3 with the correct version number and the correct USB device path):
    sudo diskutil unmountDisk /dev/disk3
    sudo dd if=./CentOS-7-x86_64-Minimal-XXXX.iso of=/dev/disk3 bs=1m
    
  9. After the dd program finishes, there will be some output statistics on how long it took and how much data has been transferred during the copy process. On OS X, ignore any warning messages about the disk not being readable.
  10. Congratulations! You now have created your first CentOS 7 USB installation media. You now can safely remove the USB drive in Windows or OS X, and physically unplug the device and use it as a boot device for installing CentOS 7 on your target machine.

How it works...

So what have we learned from this experience?

The purpose of this recipe was to introduce you to the concept of creating an exact copy of a CentOS installation ISO file on a USB device, using the dd command-line program. The dd program is a Unix based tool which can be used to copy bits from a source to a destination file. This means that the source gets read bit by bit and written to a destination without considering the content or file allocation; it just involves reading and writing pure raw data. It expects two file name based arguments: input file (if) and output file (of). We will use the CentOS image file as our input filename to clone it exactly 1:1 to the USB device, which is accessible through its device file as our output file parameter. The bs parameter defines the block size, which is the amount of data to be copied at once. Be careful, it is an absolute expert tool and overwrites any existing data on your target while copying data on it without further confirmation or any safety checks. So at least double-check the device drive letters of your target USB device and never confuse them! For example, if you have a second hard disk installed at D: and your USB device at E: (on OS X, at /dev/disk2 and /dev/disk3 respectively) and you confuse the drive letter E: with D: (or /dev/disk3 with /dev/disk2), your second hard disk would be erased with little to no chances of recovering any lost data. So handle with care! If you're in doubt of the correct output file device, never start the dd program!

In conclusion, it is fair to say that there are other far more convenient solutions available for creating a USB installation media for CentOS 7 than the dd command, such as the Fedora Live USB Creator. But the purpose of this recipe was not only to create a ready-to-use CentOS USB installer but also to get you used to the dd command. It's a common Linux command that every CentOS system administrator should know how to use. It can be used for a broad variety of daily tasks. For example, for securely erasing hard disks, benchmarking network speed, or creating random binary files.

You have been reading a chapter from
CentOS 7 Linux Server Cookbook, Second Edition - Second Edition
Published in: Jan 2016
Publisher:
ISBN-13: 9781785887284
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image