CentOS 8 Essentials
上QQ阅读APP看书,第一时间看更新

3.2 Writing the ISO Installation Image to a USB Drive

These days it is more likely that an operating system installation will be performed from a USB drive than from a DVD. Having downloaded the ISO installation image for CentOS 8, the steps to write that image to a USB drive will differ depending on whether the drive is attached to a Linux, macOS or Windows system. The steps outlined in the remainder of this section assume that the USB drive is new, or has been reformatted to remove any existing data or partitions:

3.2.1 Linux

The first step in writing an ISO image to a USB drive on Linux is to identify the device name. Before inserting the USB drive, identify the storage devices already detected on the system by listing the devices in /dev as follows:

# ls /dev/sd*

/dev/sda /dev/sda1 /dev/sda2

Attach the USB drive to the Linux system and run the dmesg command to get a list of recent system messages, one of which will be a report that the USB drive was detected and will be similar to the following:

[445597.988045] sd 6:0:0:0: [sdb] Attached SCSI removable disk

This output tells us that we should expect the device name to include “sdb” which we can confirm by listing device names in /dev again:

# ls /dev/sd*

/dev/sda /dev/sda1 /dev/sda2 /dev/sdb

From this output we can tell that the USB drive has been assigned to /dev/sdb. The next step before writing the ISO image to the device is to run the findmnt command to make sure it has not been auto-mounted:

# findmnt /dev/sdb

TARGET SOURCE FSTYPE OPTIONS

/run/media/neil/d6bf9574-7e31-4f54-88b1 /dev/sdb ext3 rw,nosuid,no

If the findmnt command indicates that the USB drive has been mounted, unmount it before continuing:

umount /run/media/neil/d6bf9574-7e31-4f54-88b1

Once the filesystem has been unmounted, use the dd command as follows to write the ISO image to the drive:

# dd if=/path/to/iso/image.iso of=/dev/sdb bs=512k

The writing process can take some time (as long as 10 - 15 minutes) to complete depending on the image size and speed of the system on which it is running. Once the image has been written, output similar to the following will appear and the USB drive is ready to be used to install CentOS 8:

5956+0 records in

5956+0 records out

3122659328 bytes (3.1 GB, 2.9 GiB) copied, 426.234 s, 7.3 MB/s

3.2.2 macOS

The first step in writing an ISO image to a USB drive attached to a macOS system is to identify the device using the diskutil tool. Before attaching the USB device, open a Terminal window and run the following command:

$ diskutil list

/dev/disk0 (internal, physical):

   #: TYPE NAME SIZE IDENTIFIER

   0: GUID_partition_scheme *1.0 TB disk0

   1: EFI EFI 209.7 MB disk0s1

   2: Apple_APFS Container disk2 1000.0 GB disk0s2

 

/dev/disk1 (internal):

   #: TYPE NAME SIZE IDENTIFIER

   0: GUID_partition_scheme 28.0 GB disk1

   1: EFI EFI 314.6 MB disk1s1

   2: Apple_APFS Container disk2 27.7 GB disk1s2

 

/dev/disk2 (synthesized):

   #: TYPE NAME SIZE IDENTIFIER

   0: APFS Container Scheme - +1.0 TB disk2

                                 Physical Stores disk1s2, disk0s2

   1: APFS Volume Macintosh HD 473.6 GB disk2s1

   2: APFS Volume Preboot 42.1 MB disk2s2

   3: APFS Volume Recovery 517.0 MB disk2s3

   4: APFS Volume VM 1.1 GB disk2s4

Having established a baseline of detected devices, insert the USB drive into a port on the macOS system and run the command again. The same results should appear with one additional entry for the USB drive resembling the following:

/dev/disk3 (external, physical):

   #: TYPE NAME SIZE IDENTIFIER

   0: *16.0 GB disk3

In the above example, the USB drive has been assigned to /dev/disk3. Before proceeding, unmount the disk as follows:

$ diskutil unmountDisk /dev/disk3

Unmount of all volumes on disk3 was successful

Finally, use the dd command to write the ISO image to the device, taking care to reference the raw disk device (/dev/rdisk3) and entering your user password when prompted:

$ sudo dd if=/path/to/iso/image.iso of=/dev/rdisk3 bs=1m

Once the image has been written, the USB drive is ready.

3.2.3 Windows

A number of free tools are available for Windows that will write an ISO image to a USB drive, but one written specifically for writing Linux ISO images is the Fedora Media Writer tool which can be downloaded from the following URL:

https://getfedora.org/en/workstation/download/

Once installed, launch the writer tool and select the Custom image option as highlighted in Figure 3-1:

Figure 3-1

In the resulting file selection dialog, navigate to and select the CentOS 8 installation ISO image and click on the Open button. After selecting the image, a dialog will appear within which the image can be written to the USB drive. Select the target USB drive from the device menu before clicking on the Write to Disk button:

Figure 3-2

Once the image has been written to the device, the device is ready to be used to perform the installation.