Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

TheHackersManual2015RevisedEdition

.pdf
Скачиваний:
55
Добавлен:
26.03.2016
Размер:
44 Мб
Скачать
☆
“The UEFI firmware can read partition tables and FAT filesystems”

Hardware hacks

Big disk

Hard disks have increased in size beyond what the MS-DOS partitioning scheme can handle. It can’t address disks larger than 2TiB because the partition tables store sector addresses as 32-bit numbers, and this means that there can’t be more than 2^32 sectors. Because

each sector contains 512 bytes, this gives a

therefore limited to 512 bytes – 446 bytes for the bootloader, and a partition table containing up to four 16-byte records. The last two bytes contain a signature that the BIOS uses to recognise a valid MBR. The partition tables use 32-bit sector address fields, which means they can’t address disks larger than 2TiB. This type of partition table is often referred to as an MS-DOS partition table in an attempt to differentiate it from the new GPT.

The problems with this configuration include being limited to one bootloader, the limitation of four partitions and the maximum 2TiB disk size. The UEFI supports multiple bootloaders, and the GPT supports up to 128 partitions and works with disks bigger than 2TiB. The other thing that UEFI brings to the table is the ability to secure the boot process.

Because the BIOS expects the bootloader to be located in the first sector of the disk, there

can only be one per disk. Most BIOSes allow selection of the boot disk and, therefore, can support as many bootloaders as there are physical disks. In contrast, UEFI ignores any bootloader in sector 0, but instead allows multiple bootloaders to exist on a single disk by using a special partition instead of an absolute sector. The special partition is known as the EFI System Partition, or ESP, and is formatted with a FAT filesystem (usually FAT32) and typically sized between 100MiB and 250MiB. The UEFI specification requires it to be the first partition and it must have its boot flag set. On a Linux system it’s customary to mount the ESP under /boot/efi. By convention, bootloaders are stored on the ESP in vendor-specific subdirectories, and the UEFI forum has a list of these sub-directories at www.uefi.org/specs/ esp_registry.

At the core of UEFI is its firmware, and it is responsible for loading and executing UEFI applications. These are standalone programs that depend only on the firmware’s services – they do not need an operating system. They can be pre-boot maintenance/diagnostic tools, but most are operating system bootloaders. The UEFI firmware contains a boot manager

maximum size of 2TiB. The new GPT partitioning scheme overcomes this limitation by using 64-bit fields, and these allow storage of 2^64 512-byte sectors, or 8ZiB (9.4ZB).

