Kako je instalacija Arch Linuxa vratila moj stari laptop u život

Imate staro računalo koje je presporo za pokretanje Windowsa? Nemojte ga baciti ili prodati. Instalirajte Linux na njega.

Nikad niste koristili Linux? Jako je zabavno, sve dok ste spremni učiti i petljati.

Imajte na umu da ako ne uživate u prtljanju, stolni Linux možda nije najbolji operativni sustav za vas.

Operativni sustavi Windows i macOS čine da sustavi rade sporije tijekom vremena. Aplikacije postaju složenije jer se prilagođavaju zahtjevima za user-friendly značajkama.

Windows 10 je na ovom planu bio bolji. Microsoftov cilj da ima univerzalni OS na stolnim računalima, tabletima i mobilnim uređajima potaknuo ih je da zadovolje potrebe strojeva s nižim specifikacijama.

Ali nisam siguran ima li Apple taj isti cilj. Novi MacBook Pros sporiji su od mnogih strojeva koji imaju trećinu cijene. Mnogi su se korisnici požalili da El Capitan i Sierra troše više resursa nakon što su nadogradili svoj Mac operativni sustav.

To u biti nije loše. Volim brigu o povećanju upotrebljivosti mog Maca. Volim kako brzo radi moj Windows 10 stroj i koristim Windows od svoje sedme godine. Smatram se osobom koja koristi Windows.

Čuvajte se fanboyhood-a. Uvijek ostanite otvorenog uma. Glupo je držati se bilo kojeg od ovih operativnih sustava. Život ima više od računala koje koristite.

Ali planirano zastarjevanje znači da ljudi bespotrebno bacaju stare Macove i Windows strojeve. Prespore su za upotrebu i na njih se ne može instalirati novi softver.

Prije nekoliko tjedana pokrenuo sam svoj MacBook iz 2008. i odbio je instalirati Chrome. Ne bih ga ni dodirnuo teglenicom. Nije cool!

Međutim, sada pišem s Acerom Aspire 5735 iz 2009. godine. Ima Core 2 Duo procesor, s dvije jezgre na 2,0 GHz. Ima 4 GB DDR2 RAM-a i HDD od 500 GB. Instalirao sam potpuno novu bateriju, ali zasad je to jedina nadogradnja hardvera.

Koristim najnoviju verziju preglednika Google Chrome. Trenutno imam šest otvorenih kartica i još nisam doživio neko veće usporavanje. Također ima najnovije verzije PhpStorm i DataGrip.

U vrijeme kad mi je otac kupio ovaj laptop, bio je vrlo popularan. Svidjelo mi se. Bio je to stroj s visokim specifikacijama i jako je dobro radio. Tek sam započeo sveučilište i ovaj mi je stroj pomogao u učenju. A u moje slobodno vrijeme dobro je služilo za pregledavanje i konzumiranje medija. Bio je to fantastičan prijenosni radni stroj pet godina.

Nema mi smisla da je upravo umrlo. Nisam na njemu igrao zahtjevnije igre, samo sam želio biti produktivan na njemu.

Želim e-poštu, želim pregledavanje, želim PhpStorm i DataGrip na svom prijenosnom računalu. S Linuxom sve te stvari mogu raditi s lakoćom.

Još je bolje što moju aktivnost ne prati korporacija. Moj operativni sustav ne sluša mikrofon 24 sata dnevno, 7 dana u tjednu i ne pohranjuje podatke u skladište podataka izvan zemlje.

S Linuxom imam slobodu i privatnost koliko god želim.

Instaliranje Linuxa na vaš laptop također je suludo jednostavno. Pokazat ću vam kako to učiniti za samo sekundu.

Imajte na umu da Linux pokreće najveće poslužitelje, najpopularnije programe i najvažnije usluge na svijetu.

Ali on također pokreće sve Android pametne telefone. Iako su mobiteli svake godine sve moćniji, oni nisu toliko moćni kao moderna računala. A Android radi vrlo glatko na većini modernih telefona.

