Arch-itect your cas­tle

Base your cus­tom spin on the pop­u­lar DIY Linux dis­tri­bu­tion.

Linux Format - - HOTTEST DISTROS -

While both bod­hibuilder and livecd-cre­ator en­able you to cre­ate a cus­tomised spin with a fair amount of tweaks, if you have the pa­tience to hand-craft an in­stal­la­tion from scratch, Arch Linux of­fers a more com­pre­hen­sive ap­proach. Arch is an ideal plat­form for cul­ti­vat­ing a cus­tom dis­tro with­out the code bloat and pack­age pro­lif­er­a­tion that af­flicts so many other pop­u­lar ones. The Archiso pack­age is a col­lec­tion of bash scripts that you can use to con­vert your Arch in­stal­la­tion into a dis­tributable dis­tro. Like the dis­tro it works on, Archiso has a steep learn­ing curve, but gives you a lot of con­trol over the fi­nal re­sult.

The first thing you need be­fore you can use Archiso is an Arch Linux in­stal­la­tion. If you’re new to Arch, the process is well doc­u­mented on the project’s wiki page ( https://wiki.arch­­dex.php/In­stal­la­tion_ guide). An­other op­tion is to use an in­stal­la­tion of a pure Arch-based dis­tri­bu­tion like An­ter­gos, Ar­coLinux, Chakra or Man­jaro. In fact, some of these dis­tros, like Man­jaro have their own fork of the Archiso script. In any case, once you’ve in­stalled Arch on your com­puter, the next step is to cus­tomise it to your lik­ing. That in­cludes in­stalling more pack­ages, swap­ping out the de­fault themes and art­work of your desk­top en­vi­ron­ment and con­fig­ur­ing other as­pects of the sys­tems such as the net­work. As usual we’ll copy these cus­tomi­sa­tions and con­fig­u­ra­tions from the in­stalled in­stance of Arch over to the cus­tom dis­tro we’re build­ing. When you’re done cus­tomis­ing the Arch in­stal­la­tion, fire up a ter­mi­nal and in­stall Archiso and its de­pen­den­cies with # pac­man -S make squashfs-tools li­bisoburn dos­f­s­tools patch lynx de­v­tools git archiso

Next, cre­ate a direc­tory where we’ll tweak the files for our cus­tom dis­tro with mkdir ~/arch­live . Make sure you have enough free disk space to ac­com­mo­date all the pro­grams you wish to in­stall, along with any files you want to copy over to the cus­tom dis­tro. Archiso comes with two pre­de­fined pro­files.

The base­line pro­file is use­ful for cre­at­ing a ba­sic live sys­tem with no pre-in­stalled pack­ages. How­ever, we’ll use the re­leng pro­file, which en­ables you to cre­ate a fully cus­tomised Arch Linux with pre-in­stalled apps. To use these scripts, sim­ply copy them over to the ~/arch­live direc­tory, like so: # cp -R /usr/share/archiso/con­figs/re­leng/ ~/ arch­live/

Pack­age ‘em up

To put pack­ages on the cus­tom dis­tro all you need to do is list them in the pack­ages.x86_64 file un­der the newly cre­ated arch­live direc­tory. The file al­ready con­tains a list of es­sen­tial pack­ages and you can man­u­ally add to it with a text edi­tor. Since our goal is to mir­ror our Arch in­stal­la­tion, use the pac­man -Qqe >> ~/arch­live/ pack­ages.x86_64 com­mand to dump the name of all the in­stalled pack­ages in that file.

The ai­rootfs direc­tory in­side ~/arch­live/ acts as an over­lay for what will be the root direc­tory of your new dis­tri­bu­tion. Any files you add to this direc­tory will be added to your dis­tro’s filesys­tem. So for ex­am­ple, if you want your cus­tom dis­tro to have the same users as your host ma­chine, copy over the rel­e­vant files with:

# cp /etc/{shadow,passwd,group} ~/arch­live/ ai­rootfs/etc/

An­other use of the ai­rootfs filesys­tem is to set up and launch the graph­i­cal en­vi­ron­ment. First find out the .ser­vice file for the lo­gin man­ager in your cur­rent setup with: $ ls -l /etc/sys­temd/sys­tem/dis­play-man­ager. ser­vice

As­sum­ing you’re us­ing GDM, you’ll then have to sym­link the file into the new filesys­tem with: # ln -s /usr/lib/sys­temd/sys­tem/gdm.ser­vice ~/arch­live/ai­rootfs/etc/sys­temd/sys­tem/ dis­play-man­ager.ser­vice

Just like be­fore, to copy over any files that you want within the user’s /home direc­tory, you need to place them in the /etc/skel direc­tory. First, cre­ate it with mkdir ~/arch­live/ai­rootfs/etc/ skel and then copy over the files like cp -R ~/. con­fig ~/arch­live/ai­rootfs/etc/skel/ .

To log in au­to­mat­i­cally as your user in­stead of the de­fault root user, open the ~/arch­live/ ai­rootfs/etc/sys­temd/sys­tem/getty@tty1. ser­vice.d/au­tolo­gin.conf file in a text edi­tor and mod­ify this line to swap the auto lo­gin user: Ex­ecS­tart=-/sbin/agetty --au­tolo­gin <user­name> --no­clear %I 38400 linux Re­place <user­name> with the user that you want to log in as.

Cus­tomise the image

In­side root’s home folder (~/ arch­live/ai­rootfs/ root) there’s a file named cus­tom­ize-root-image. sh. Any ad­min­is­tra­tive task that you would nor­mally do af­ter an Arch in­stall can be scripted into this file. Re­mem­ber that the in­struc­tions within the file have to be writ­ten from the per­spec­tive of the new en­vi­ron­ment, which is to say that / in the script rep­re­sents the root of the dis­tro that’s be­ing as­sem­bled. Open the file in a text edi­tor, find the line that sets /etc/lo­cal­time and change it to your time­zone. For ex­am­ple: ln -sf /usr/share/zone­info/Europe/Lon­don /etc/lo­cal­time Also make sure that the shell is set to Bash by chang­ing the user­mod line to read: user­mod -s /usr/bin/bash root

Scroll down and add a line to copy the con­tents of the /skel direc­tory into your user’s home direc­tory as well and set proper own­er­ship per­mis­sions with: cp -aT /etc/skel/ /home/bodhi/ chown bodhi /home/bodhi -R

In both these com­mands, re­mem­ber to re­place bodhi with the name of your user.

Fi­nally, scroll down to the end of the file where you’ll no­tice a bunch of sys­tem­ctl com­mands. To boot straight into the graph­i­cal desk­top, change the de­fault tar­get from multi-user by edit­ing the line so that it reads: sys­tem­ctl set-de­fault graph­i­cal.tar­get

That’s it. You’re now all set to build the ISO for your cus­tom dis­tro. En­ter the ~/arch­live direc­tory and run the fol­low­ing ./ -v -N LXFArch -V 0.1 -L LXFArch_0.1 to ini­ti­ate the build process. The -v switch en­ables the ver­bose mode, the -N switch sets the name of the ISO image, -V sets the ver­sion num­ber and -L ap­pends a la­bel to the gen­er­ated ISO image. The process doesn’t usu­ally throw any er­rors but if you get any pac­man-re­lated com­plaints try re­fresh­ing its au­then­ti­ca­tion keys with pac­man-key --re­fresh-keys .

The process will take some time de­pend­ing on the num­ber of pack­ages it has to fetch. It’ll cre­ate and process ev­ery­thing un­der the ~/arch­live/ work/ direc­tory. When it’s done, the script will cre­ate the ISO un­der the ~/arch­live/out/ direc­tory. The script doesn’t of­fi­cially sup­port re­build­ing the ISO and calls to the build script will fail. You can get around that lim­i­ta­tion by delet­ing the ~/arch­live/work/ direc­tory.

Have fun build­ing your own dis­tro, but re­mem­ber a dis­tro isn’t just for Christ­mas, it’s for life; so you’ll need to sup­port it, for­ever. Make sure you tell us how you got on as well!

You can use archiso-off­line-re­leng to cre­ate a cus­tom dis­tro that’ll only use lo­cally hosted pack­ages in­stead of fetch­ing them from on­line re­pos.

Newspapers in English

Newspapers from Australia

© PressReader. All rights reserved.