That is more than all the storage currently existing in the world. (http://tinyurl.com/dxvramm).

that enables the user to launch UEFI applications. A boot manager is similar to a bootloader, like Grub, except that it can only load EFI applications. It is possible to configure the Linux kernel (since 3.3) as an EFI application, and doing so can remove the need for a bootloader such as Grub because UEFI is then able to boot it directly.

The UEFI firmware can read partition tables and FAT filesystems, unlike the BIOS which relies on a bootloader. It is configurable via EFI variables that are stored in NVRAM. The main variable driving the EFI boot manager is called BootOrder and defines the menu items it displays. If it isn’t set, the firmware follows a standard procedure to locate a bootloader at a specific path on the ESP. The path, which is architecture-dependent, is of the form:

\EFI\BOOT\BOOT[architecture name].EFI

The G in GPT stands for GUID, which is a Globally Unique Identifier, an implementation of the Universally Unique Identifier standard defined by RFC4122. The GPT uses GUIDs to identify disks and partitions. It begins at sector 1 with a

header that defines the number and size of the partition records in the table that follows. The header contains a disk GUID that uniquely identifies the disk, and each partition defined in the GPT contains two GUIDs: the first represents the partition’s type and the second uniquely identifies it. The header also contains a CRC32 checksum that can be used by the firmware or operating system to verify data integrity. Don’t go manually editing your partition table!

The GPT can hold 128 partitions, and this removes the need for logical and extended partitions. The extended partition was a way to overcome the four-partition limit of the MBR. It allowed one of those partitions to be used as an extended partition that could be sub-divided into many logical partitions.

Each partition record is 128 bytes long and contains the GUIDs mentioned, the partition’s beginning and end sector addresses, some attributes and a human-readable name.

A second copy of the GPT is stored at the end of the disk as a backup. To accommodate 128 such partition records requires 16,384 bytes. This is 32 sectors, which means that the first usable sector on a GPT disk is sector 34.

A GPT disk contains two copies of its partition table, plus a protective MS-DOS partition table.

The GPT scheme also includes a master boot record, and its purpose is to help prevent corruption of a GPT disk by tools that are not GPT-aware. This Protective MBR, or PMBR, contains an MS-DOS partition table with one partition covering the whole disk (or 2TiB if the disk is bigger). This partition is marked with a type of 0xEE. Systems unaware of GPT will see an unknown partition occupying the whole disk and leaving no available space.

Another use of the protective MBR is to allow a BIOS to boot a GPT disk. If it contains a bootloader, the BIOS will blindly load and execute it. If that bootloader understands GPT, it can boot it. One such bootloader is Grub2, and is used by many Linux distributions. This allows BIOS-based systems to use disks greater than 2TiB.

MS-DOS partitioned disks usually leave a gap (known as the DOS Compatibility region), starting at sector 1 and running up to the beginning of the first partition. Bootloaders traditionally used this unallocated space to locate code (Grub 1 wrote its stage 1.5 loader here). With GPT, the partition table begins at sector 1, immediately after the PMBR – so there is no unallocated space to use in this way. Instead, the GPT specification provides for a special BIOS boot partition for use by boot loaders that would otherwise have used the DOS Compatibility region. Grub 2 writes

its bootloader directly on to that partition (it does not contain a filesystem). Given that the presence of the DOS Compatibility region was by convention rather than definition, having a specifically allocated partition is more robust.

So far,we’ve presented a lot of theory.We’ll now put that into practice to set up a new system based on UEFI and GPT.Our new system will dual boot: it will work with both UEFI and BIOS firmware.

UEFI | hacks Hardware

The Hacker’s Manual 2015 | 81

Hardware hacks | UEFI

Hardware hacks

We’ll use VirtualBox so you can follow along

Partition table

 

 

even if you don’t yet have a machine with UEFI

 

 

firmware. And we’ll use the November 2012

 

 

 

 

 

Arch Linux ISO – this means that you’ll need to

Number

Start

End

Size

Code Name

perform the setup manually, which will help

1

2048

411647

200.0MiB

EF00 EFI System

with understanding the necessary steps. Get it

2

34

2047

1007.0KiB

EF02 BIOS boot partition

from https://www.archlinux.org/download.

3

411648

821247

200.0MiB

8300 Linux /boot filesystem

First, create a new 64-bit virtual machine

4

821248

20971486

200.0MiB

8300 Linux /root filesystem

and hard disk for the test (10GB should suffice).

 

 

 

 

 

Ensure you check the ‘Enable EFI’ option on the

 

 

 

 

 

System page of the virtual machine’s settings

(parted) mkpart primary ext4 821248 20971486

# arch-chroot /mnt grub-mkconfig -o /boot/

to give the machine UEFI firmware. Attach the

(parted) name 4 “Linux /root filesystem”

grub/grub.cfg

ISO image and start the virtual machine. It

(parted) quit

 

 

# umount /mnt/boot/efi /mnt/boot /mnt

should eventually display a root prompt. Log in

We’ve used GPT partitioning but MS-DOS

This installs the system files on to the root

– there is no password.

partitioning can be used if the disk is smaller

filesystem mounted at /mnt. It also appends to

You need to create four partitions. You

than 2TiB – then omit the BIOS boot partition

/etc/fstab to cater for the additional boot and

can use gdisk to do this. The sizes are

and use fdisk to change the partition type of

EFI filesystems mounted underneath

suggestions sufficient for this exercise, but

the EFI System Partition to 0xEF. VirtualBox

/mnt (sed is used to get around a bug in

other values could be used. The ESP is created

UEFI firmware works with GPT or MS-DOS but

genfstab). We then install the grub package

from sector 2048 (the default offered by gdisk)

other firmwares may only support GPT.

and ensure that the efivars kernel module is

and the BIOS boot partition is put in the space

Make the filesystems and mount them:

loaded (it makes the EFI variables available

preceding the ESP. See the table for the

# mkfs.vfat -F32 /dev/sda1

 

under /sys/firmware/efi). Next, grub-install

suggested partition.

# mkfs.ext2 /dev/sda3

 

installs Grub into a new arch-grub subdirectory

Start gdisk with gdisk /dev/sda and then

# mkfs.ext4 /dev/sda4

 

of the ESP that we mounted at

use o to create a new empty partition table. Use

# mount /dev/sda4 /mnt

 

/boot/efi. If all goes well, it should respond

n to create a partition, t to set its type code and

# mkdir /mnt/boot

 

with “Installation finished: No error reported.”

(optionally) c to change its name. Write the new

# mount /dev/sda3 /mnt/boot

 

After that, we generate the Grub configuration

partition table with w. Or you can use parted:

# mkdir /mnt/boot/efi

 

file and unmount our filesystems from /mnt. If

# parted /dev/sda

# mount /dev/sda1 /mnt/boot/efi

you reset the virtual machine, it should offer the

(parted) unit s

Use the ArchLinux pacstrap utility to install

newly configured Grub menu and boot our the

(parted) mktable gpt

a new system on the prepared filesystems:

system.

 

(parted) mkpart primary 2048 411647

# pacstrap /mnt base

 

Part of the Grub setup configures the EFI

(parted) set 1 boot on

# genfstab -p -U /mnt | sed ‘s/cp437/437/’ >> /

boot order in the NVRAM. This would normally

(parted) name 1 “EFI System Partition”

mnt/etc/fstab

 

 

configure UEFI so that it automatically loads

(parted) mkpart primary 34 2047

# arch-chroot /mnt pacman -S grub-efi-x86_64

Grub when the machine is started. However,

(parted) name 2 “BIOS Boot Partition”

# modprobe efivars

 

VirtualBox does not persist the firmware

(parted) set 2 bios_grub on

# arch-chroot /mnt grub-install --target=x86_64- NVRAM after the virtual machine is stopped,

(parted) mkpart primary ext2 411648 821247

efi --efi-directory=/boot/efi --bootloader-

and this results in the boot settings being lost.

(parted) name 3 “Linux /boot filesystem”

id=arch_grub --recheck

 

If this happens, the EFI shell will be started and

The UEFI shell

One special UEFI application is the UEFI shell. It’s a basic command-line environment that you can use to launch EFI applications or do basic configuration and troubleshooting.

The firmware will drop you into the shell if there is no suitably-configured start-up sequence in place. The other way to get there is via the firmware’s menu interface in response to a special key. In VirtualBox it’s the [Del] key, but you will need to have quick reflexes! You can also hit c at the Grub menu to access the Grub prompt and then type exit. Two handy shell commands are help and bcfg:

> bcfg boot dump -v

will list the EFI applications listed in the boot manager. You can add/remove options or change their ordering. To add a boot option:

>bcfg boot add 3 fs0:\EFI\arch_grub\grubx64.efi “ArchLinux Grub”

and to move it up the list:

>bcfg boot mv 3 2

One last shell command worth remembering is reset, which resets the machine to start the

Access the shell via the firmware’s boot manager.

boot process from the beginning again. Boot options can also be managed from

within Linux through its efibootmgr command (root privileges are required). If, for example, your firmware doesn’t offer a shell, you could download an open source one from Intel’s Tianocore project, install it to a subdirectory beneath /boot/EFI and add a boot manager menu item to access it:

#mkdir /boot/efi/EFI/tiano

#wget https://edk2.svn.sourceforge.net/svnroot/ edk2/trunk/edk2/ShellBinPkg/UefiShell/X64/ Shell.efi

#efibootmgr --create --label ‘Tiano Shell’

--loader ‘\EFI\tiano\Shell.efi’

There is much more to the shell than this. It’s worth grabbing a copy of the shell specification from the UEFI forum (www.uefi.org).

82 | The Hacker’s Manual 2015

Hardware hacks

Partition types

GPT uses a GUID to identify a partition’s type in a similar way to the partition type field on an MS-DOS partition. You can use gdisk to change a GPT partition’s type – you can enter a GUID or use a short-code similar to those used in fdisk for MS-DOS partitions. These codes are specific to gdisk.

The related GUIDs are too unwieldy to list here but some of them are listed on Wikipedia (https://en.wikipedia. org/wiki/GUID_Partition_Table#Partition_type_ GUIDs).

The GUID originally used for Linux filesystem partitions is the same as the one that Microsoft uses (it’s called a basic data partition). To avoid any confusion that this might cause, a new GUID for Linux filesystems has recently been defined, but it may not yet be in use on existing systems.

you’ll need to manually launch the bootloader:

 

system will only boot something signed with

after the pre-bootloader, which makes this

2.0 Shell> fs0:\EFI\arch_grub\grubx64.efi

 

that key. Most new PCs are pre-configured in

approach no more secure than having UEFI

Once the OS has booted, to work around the

this way to gain Windows 8 certification.

secure boot disabled. It does, however, allow

lack of persistent NVRAM, you need to set up a

Machines with Windows 8 pre-installed will

Linux and other insecure operating systems to

default bootloader:

 

have secure boot enabled by default. You can,

be booted in a secure boot environment. This

# mkdir /boot/efi/EFI/BOOT

 

however, disable secure boot. At this time, the

solution is being provided by the Foundation as

# cp /boot/efi/EFI/{arch_grub/grub,BOOT/

 

most practical solution to the secure boot issue

an interim solution until distributions

BOOT}x64.efi

 

for Linux users is to disable secure boot.

implement fully secure solutions.

The firmware will fall back to EFI\BOOT\

 

However, some people may want or need to use

The Fedora Shim aims to go a step further

BOOTx64.efi if no boot order is configured, as

 

secure boot, and this requires having Linux

by enabling secure boot of a Linux system. It

will be the case with nothing in the NVRAM.

 

signed with a key that the firmware recognises.

loads a special version of Grub that contains a

This should result in a successful boot after

 

For Linux to secure boot, there are two basic

Fedora public key, and it will securely boot

starting the virtual machine. Now, to make the

 

options. The first is to get OEMs to include

kernels that can be validated with that key.

system boot on a BIOS, it is a simple matter of

 

additional keys that can be used to sign Linux.

It will also boot other kernels, but doing so will

also setting up the BIOS boot configuration:

 

The second is to sign Linux with the Microsoft

require a physical presence during boot.

# dhcpcd

 

key. There are, however, practical

Securely booted kernels will also restrict the

# pacman -S grub-bios

 

considerations which make both these

boot command line and require kernel modules

# grub-install --target=i386-pc --recheck /dev/

 

schemes unattractive.

to be signed. The shim is a way to securely boot

sda

 

Signing the Linux kernel is impractical, due

a pre-determined Linux configuration, but it still

Start by establishing network connectivity –

to its fast-changing nature and the fact that

proves difficult when customisations are

using dhcpcd is one way. Then install the grub-

many people build their own custom kernel. So

required. This would need a custom shim

bios package and install the BIOS version of

 

the approach is to use a signed bootloader

containing locally produced keys, which is

Grub to the disk. This will set up the boot code

 

which can then load any kernel image.

signed with a key recognised by the firmware.

in the master boot record and the BIOS boot

 

Examples of signed bootloaders include

How one would achieve this is not yet clear.

partition that we set up earlier. It uses the same

the Linux Foundation’s pre-bootloader and

Similar approaches are being taken by SUSE

Grub configuration file, /boot/grub/

“Signing the Linux kernel

and Ubuntu.

grub.cfg, that we set up before.

The signing mechanism for

Shut down the virtual machine and

secure boot is called Microsoft

change it from EFI to BIOS by

is impractical due to its

Authenticode, and is managed by

unchecking the ‘Enable EFI’ option on

Symantec (formerly VeriSign). For a

fast-changing nature”

 

the System page of its settings. When

 

$99 annual fee, you can sign as

the virtual machine is restarted, it will

 

 

 

many binaries as you wish, via the

boot through its BIOS. This example

 

solutions from distro-makers, like the Fedora

Microsoft Developer Center at

demonstrates that it is easy to install a system

 

Shim. By being signed with Microsoft’s key,

https://sysdev.microsoft.com (you’ll need

on to a GPT or MS-DOS partitioned disk that

 

these should work on any machine shipped

a Windows Live ID to sign in).