To je zato što je Linux jednostavan. Koristi manje resursa i ima bogatu zajednicu programera koji žele jedni drugima pomoći.

Ako je Linux dovoljno dobar da pokreće najvažnije usluge na svijetu, dovoljno ga je koristiti za pregledavanje feeda vijesti na Facebooku.

Arch Linux

Za svoju instalaciju odabrao sam Arch Linux. Ovo nije distribucija za one koji slabe srce.

Instalacijski program Barebones za Arch ne temelji se na GUI-ju, pa čak ni na tekstu. Čisto koristi naredbeni redak.

To mi se ipak sviđa. Instalacija OS-a na ovaj način pomaže mi da razumijem njegov unutarnji rad.

Na radnoj površini imam Ubuntu 16.10 “Yakkety”, a instalirati ga je bilo jednostavno. Preuzeo sam ISO, spalio ga na USB, priključio na računalo, pokrenuo s USB-a i slijedio jednostavne upute.

Ubuntu je daleko najmekši uvod u Linux. Preporučujem ga osobama bez iskustva izvan Windowsa ili čak MacOS-a, jer će biti najpoznatiji ljudima.

Kad dublje zaronite u Linux, isprobajte različite stvari i naviknite se na terminal. Shvatit ćete zašto mi se sviđa instalacijski program Arch.

Nisam koristio tekstualni instalacijski program Arch “Anywhere”. Upravo sam koristio naredbeni redak.

Iako su Arch često nazivali "horor igrom zasnovanom na tekstu", stvarnost je da je nevjerojatno jednostavna za instalaciju. O tome kako unutarnji dijelovi zapravo rade saznat ćete kasnije u ovom članku.

Prema zadanim postavkama ne dobivate okruženje radne površine. To je čisto naredbena linija. Ovo je prema dizajnu. Arch je namijenjen jednostavnom barebones Linux sustavu.

Arch izaziva ovisnost. Počinjete bez ičega i instalirate softver po potrebi.

Suprotno tome, Ubuntu je suptraktivan. Počinjete sa svime što bi vam moglo zatrebati i smanjujete dok ne dobijete lakši sustav.

Nijedno od njih nije "u pravu". Svaka jednostavno odgovara različitim ljudima i slučajevima korištenja. Jedini "pravi" OS je OS koji vam najbolje pomaže u radu i igranju.

Ipak, opet je nevjerojatno jednostavno instalirati okruženje radne površine na Arch. Doslovno su potrebne dvije naredbe i ponovno podizanje sustava da biste instalirali operativnu radnu površinu.

A budući da želimo sustav koji možemo koristiti, zasigurno ćemo htjeti radno okruženje. U svojoj instalaciji odabrao sam Gnome 3. Sviđa mi se njegov izgled. Iako je poznato da je težak resurs, uživam u izazovu. Mislim da je moj laptop dorastao tome.

Započnimo.

Kako sam instalirao Arch Linux na svoj laptop

Sada ću objasniti kako sam instalirao Arch Linux na svoj laptop.

Možete slijediti ako želite. Samo pripazite da će to izbrisati sve podatke s tvrdog diska vašeg računala. Učinite to samo ako ste potpuno sigurni da to želite, zato napravite sigurnosnu kopiju važnih podataka na drugom računalu. Svakako nemojte brisati podatke na uređaju koji nije vaš!

1. Izradite USB instalacijski program

First, I downloaded the official Arch Linux ISO from their website. I decided on the 64-bit version.

On my Windows 8 tablet, I used a program called Rufus. It allowed me to burn the ISO to a USB stick.

If you want to try this, you’ll need a USB stick with enough memory to hold the OS at least. You can buy an 8GB USB stick, which is more than enough space, at a very cheap price nowadays.

And if you’re on a Mac, you won’t be able to use Rufus, but you can use UNetbootin, which is highly rated.

Then once inside Rufus, I chose the USB stick from the list of drives. I chose the ISO image from my downloads folder, and selected Start to begin the burning process.

Warning:If you do this, it will delete everything on the USB stick.

