Hvordan installation af Arch Linux bragte min gamle laptop tilbage til livet

Har du en gammel computer, der er for langsom til at køre Windows? Smid det ikke eller solg det. Installer Linux på det.

Har du aldrig brugt Linux? Det er meget sjovt, så længe du er villig til at lære og at tinker.

Bemærk, at hvis du ikke kan lide at tinkere, er desktop Linux muligvis ikke det bedste operativsystem for dig.

Windows- og macOS-operativsystemerne får systemer til at køre langsommere over tid. Apps bliver mere komplekse, da de tilpasser sig kravene til mere brugervenlige funktioner.

Windows 10 har været bedre på denne front. Microsofts mål om at have et universelt operativsystem på tværs af desktops, tablets og mobile enheder har tilskyndet dem til at imødekomme maskiner med lavere specifikationer.

Men jeg er ikke sikker på, om Apple har det samme mål. De nye MacBook Pros er langsommere end mange maskiner, der er en tredjedel af prisen. Mange brugere har klaget over, at El Capitan og Sierra dræner flere ressourcer, efter at de har opgraderet deres Macs operativsystemer.

Det er ikke i sig selv en dårlig ting. Jeg elsker den omhu, der er taget for at forbedre anvendeligheden af ​​min Mac. Og jeg elsker hvor hurtigt min Windows 10-maskine fungerer, og jeg har brugt Windows siden jeg var syv år gammel. Jeg betragter mig selv som en Windows-strømbruger.

Pas på fanboyhood. Bliv altid åben. Det er dumt at holde sig til et af disse operativsystemer. Der er mere i livet end den computer, du bruger.

Men den planlagte forældelse betyder, at folk unødvendigt smider gamle Mac'er og Windows-maskiner væk. De er for langsomme til at bruge, og ny software kan ikke installeres på dem.

Jeg startede min 2008 MacBook op for et par uger siden, og den nægtede at installere Chrome. Ville ikke engang røre ved det med en lektestang. Ikke sejt!

Imidlertid skriver jeg nu med en Acer Aspire 5735 fra 2009. Den har en Core 2 Duo-processor med to kerner ved 2,0 GHz. Den har 4 GB DDR2 RAM og en 500 GB HDD. Jeg har installeret et helt nyt batteri, men indtil videre er det den eneste hardwareopgradering.

Jeg bruger den nyeste version af Google Chrome. I øjeblikket har jeg seks faner åbne, og jeg har endnu ikke oplevet nogen større afmatning til dato. Det har også de nyeste versioner af PhpStorm og DataGrip.

På det tidspunkt, hvor min far købte denne bærbare computer til mig, var den meget populær. Jeg elskede det. Det var en maskine med høj specifikation, og den kørte meget godt. Jeg var lige begyndt på universitetet, og denne maskine hjalp mig med mine studievaner. Og i min fritid fungerede det godt til at gennemse og forbruge medier. Det var en fantastisk bærbar arbejdsmaskine i fem år.

Det giver ikke mening for mig, at det bare døde. Jeg gjorde ikke noget krævende spil på det, jeg ville bare være produktiv på det.

Jeg vil have e-mail, jeg vil have browsing, jeg vil have PhpStorm og DataGrip på min bærbare computer. Med Linux kan jeg nemt gøre alle disse ting.

Endnu bedre overvåges min aktivitet ikke af et selskab. Mit operativsystem lytter ikke gennem mikrofonen 24/7 og lagrer data i et datalager uden for landet.

Med Linux har jeg så meget frihed og privatliv som jeg vil.

Installation af Linux på din bærbare computer er også sindssygt let. Jeg viser dig, hvordan du gør det på bare et sekund.

Husk, at Linux driver de største servere, de mest populære applikationer og de vigtigste tjenester i verden.

Men det styrker også alle Android-smartphones. Mens mobiltelefoner bliver mere magtfulde hvert år, er de ikke så magtfulde som moderne computere. Og Android kører meget glat på de fleste moderne telefoner.