works under UEFI and BIOS. It is worth

 

with Windows 8. However, getting them signed

There isn’t yet a straightforward answer to

mentioning that the ride with some other

 

is proving difficult (http://bit.ly/VFEAV9).

the secure boot question. There are methods

distributions can be less smooth.

 

To avoid the potential for these solutions to

that allow working around the problem, but it’s

OK, let’s tackle the elephant in the room:

 

be used as a way for malware to affect secure

too early to know how easy it will be to run

secure boot. The gist of secure boot is that UEFI

systems, they all require a human user to be

Linux within a secure boot environment. If you

won’t load something that isn’t signed with a

 

present, who must confirm they wish to

feel strongly about this, you may be interested

recognised key. New computers with

 

proceed with an unsigned boot loader.

in the FSF’s campaign: (http://bit.ly/

Windows-8 pre-installed ship with a key from

 

The idea behind the Linux Foundation’s pre-

nHYBRN). And there is always the option of

Microsoft to allow their latest operating system

bootloader is to provide a signed loader, which

disabling secure boot – you’ll be no worse off

to boot securely. If such a system has secure

 

will chain-load another bootloader (like Grub)

than you are today. But you want to be running

boot enabled, and only has that key, then the

 

that then loads Linux. Secure verification stops

the machine of tomorrow, right? Θ

UEFI | hacks Hardware

The Hacker’s Manual 2015 | 83

Hardware hacks | Build a Linux PC

Hardware hacks

BUILD A LINUXPC

Making your own PC doesn’t just save you money, it ensures you get a machine that’s perfectly tuned to your needs. we shows you all you need to know.

84 | The Hacker’s Manual 2015

Hardware hacks

uying a ready-made machine on which to install Linux might

 

seem like the most convenient way to get up and running, but

 

you’re actually making a fair few compromises by going for a

 

Bshop-bought machine. The biggest compromise is price: you’re

 

paying a premium for someone to build the PC for you. This makes

 

sense for those of us who want to have a slightly easier life, but you also

 

get very little – if any – say on what components are used, so you could

 

be paying more for hardware you might not need. This brings us on to

 

the second compromise: the hardware. While there are some PC

 

manufacturers that let you customise your computer before you

 

purchase it, the personalisation options are often quite limited. This

 

means you’ll never have complete control over how well the machine

 

performs, and you may end up with a PC that’s fine for some tasks, but

 

not great with others. The final major compromise you’re forced to

 

make is one that we Linux users are all too familiar with: software. It is

 

still frustratingly difficult to buy a ready-made computer without

 

Windows – or Mac OS X, if you’re that way inclined – and a host of

 

irritating pre-installed bloatware. And while wiping the hard drive and

 

installing the distro of your choice is an unnecessary hassle, it also

 

means you ended up paying for an OS licence that you don’t want.

 

When building your own machine you don’t have to put up with these

 

compromises. You’re not paying for someone else to build it, or coughing up

 

for any premium branding – just having the name ‘Sony’ or an icon of an

 

apple stamped somewhere seems to up the price of a computer. Instead,

 

you’re able to shop around for each individual component to get the best

 

deal. Careful purchases can end up saving you hundreds of pounds.

 

Shopping around also helps you avoid the second compromise of fixed

 

hardware as you’re free to pick ‘n’ mix components to suit your needs

 

perfectly. Building a Linux box for working on documents, and have a NAS

 

device already? Then you won’t be needing a huge 4TB hard drive. However,

 

if you are a keen photographer, then a small capacity SSD will be pointless.

 

The same goes for graphics – both Intel and AMD’s onboard graphics

 

technologies are now so powerful that for day-to-day use you probably won’t

 

even need a separate graphics card. On the other hand, if you’re going to be

 

photo or video editing, you’re going to want a decent GPU, and if you’re

 

looking to play the latest games you may need something even more

 

powerful. If you’re going to be building and running a home server, then

 

dependable, low-powered hardware is the way to go. Finally, because you’re

 

building from scratch, you won’t find any pesky pre-installed operating

 

systems and you will be good to go with the distro of your choice.

 

Prime choice

 

The ‘choice’ word here is particularly important. One of the best things about

 

Linux, as well as free and open source software, is the enormous wealth of

 

choice. This enables you to run operating systems and software that

 

perfectly suit your needs – and if it isn’t a perfect fit, you can always work

 

with the source code to create your very own personalised tools. By building

 

your own PC, customising it and knowing intimately how it works, you will

2015

have a truly personal machine rather than one that’s ‘off-the-rack’. It can’t be

April

overstated how efficient it is to have both hardware and software that suit

 

your needs, and can stay relevant for a good few years.

publication

to put the wrong component into the wrong slot because of the different

It is sometimes thought that building your own computer is incredibly

 

complicated, but it’s actually surprisingly simple. For example, you’re not able

 

connections, and most motherboards come with instructions that are clear

of

time

and easy to understand. This is why we’re not including a step-by-step guide

 

here. The most important – and potentially most complicated – process

at the

about building your own PC is actually in the planning stage, in making sure

that all the parts are compatible with each other and you’ve got the right

correct

 

components for the job. We’ll show you everything that you need to build the

prices

awesome gaming PC, a media centre or a home server.

ideal computer for your tasks, be it a standard desktop machine, an

 

 

All

PC Linux a Build | hacks Hardware

The Hacker’s Manual 2015 | 85

Hardware hacks | Build a Linux PC

Hardware hacks

Build a desktop PC

Just need something for everyday use? Check this out.

Many people want a PC for simple, day-to-day computing. If you’re building such a machine then you’re going to need to perform a delicate

balancing act. There will be little need to have a flashy and expensive graphics card – as we mentioned earlier, the on-board graphics of the latest Intel and AMD processors will be perfectly fine for standard computing. There is also little need to install 16GB of the fastest available RAM. On the one hand, you’ll want to keep costs low by getting the bare minimum of components, but on the other hand it’s worth thinking about future-proofing your PC. What do we mean by this? Well, at the moment you may only need 4GB of RAM – if that. However, we are already seeing 8GB of RAM becoming increasingly common in modern computers, and you don’t really want to be opening up your PC’s case to upgrade it often. Buying less RAM might not even be as cost-effective as you think (see the Price of RAM box for more information).

Intel remains hard to beat when it comes to the best processors.

Price of RAM

For the vast majority of PC users, 4GB of RAM will be plenty for day-to-day tasks. However, 8GB of RAM is rapidly becoming the norm for new computers, and as distros and programs continue to increase in complexity, we may soon see a time when 4GB of RAM seems rather… quaint.

One of the biggest arguments for going with 8GB rather than 4GB is that 8GB of RAM will ensure that your PC isn’t going to go out of date any time soon, whereas with 4GB of RAM you may find yourself wanting to upgrade after a while. As well as being inconvenient, this could also cost you more money in the long run. DDR3 RAM

has been around for a long time now, and DDR4 isn’t too far off. This means that prices for DDR3 are about as low as they can go, and the price difference between a 4GB set and a 8GB set is a lot less than you’d imagine. The average price for a 4GB set of RAM is currently around £20-£25, whereas 8GB is around £35-£40, so the price per gigabyte works in favour of the larger set. If you can afford it, it’s well worth going for the larger set to future-proof your machine. If you are building a standard, everyday desktop, then we’d recommend the Crucial Ballistix 8GB, which at the time of writing can be found online for around £54.

Buying a modern motherboard means that you don’t have to worry about buying certain other components. In the past, we might have recommended purchasing a sound card, but pretty much any motherboard you buy these days comes with a perfectly good built-in audio solution. The exact same can be said for Ethernet network adaptors – you no longer need to buy a discrete network card for day-to-day computing, because your motherboard will come with one already. This means that you’re not going to need to cough up the cash to buy those extra components.

What processor?

So what do you need to buy? The first consideration is what processor to go for, as this will determine which motherboards you’ll be able to use due to the socket type it’ll use. As an aside all desktop processors are 64-bit these days (Intel Atom and older Intel Celeron processors are an exception) and you’ll need it as we’re going to suggest at least 4GB of memory. None of this is a problem as all distros also offer 64-bit builds.

So bearing in mind that you want a medium-powered PC for day-to-day tasks, we’d recommend going for an Intel Core i5-4570. This is a very capable processor that comes in at a pretty low cost (it’s available for around £140), thanks to the lack of more advanced features that Intel’s more expensive processors come equipped with. For example, the CPU multiplier of the Intel Core i5-4570 is locked, but because you’re not looking to overclock this processor to eke out every ounce of power, this won’t be a problem. Unlike the higher end Intel chips, it has four threads, rather than eight, and it does not support Hyper-threading. It is therefore not the best chip for professional video editing and 3D rendering – but you’re unlikely to need a standard desktop PC for such tasks. It is more than powerful enough for most undertakings, and the onboard graphics (Intel HD Graphics 4600) is absolutely fine for media, photo editing and even the odd game.

If you’re looking for a bit more grunt, and you have the budget for it, then the Intel Core i7-4770K is another excellent processor, though quite a bit more expensive at around £242. On the other hand, if you are trying to save some money, then the Intel Core i3-4130 is a good choice at £83. Interestingly, it actually has a higher clockspeed than the Intel Core i5-4570 (3.4Ghz compared to 3.2GHz), but it is only dual-core, whereas the i5 is quad-core. All of these processors use the LGA 1150 socket – more on that in a bit – which will make choosing a motherboard much easier.

You may have noticed that this section of the article has been a bit Intel-heavy; if you’d rather have an AMD-flavoured processor, then the A10-7850K is a great alternative. It has onboard AMD Radeon R7 graphics and costs around £135, which is a little less than the i5-4570. If you want this processor, you will need to find a motherboard that supports the FM2+ socket. All of the processors listed here should come complete with a heat sink and fan. While they won’t be much good if you’re a hardcore gamer or a keen overclocker, they will be absolutely fine for a regular desktop computer

86 | The Hacker’s Manual 2015

Hardware hacks

It’s hard not to recommend 8GB of system memory in terms of value,

performance and future proofing.

user and you won’t have to worry about buying an additional fan or heat sink, either.

The mother

Now you’ve settled on a processor, you can start thinking about the motherboard. The motherboard will determine quite a few important aspects of the PC you’re building, such as the size of the case and the amount of RAM that it can hold. If you’ve gone for one of the Intel processors we suggested, then you need to make sure the motherboard supports an Intel chipset and the LGA 1150 socket. For a standard desktop build we’d recommend the ASUS H81M-C motherboard. This might be a budget board but it offers everything you’ll need. With this board you get two DIMM slots for DDR3 RAM (up to a reasonable 16GB), built-in audio, four USB 3.0 ports, two USB 2.0 ports, a built-in network card, and HDMI, VGA and DVI ports for connecting monitors. Basically, pretty much everything you need. It comes with six SATA 3 ports, so you can add in plenty of hard drives. They are backwards compatible with older SATA drives, so if you have some old hard drives lying around you can still use them

– though if they have IDE connectors you’ll have to use an adaptor. If you need a new hard drive, then we’d recommend

the Western Digital 1TB drive. The capacity is adequate and has the standard disk speed of 7,200rpm. While solid state drives offer a bigger speed boost, their relatively limited capacity mean they aren’t really a worthwhile purchase for day-to-day computing.

You’ll also need a PSU (power supply unit) to power the components and the computer itself. We’ve selected components with relatively low power consumption, and as we’re not using a discrete graphics card, you’re not going to need a monster 1,000W power supply. However, if you want to expand your PC later on, it’s a good idea to buy a PSU with additional watts to what you’ll need. It’s also well worth going for a PSU that is dependable – you don’t want it breaking down or damaging your components – and with good power efficiency, as this PC will be getting lots of use. Don’t just buy the cheapest model available, and make sure you read customer reviews, which are a good indicator of the reliability of a PSU. For power efficiency, get a PSU that has an 80 Plus certificate. This means the PSU will only waste 20% or less of its energy as heat, reducing bills and noise levels.

You’ll want to make sure the PSU has the right type of connectors for your motherboard. All new PSUs have been ATX12V v2.31 compliant since around 2008 and if you opt for a system with modular cabling it’ll ensure it can adapt to your needs, though this tends to only be available on higher-end models. We’re recommending the Corsair CX500, which combines reliability, power and efficiency for around £46. For the case, you don’t need anything flashy. Any standard ATX case is going to do the job and can cost as little as £15, just don’t get one that includes a PSU.

Shopping list

Processor

Intel Core i5-4570

£160

Motherboard

ASRock Z87 Extreme3

£40

Memory

Crucial DDR3 8GB

£54

Hard drive

WD 1TB

£45

PSU

Corsair CX500M

£46

Case

ATX Mid Tower

£15

DVD Drive

Samsung DVD-RW

£11

Modular cabling ensures you get the power connections

Total:

£371

you need and reduces the spaghetti cable mess.

 

 

PC Linux a Build | hacks Hardware

The Hacker’s Manual 2015 | 87

Hardware hacks | Build a Linux PC

Hardware hacks

Build a gaming PC

Enjoy the surge in Linux games with your own custom system.

Only a few short years ago the idea of building a gaming PC filled to the brim with the latest components and then installing Linux on it would

have you burnt at the stake as a witch, or at the very least garnered you some disapproving head shakes from your gaming pals. These days an increasing number of high profile blockbuster games and indie titles are coming to Linux, encouraged by Valve – the games developer and company behind Steam, the digital distribution service – which has created its own Linux distro, SteamOS.

With companies like Crytek (Crysis and Far Cry series) and Epic (Gears of War and Unreal series) that both produce the high-end game engines that power many of the bigger releases – as well as developing graphically impressive games themselves – fully embracing Linux, gaming has never been in ruder health.

There are a number of reasons why you’d want to build a Linux gaming powerhouse. For a start, Linux is free, so you can put the money you would have spent on a Windows licence towards a more powerful graphics card – always a

The mighty Nvidia Titan is an exercise in pure 3D graphics performance.

popular option with gamers. Because Linux distros take up a lot less resources when running in the background compared to Windows, it also means that you’ll see much better results running a game in Linux.

So what do you need to take into account when building a Linux gaming machine? The mindset behind creating a gaming PC that can tackle all of the latest games at the best possible quality is quite different to when you’re building a standard desktop machine. You want the most power you can get for your money, and if you want to try your hand at overclocking, you’re going to want components that let you squeeze out every last drop of power. This means that you’re going to be looking at spending quite a bit more, and sometimes overlooking cheaper components for more expensive ones.

Planning your machine

Having said that, the base of our gaming machine is some what different to that of the desktop PC. The ASRock H97M Pro4 motherboard is an excellent choice, thanks to its excellent price and support for some of the latest technology. In our benchmarks it also performed incredibly well for memory bandwidth and overclocking performance. The Intel Core i5-4570 processor we suggested on the previous pages is also a perfectly fine choice, though it does not support overclocking. This will be fine for most people, but if you want some additional leeway in getting the most performance for your money, then the Intel Core i5-4670K offers not just a faster base clockspeed (3.4GHz compared to 3.2GHz), but it’s also able to be overclocked to around 4.5GHz – offering a pretty decent boost in performance for free. Although the Intel Core i5-4670K comes with a fan for keeping it cool, unlike the desktop PC, this won’t be enough. The processor is going to be getting a lot hotter during use, because of the intensive nature of games and especially if it is getting overclocked, which means we’ll need a different cooler to

Performance parts

If you want the best performance out of your gaming PC, then you’re going to want to splash out on the fastest kit you can afford. When it comes to RAM, it’s less about the amount (8GB is still more than enough for gaming), but more about the frequency and latency of the RAM. If you decide to use the suggested ASRock H97M Pro4 motherboard, it supports dual channel DDR3 RAM with four slots, so we’ll want a set of RAM that comes in either two or four sticks (eg. two sticks of 4GB).

The frequency of RAM can be between 800MHz to 3,000MHz, with our motherboard supporting an overclocked frequency of 2,933. For gaming purposes, we don’t need much over 1,600MHz. The faster the RAM, the more latency occurs, so this is a good trade off. Faster RAM

also produces more heat, which in turn requires RAM sticks to include large heatsinks. These can end up causing problems if you have a large CPU cooler, as you may find it doesn’t fit. The HyperX Fury memory ticks all these boxes, and comes at a decent price at around £54.

The most important part of a gaming machine is the graphics card, and the most expensive – however it may be worth paying more to keep your PC relevant for the near future. The most powerful single card graphics card on the market today is the Zotac GeForce GTX 970, which has a huge 4GB of GDDR5 memory with a 384-bit interface and bandwidth of 3,36GB/sec. This is a card that’s going to be futureproof for a long time, and is the one to get if you want the ultimate graphics card. It comes at a price,

however, at just under £500. This will be beyond most people’s budgets, and certain aspects of the card, such as the 4GB of GDDR5, will not be fully exploited by even the most demanding games, especially if you’re only going to be running one monitor. When 4K displays become the norm, however, that GDDR5 will be vital.

For a more realistic budget we’d recommend going for the AMD Radeon R9 290. Though the price tag is still nothing to be sniffed at (around £220), it compares favourably with Nvidia cards that are almost twice the price. All these highpowered parts are going to need plenty of air flow to keep them cool, so a nice big chassis with plenty of built-in fans will do the trick, and we suggest the Corsair Carbide 200R as it fits the bill nicely, for around £50.

88 | The Hacker’s Manual 2015

Hardware hacks

Gaming processors

We’ve once again gone for Intel processors for the gaming build. This isn’t due to any bias on our side (or money bags stashed under our desks) but because Intel processors have generally been ahead of AMD’s offerings, though AMD is gaining ground again.

Intel’s current crop, the fourth generation of Intel Core processors, boasts excellent speeds that benefit gamers. By the time you read this a brand new range of fourth generation processors

(codenamed Devil’s Canyon) should be available to buy, offering speed increases on the previous Haswell processors, for the same price. While the top of the range fourth gen processors have the i7 moniker, we’re recommending the i5 variant. This is because the main difference between the i7 and i5 processors is that i7s support Hyperthreading, and come with more threads in total (eight as opposed to six). This makes i7s great for intensive multitasking, such as video

encoding, but for gaming there is very little benefit – certainly not enough to justify the additional cost. It can be argued that the larger cache of an i7 processor (8MB compared to 6MB of an i5) is more important, but again with gaming you’re not going to see massive differences, which is why we recommend choosing an i5 processor and save your money – or even put it towards a better graphics card, which will definitely have more of an impact.

keep healthy. There are two main options here; air cooling and water cooling. Air cooling usually consists of big heatsinks and fans that sit over the processor. The pros of an air cooling system is that they are usually cheap and easy to install, with the cons being that they can be bulky and noisy.

Water cooling systems, on the other hand, use water to transfer the heat from the processor to a radiator situated elsewhere in the computer’s chassis. The benefits of water cooling is that they are more efficient and quieter than air coolers, and can also be less bulky and more flexible. The cons are that they can be more fiddly to install, and a bit more expensive. However, you can buy self-contained water cooler systems that come ready-prepared with coolant, so installation is pretty straightforward. While you might not be too keen on the idea of pumping liquid past your expensive electrical components, self-contained water coolers are perfectly safe and reliable. The choice of what to go for depends on how big your PC case is, how quiet you want your PC to be, how far you’re wanting to push your components and your budget. If you’re not going to be overclocking and you don’t mind a noisy PC, then air cooling will be a good choice, but if you want a quieter machine that’s better at keeping cool, then water cooling is the way to go.

You’re also going to want to get a dedicated graphics card

– and the one you go for depends on how well you want your gaming PC to run the latest and most graphically intense games. You can pay as little as £60 for a graphics card all the way to just shy of £1,000, so think carefully about what it is that you want from your machine.

Drivers and software

Historically, one of the biggest stumbling blocks for seeing significant growth in Linux gaming has been getting 3D graphics drivers to work. These drivers would at best be

proprietary, and at worst non-existent. Happily, there’s always been a dedicated community beavering away at open-source alternatives, which usually contain many of the same features as

the official drivers. Many distros also make it easy to choose between a proprietary and open source driver option, depending on your preference. In Ubuntu, for example, and its derivatives, you can find this by opening up System Settings, then clicking on Software & Updates. In the Ubuntu Software tab, click Proprietary Drivers for Devices to enable those drivers. Click the Additional Drivers tab to see what drivers are installed, and if any of them are proprietary.

If you’re using an Nvidia card, then the default drivers should be the open-source Nouveau drivers, which have been created by reverse engineering Nvidia’s proprietary graphics drivers for Linux. Though Nvidia has been far from a darling of the open source world, it has won plaudits by contributing to the open source driver recently. This should mean that there’s a better chance of feature parity between the open-source and proprietary drivers, which means there’s less cause to use the latter. You can find out more about Nouveau at http://nouveau.freedesktop.org. If you’re using an AMD graphics card, then the open source drivers should be installed by default as well. The proprietary drivers (known as Catalyst/fglrx) can be installed from the package manager. Note: make sure you uninstall and purge the old drivers first.

As far as the best distros go, although much has been made of Valve’s new game-centric distro SteamOS, it is still in its early days, so we’d hesitate to recommend it if you also want to use your PC for other day-to-day tasks. It’s worth keeping an eye on for the future, though. For the most compatible, and hassle free, experience, we’d recommend a Debian derivative, with Ubuntu or Mint being the best bet.

Proprietary drivers continue to plague GNU/Linux distros and will do for some time to come.

Shopping list

Processor

Intel Core i5-4670K

£192

Motherboard

ASRock H97M Pro4

£70

Memory

HyperX Fury 8GB

£54

Graphic card

AMD Radeon R9 290

£220

Hard drive

WD 1TB

£45

PSU

Corsair CX600M

£53

Case

Corsair Carbide 200R

£46

CPU cooler

Coolermaster Seidon 120V

£35

 

Total:

£715

PC Linux a Build | hacks Hardware

The Hacker’s Manual 2015 | 89

Hardware hacks | Build a Linux PC

Hardware hacks

Build a media centre

A stylish way to enjoy all your videos and music in the living room.

If you fancy building a PC that can sit unobtrusively in your living room and serve you all the media your eyes and ears can handle, then you’ll be pleased to know

that it’s extremely easy nowadays, and with a few choice distros you can create an excellent media machine that can be used comfortably with a TV.

While building a gaming PC is mainly about being big and brash, creating a decent media PC is a bit more nuanced affair. You don’t want powerful components – in fact in some cases you’ll want the opposite, as you’re going to be making a small machine that’s on for very long periods and that operates as quietly as possible, which means you don’t want to be generating much heat. Unless you don’t mind a big beige box sitting in the corner of your living room, then you’ll

Kodi (XBMC) is up to version 14, which is lucky for everyone.

want an attractive and compact case. Luckily, we’re spoilt for choice with small-form factor Micro-ATX chassis as they’ve become increasingly popular as integrated components have become more powerful and power efficient. We’ve gone for the Antec ISK310-150 Micro-ATX case as it’s compact and looks great.

Because of the format’s small size, it can be a bit fiddly, so if you want a bit more space and flexibility, we’d also recommend the Antec ISK 600. The Antec ISK310-150 MicroATX case comes with a built-in 150 watt power supply, which means that’s one less thing to worry about. The fan speed on the PSU can also be changed to make it as quiet as possible, though you’ll want to keep an eye on temperatures.

Perfectly formed parts

Because of the size of the chassis you’ll also need to choose an mini-ITX form factor motherboard. For this build we’d recommend the ASRock FM2A88X-ITX+, because not only does it have a compact design, but it also includes some pretty handy features for a media PC. It comes with not just a HDMI out port for connecting to a high definition TV, but also a HDMI in port for connecting other devices to it, particularly useful if your TV only has limited HDMI ports.

The motherboard also comes with built-in wireless 802.11n antennas, which gives you a bit more flexibility when placing the PC. This motherboard supports the FM2+ socket, as we recommend getting the AMD A8-7600 processor, thanks to its excellent onboard graphics, which keeps both the cost and the power consumption down. While a liquid cooler to keep the processor’s temperatures down is an ideal solution for a media PC, thanks to its relatively quiet performance, if you’re going for a small case then there probably won’t be enough room. If that’s the case, then the

Media playing distros

Unlike some of the other systems that we’ve covered that you can build yourself, the software that you can install on media PCs is just as important, if not more so, than the hardware you decide to install in it. There are a number of lightweight distributions that have been created especially for media PCs. The idea behind these are to offer a simple, yet elegant operating system that gives you easy access to your media through an interface that has been tailor made of use on TVs.

The most popular software is Kodi (http:// kodi.tv aka XBMC), which was once a media centre program for the Xbox console, but is now a fully fledged open source media player in its own right that can be installed on a wide variety of platforms. The distro comes with a number of excellent features including UPnP compatibility, which lets you stream media to and from other network connected devices, along with PVR,

music and movie support. Add-ons can also be installed to expand the functionality. As XBMC is installed as a standard distro, you can also use your media PC for day to day tasks as well. However, if you want it to be a dedicated media player, then it is worth giving XBMCbuntu a try.

As the name suggests it is an Ubuntu-based distro that has XBMC already installed and configured. It is designed to be as lightweight as possible, enabling you to boot up and begin watching media as quickly as possible. It comes as a live CD so you can give it a try before you install it, and you can find out more at http:// bit.ly/lxfxbmcbuntu.

Plex is another popular media centre and comes in two flavours: Plex Home Theater can be installed on machines hooked up to a TV and can play both local and remote media, while the other version: Plex media server can be installed on remote computers and NAS devices to

organise and stream your media to other connected devices. Though originally a fork of XBMC, Plex now has taken on a life of its own and can be found on many Smart TVs and set top boxes, and uses a number of closed source and proprietary technologies. Though Plex Home Theater doesn’t have an official Linux version at the moment, there are builds available for certain distros, which you can find out more about at http://bit.ly/lxfplex.

An up and coming media centre distribution that we’re rather fond of at Linux Format is OpenELEC (which stands for Open Embedded Linux Entertainment Center). This is a lightweight Linux distribution that’s been built from scratch with media playing in mind. It’s also based on XBMC and is extremely easy to set up and can be installed on a whole host of hardware configurations, including, of course, the ridiculously popular Raspberry Pi.

90 | The Hacker’s Manual 2015

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]