When the process finished, I had a bootable USB stick.

2. Boot from the USB stick

I rebooted the laptop, plugged in the USB stick, and entered the BIOS. I changed the boot priority so that the USB drive controller is at the top. Then I exited the BIOS and the computer rebooted.

I was greeted by the GRUB boot loader, which took me to the Arch Linux terminal. It’s a weird, limbo-like place where you’re using the USB stick as the OS and the main filesystem. Many people actually plug the USB stick into their computer to have a portable operating system.

3. Check the network

Plugging in an Ethernet cable to my router allowed me to have internet access. I checked that the internet was up, with the code

ping google.com

This resulted in successful pings that returned a response.

The internet was a-OK!

The Ethernet is the simplest and most secure way to connect to your internet source provider. Most old laptops have an Ethernet port. I chose not to configure Wi-Fi until I had installed the Gnome desktop environment because it would be easier.

4. Partition the hard drive

At that time, I still had Windows Vista installed on the laptop’s main hard drive. To install Linux, I had to format the hard drive.

But first, I needed to set up the partition table. This, among other things, tells the boot loader which part of the hard drive is bootable.

To view the partition table, type

fdisk -l

I wanted two partitions on the main hard drive:

  • /dev/sda1, the primary bootable with 457GB of space
  • /dev/sda2, the primary swap space with 8GB, or double the RAM

Allocating double the RAM to swap space is a good idea for older machines with less RAM. Linux will put unused memory into the swap space to free up RAM for more immediate tasks.

I typed this into the terminal to action the partition:

cfdisk

This program provides a user interface for creating and managing partitions.

It should look something like this:

I highlighted the existing partitions and selected DELETE. Then I selected NEW and entered 457G as the space, marking it as primary.

Next, I selected BOOTABLE on that partition.

Then I selected the FREE SPACE in the line below, clicked NEW again, and created the swap partition with 8G of space. This was double the laptop’s RAM, marking it as primary. Linux should automatically recognize this as swap space.

I then selected WRITE and typed yes to confirm. This installed the new partitions.

Warning: Beware if you do this yourself. This might erase data and will definitely mess up your existing installation. So only follow this if you’re committed to trying out Arch Linux.

To verify the partitions, type

fdisk -l

5. Format the partitions

I created the primary partitions, but they weren’t formatted yet. I used this command to format the main partition as EXT4:

mkfs.ext4 /dev/sda1

Then to format and activate the swap partition:

mkswap /dev/sda2swapon /dev/sda2

The hard drive has been completely formatted, and the swap partition activated.

6. Installing the base Arch Linux system

To install the Arch Linux base system, I mounted the laptop’s new primary /dev/sda1 partition onto my USB’s filesystem.

Remember that the USB is acting as “the computer” in this situation. Unix system have one tree for the filesystem. It doesn’t matter if it’s running off a USB stick or an RPi or a powerful server, all Unix systems are like this.

Mounting a drive into the filesystem is sort of like docking a filesystem onto the main one. We’re temporarily “plugging” the hard drive’s primary partition’s filesystem into the USB’s filesystem.

mount /dev/sda1 /mntpacstrap /mnt base base-devel

This didn’t take too long, but I did have time to make myself a cup of tea and check my emails on my tablet.

When it was done I patted myself on the back, and ran the next command to create the fstab. This is a file which contains information about the system’s partitions.

genfstab /mnt >> /mnt/etc/fstab

The file can be read to verify:

cat /mnt/etc/fstab

7. Configure Arch Linux

I needed to log into the new Arch Linux install to configure a few things. I needed to set the root password and time zone, and create my user account.

arch-chroot /mnt /bin/bash

Then I edited the locale file:

vi /etc/locale.gen

I found my locale en_GB.UTF-8 and uncommented it. Then I pressed ESCAPE and typed :x to write and exit the file.

To activate the locale, I entered:

locale-gen

Next, I created another locale file:

vi /etc/locale.conf

I added the following line and saved the file as above.

LANG=en_GB.UTF-8

Then I set the correct time zone.