Det er fordi Linux er simpelt. Det bruger færre ressourcer og har et rigt samfund af udviklere, der er ivrige efter at hjælpe hinanden.

Hvis Linux er god nok til at drive de vigtigste tjenester i verden, er det god nok til at bruge til at gennemse dit Facebook-nyhedsfeed.

Arch Linux

Til min installation valgte jeg Arch Linux. Dette er ikke en fordeling for svag hjerte.

Barebones-installationsprogrammet til Arch er ikke GUI-baseret eller endda tekstbaseret. Det bruger udelukkende kommandolinjen.

Jeg kan dog godt lide det. Installation af et operativsystem på denne måde hjælper mig med at forstå dets indre funktion.

Jeg har Ubuntu 16.10 "Yakkety" på mit skrivebord, og det var en leg at installere. Jeg downloadede ISO, brændte den til en USB, satte den i min pc, startede fra USB og fulgte de nemme instruktioner.

Ubuntu er langt den blødeste introduktion til Linux. Jeg anbefaler det til folk uden erfaring uden for Windows eller endda macOS, fordi det vil være det mest velkendte for folk.

Når du dykker dybere ned i Linux, skal du prøve forskellige ting og vænne dig til terminalen. Du forstår, hvorfor jeg kan lide Arch-installationsprogrammet.

Jeg brugte ikke det tekstbaserede Arch “Anywhere” -installationsprogram. Jeg brugte lige kommandolinjen.

Og selvom Arch ofte er blevet kaldt et “tekstbaseret horror-spil” af nogle, er virkeligheden, at det er utroligt nemt at installere. Du vil lære mere om, hvordan internerne rent faktisk fungerer senere i denne artikel.

Du får ikke et skrivebordsmiljø som standard. Det er rent kommandolinje. Dette er af design. Arch er beregnet til at være et simpelt Linux-system med barebones.

Arch er vanedannende. Du starter med intet og installerer software efter behov.

I modsætning hertil er Ubuntu subtraktiv. Du starter med alt, hvad du muligvis har brug for, og trimmer ned, indtil du har et lettere system.

Ingen af ​​dem har "ret". Hver passer bare til forskellige mennesker og bruger sager. Det eneste “rigtige” OS er det operativsystem, der bedst hjælper dig med at arbejde og spille.

Endnu en gang er det dog utroligt nemt at installere et skrivebordsmiljø til Arch. Det tager bogstaveligt talt to kommandoer og en genstart for at installere et driftsbord.

Og fordi vi vil have et system, som vi kan bruge, vil vi helt sikkert have et skrivebordsmiljø. I min installation valgte jeg Gnome 3. Jeg kan godt lide udseendet af det. Selvom det er kendt at være ressourcetungt, glæder jeg mig over udfordringen. Jeg tror, ​​at min bærbare computer er klar til det.

Lad os komme igang.

Hvordan jeg installerede Arch Linux på min bærbare computer

Jeg vil nu forklare, hvordan jeg installerede Arch Linux på min bærbare computer.

Du kan følge med, hvis du vil. Bare pas på, at dette vil slette alle data på din computers harddisk. Gør dette kun, hvis du er helt sikker på, at du vil gøre dette, så sikkerhedskopier dine vigtige data på en anden maskine. Slet bestemt ikke dataene på en maskine, der ikke er din!

1. Opret USB-installationsprogrammet

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.

Klik på kommentar knappen nedenfor, og skriv dine tanker, så jeg kan læse dem.

Jeg har et andet hurtigt spørgsmål til dig, da du sandsynligvis er en udvikler, hvis du læser dette.

Gør du de mest almindelige fejl, som de fleste udviklere laver i SQL-forespørgsler? Vil du have min 2-trins algoritme på det perfekte indeks?

Download min gratis rapport, MySQL Worst Practices.