Linux Format

Installing GNU/Linux

One cannot have a Linux PC without first installing Linux, so let us do just this and discuss filesystem­s at length!

-

“We’ll show you how to set up an LVM arrangemen­t, which can be recreated in any distro”

The process of installing Linux has never been easier, but as anyone who’s an old hat at this will tell you, it’s easy to regret decisions made during installati­on further down the line. Most commonly, people wish they’d made a separate partition for /home (your user folder, it makes recovery easy if your / (the system root) partition dies, but then so does a good back-up strategy). Most distributi­ons will give you this option this straight from the installer now.

Another gripe is where you decide you want to install another distro, but that requires shunting all the data on one partition to the beginning to make room, resizing the filesystem, shifting the partition boundary, then making a new partition. Not impossible (you can even resize certain filesystem­s while they’re mounted nowadays), but risky and time-consuming, and also something that would be trivial to set up during installati­on.

UEFI (Unified Extensible Firmware Interface) has its critics (people confuse it with Secure Boot, but it’s just an optional component of it). However, it makes booting multiple distros straightfo­rward because each one maintains its own separate GRUB rather than them all fighting it out. We don’t want to limit ourselves to just two distros, and we don’t want to make a bunch of possibly redundant partitions, so we’ll be smart and use Logical Volume Manager (LVM) to indulge our indecisive­ness.

LVM abstracts away not just partitions, but actual devices too, so one deals instead with volume groups (VGs – loose collection­s of physical devices) and logical volumes (LVs), which act like partitions (in the sense that you can put a filesystem on them). The advantage of these virtual structures is that they’re much more flexible: not only do they permit easy resizing, but devices can be dynamicall­y added and removed from VGs so that the LVs thereon can be extended onto new devices, restricted to a subset, or even relocated entirely.

What’s more is this can all happen transparen­tly. There’s no need to unmount anything, restart services or even pause that cat video. LVM also makes it possible to take snapshot volumes, which you can use for backup or testing updates. It can also be combined with dm-crypt and mdadm to make encrypted and RAIDed (respective­ly) volumes.

And so it begins…

But let’s not get ahead of ourselves, we still haven’t installed Linux. First make sure your machine is booting in UEFI mode, so disable anything to do with Classic BIOS or CSM mode, you’ll want to disable Secure Boot too, since it’s not supported by all distros (or the Linux-Format DVD). We’re not going to tell you which distro you should use, but Linux Mint

(good for everyone) and Fedora (good for the technicall­y minded) are both on our disc.

For illustrati­on we’ll show you how to set up an LVM arrangemen­t, which can be recreated in any distro. UEFI requires an ESP (EFI System Partition), which we’ll create. We’ll also have separate logical partitions for /home and / and, for reasons that will be kept secret until the next section, another partition outside of LVM’s jurisdicti­on. Later, we’ll show you how to set up a RAID1 array on larger, magnetic storage. You may wish to move the /home partition here, if you’re planning on using this for storing large, precious files. That’s fine, but let’s get down to LVM. The set-up process should easily be recreated in the Fedora installer, or any other.

The Mint Installer has an option to set up LVM, but it won’t do quite what we want (Fedora’s installer is better here), we can tweak things after the fact. So boot into the Mint live environmen­t and start the installer. Unless you’re installing alongside another OS (in which case most definitely don’t do this), select the Erase disk and install Mint option, and then check the Use LVM box. Besides installing Mint, this will set up a volume group called mint-vg , with two logical volumes: one for the OS and one for swap (best to have). You’ll also get a separate /boot partition outside of the volume group. Don’t reboot after installati­on. Instead, open a terminal and do:

$ sudo apt install system-config-lvm $ system-config-lvm

This will provide a nice GUI whence logical volumes can be added. Select the root volume and click Edit Properties. Resize it to 40GB (or whatever you see fit) and click OK. Return to the Logical View and choose Create New Logical Volume. Call it home and make it a suitable size; on our 240GB drive we used 120GB, leaving 80GB. Use the default ext4 filesystem. Make another LV in the free space, call it

bcache ( hangon!–Ed) and don’t format it, either. Exit the LVM tool and return to the terminal. If you run ls /dev/mapper you should see your newly created logical volumes. We haven’t told our still-warm install about the /home LV, let’s do that. Firstly, mount the root LV (where we’ve installed Mint):

$ sudo mount /dev/mapper/mint--vg-root /mnt

Now find the UUID of the home partition by running blkid . We’ll paste this into our install’s fstab file, so that when we reboot Mint knows to find home directorie­s there. So copy the UUID="abcd...” part and open this file with nano /mnt/etc/fstab . Add a line that looks like

UUID="abcd...” /home ext4 defaults 0 0

and save and exit with Ctrl-X, Y. Next we need to mount this volume and move across the home folder that the installer created for us:

$ sudo mkdir /lvmhome $ sudo mount /dev/mapper/mint--vg-home /lvmhome $ sudo mv /mnt/home/* /lvmhome

You should now be able to reboot into your freshly Minted install. If not then check your UEFI settings. If you run the mount command, you should see that /home does indeed live in an LV. From here you can install any applicatio­ns (Mint comes with a good selection), customise your background or continue with our guide. One thing that will come in handy is installing the SSH server, which you can easily do with:

$ sudo apt install openssh-server

 ??  ?? Mint 18.3 was released in December last year and comes with everything you need to start enjoying your new build.
Mint 18.3 was released in December last year and comes with everything you need to start enjoying your new build.
 ??  ?? It’s also possible to use Gparted to partition your disk before installati­on. This is a recommende­d option for more involved layouts.
It’s also possible to use Gparted to partition your disk before installati­on. This is a recommende­d option for more involved layouts.
 ??  ?? Our LVM ended up looking like this: three big LVs and a small one. You might go for something different.
Our LVM ended up looking like this: three big LVs and a small one. You might go for something different.

Newspapers in English

Newspapers from Australia