In the UK we have a variable time zone. In the summer we use British Summer Time (BST), which is one hour ahead of UTC. The rest of the time we’re on Greenwich Mean Time (GMT), which is the same as UTC. It will probably be simpler for you if you’re elsewhere in the world.

To find the right time zone, I entered:

ls /usr/share/zoneinfo/

I saw GB and knew that was the right one. The system will automatically adjust to BST/GMT when necessary. So to set this as the system’s time zone, I entered:

ln -s /usr/share/zoneinfo/GB /etc/localtime

8. Configure passwords and user account

The system logged me in as root. To enter the root password for later logins, I typed:

passwd

It then prompted me to type my password and to confirm it.

Then it prompted me to create my user account:

useradd jonmkdir /home/jonchown -R jon:jon /home/jon

Then I typed:

passwd jon

I typed my password for my account as I did with root.

My account was created, but I couldn’t do very much. I had no permissions. I had to create the “sudo” group and add my user to it.

groupadd sudousermod -aG sudo jon

To ensure the sudo-ers group had the right permissions:

vi /etc/sudoers

Then I uncommented this line and saved the file:

# %sudo ALL=(ALL) ALL

Now I was able to use the sudo (pronouned “soo-doo,” short for “super user do”) command as my user, so I could install new packages and access restricted parts of the filesystem.

9. Configure the network

Now I needed to set the laptop’s hostname in two files: /etc/hostname and /etc/hosts. So I ran the next command and typed laptop:

vi /etc/hostname

Then I entered the host’s file:

vi /etc/hosts

At the bottom I typed the following line:

127.0.0.1 laptop

This told my system to route all requests for the hostname laptop to itself.

The network still didn’t work as planned, so I needed to activate it. I did this by typing:

systemctl enable dhcpcd

10. Install GRUB bootloader onto the hard drive

We’re almost done! Now I needed to install GRUB loader onto the new Arch Linux system, so that it could boot from the hard drive.

To do that, I ran these commands:

pacman -S grub os-probergrub-install /dev/sdagrub-mkconfig -o /boot/grub/grub.cfg

If the first pacman command doesn’t work, try this command to synchronize the system’s core database:

pacman -Ssy

I then exited from the hard drive’s system and back into the USB:

exit

And then I unmounted the hard drive’s filesystem from the USB:

umount /mnt

And that’s it!

The hard drive had a fresh Arch Linux install ready to use. So I rebooted the laptop and unplugged the USB stick.

This then booted successfully into the terminal, but this time it was on the hard drive’s new Arch system, not on the USB stick.

11. Install the Gnome desktop environment

We have the new operating system, but it was still 100% terminal. I want a desktop environment to interact with my laptop, so I can browse web pages, read documents, and use modern apps.

There are many desktop environments for Linux. I chose Gnome because I like it, but if I wanted to, Linux allows the installation of more than one desktop environment.

Luckily, it only takes one command to install the Gnome desktop ennvironment:

pacman -S gnome

It prompted me a few times to check which versions of extra packages I want. I just clicked ENTER to select the defaults.

So the Gnome desktop environment is installed, but the system doesn’t know to load it at the boot. So I typed this to ensure it did:

systemctl enable gdm.service

This sets up the symlink, and we’re ready to reboot the laptop into Gnome!

reboot

Then when the laptop booted, it loaded Gnome, and I was able to log in with my new user account.

The system was now ready for me to use. It was far from complete though, because I wanted to install some of my favourite programs:

  • Fish shell, it makes the terminal much faster and easier to use
  • htop, for system activity monitoring
  • Git, for installing packages via the AUR and for work
  • Google Chrome, it’s my favourite browser
  • Spotify, so I can listen to my favourite tunes!
  • PhpStorm, so I can work
  • DataGrip, so I can access my databases

With Linux, and especially Arch, we can’t just download an installer or a .dmg file like we can on Windows or macOS. We need to use both of Arch’s installer programs to install them. So let’s learn how to do that!

How to install programs on Arch Linux using pacman and the AUR

Installing programs on Arch Linux might seem tricky at first. It was tricky for me the first time too, even though I had experience with Ubuntu Linux.

Arch uses pacman, short for package manager, and the Arch User Repository (AUR) to install programs.

Installing packages via pacman is super easy. To install the fish shell, htop, and Git, I just used:

sudo pacman -S fish htop git

Installing via the AUR is trickier, especially if you’re newer to Unix-like systems.

We’ll install the Google Chrome browser and Spotify to show you how to do this.

First, make sure that build essentials are installed:

sudo pacman -S file base-devel abs

Go into your user’s downloads folder:

cd ~/Downloads

Go here and copy the Git Clone URL.

Then run the following command:

git clone [the Git Clone URL]

Then entercd into the google-chrome directory that it just created, and run the following command:

makepkg -Acs

This may take a while, depending on your system.

Time for another cup of tea!

Once that’s done, install the package. The makepkg command should create a file with the file type pkg.tar.xz. Install this package by using the -U option with pacman.

sudo pacman -U x.pkg.tar.xz

Replace x.pkg.tar.xz with the name of the actual file. It will be a long, scary filename. Just copy and paste it into the command above.

That’s it!

Now in Gnome, if you hit the super key (Windows key on a Windows machine), type Chrome and the Chrome app icon should appear on the screen. Super easy!

We can use the same commands for every other AUR package we want to install. We can certainly do the same for Spotify by using the URL here.

Remember, these are the steps to install programs from the AUR:

  • Find the package’s Git clone URL here.
  • git clone [the URL]
  • cd [package name]
  • makepkg -Acs
  • sudo pacman -U x.pkg.tar.xz

Yaourt

An easier way to install AUR packages is using Yaourt. It allows you to automatically install from the AUR with one line, much like pacman.

Open up /etc/pacman.conf and add the following lines of code to the bottom:

[archlinuxfr]SigLevel = NeverServer = //repo.archlinux.fr/$arch

Then, in the terminal run this:

sudo pacman -Sy yaourt

Now you can install any package using Yaourt. The usage is similar to pacman:

yaourt  [options] [packages]yaourt 
yaourt -Syu # Updates the Arch systemyaourt -S  # Install a packageyaourt -U  # Upgrade a packageyaourt -R  # Remove a packageyaourt -P  # Install from a PKGBUILD in the directoryyaourt --stats # Show stats on all your packages

I hope I have shown that it’s easier than it looks to use the AUR. It’s super easy to install with pacman too.

I thought it was important to share Arch’s core skills, because with Arch, very few programs are pre-installed. So you’ll need to use these core skills a lot if you want to install the programs you need.

That is what I like about Arch Linux. You can create the computer you want, instead of just being given a bloated system that has more than you could possibly want or use.

That is also why Arch Linux is perfect for older laptops and PCs. It is so lightweight that it runs below 5% CPU with multiple programs on at the same time. Here’s a screenshot of my laptop’s desktop with htop:

Yes, I love 90s music. Sue me! It was one of the best decades for music!

I chose the Gnome desktop environment as well, which many experienced readers will notice is quite heavy as far as desktop environments go.

That’s true. I took a gamble by using it over a lighter DE like XFCE4.

But I’m used to the Ubuntu Unity desktop environment, which is similar to Gnome. I like that it is so user-friendly. It does come with a lot of packages that XFCE leaves out.

And as you can see from the screenshot above, it didn’t take a toll on my 2009 laptop.

I’d call this project a success.

Those are all the steps I used to install Arch Linux on my laptop. I hope it helps if you’re thinking of installing a new OS on your old laptop or old PC.

Now I have one question for you.

What do you think of this post? I’d like to hear your thoughts.

Did you try to do this install? Awesome. I’d love to hear about your experience.

Hit the comment button below, and write your thoughts so I can read them.

I have another quick question for you, since you’re probably a developer if you’re reading this.

Are you making the most common mistakes that most developers make in SQL queries? Want my 2-step algorithm on the perfect index?

Download my free report, MySQL Worst Practices.