Make your own Arch Linux Distro with ArchISO
By Swee
Welcome to this tutorial on making a Linux Distro with archiso
!
Here are the requirements:
- Arch Linux
- 20GB or more disk space
- 4GB RAM recommended
- 64-Bit CPU recommended for regular use
Tip: If you don’t want to use Arch linux, you can use a VM, but you won’t be able to test the new ISO unless you import the ISO to your host, then use a VM there.
Why ArchISO?
archiso
is a simple tool for creating ISO images and respins (distros) of Arch Linux.
Fact: Arch Linux’ official ISO images are made with archiso
.
Preparing tools
To install archiso
on your machine, run this command as root
:
pacman -Syu archiso
Tip: There could be an enchanced or newer version of
archiso
in AUR.
According to Arch Linux Wiki, there are two default profiles, base
and releng
. We’re going to use releng
because it is recommended for respins.
To use the releng
profile, you must copy the profile to the current directory you’re in. You can run this command without root:
cp -r /usr/share/archiso/configs/releng ./archlive
Now that you’ve got a base profile, you’ll need to check this README file to get an understanding of what’s in the profile directory.
Editing packages
Now that you prepared the profile, you should edit the packages.x86_64
file located in the root directory of the profile, you can also remove some unwanted packages that are originally for the Arch Linux installation medium.
WARNING: Make sure the packages exist in your
pacman
repositories or the ISO build will fail!
If your package is located in AUR or isn’t in an online repository, you can append this code to pacman.conf
and make a custom repository with that. Click here if you need information about custom repositories.
[customrepo]
SigLevel = Optional TrustAll
Server = file:///path/to/customrepo
Tip: You can also uncomment the
multilib
repository inpacman.conf
if you need any packages there.
Adding files
If you use a graphical file manager like pcmanfm, then it will be simple to transfer your current configuration to your archiso
profile.
Note: even if your machine has the default configuration of the program you want, you can copy the one from your machine to airootfs and edit it.
if you are using the command line to prepare your profile, then you can use the following command to copy iptables
(can be any file) to your archiso
profile.
cp -r /etc/iptables ./archlive/airootfs/etc
Tip: files like /etc/sudoers
should copied to archlive/airootfs/etc/
. think of airootfs being a filesystem offset.
Changing OS branding
Now it’s your turn for rebranding your OS, you can start with copying and editing /etc/os-release
to airootfs and then editing the profile’s grub
and syslinux
folders. with editing these folders, you can change the OS names and descriptions in different bootloaders. plus a new splash for SYSLINUX is great.
Enabling SystemD services
To enable systemd
services on your archiso
profile, you have to add the service’s packages to both your packages.x86_64
file and your system.
systemd
units run by wants targets, for example, multi-user.target
can be added to the system by using this command.
mkdir -p ./archlive/airootfs/etc/systemd/system/multi-user.target.wants
And to enable the services that is wanted by multi-user.target
such as gpm.service
, you can run this command to make a symlink of the service just like systemctl enable
will.
ln -s /usr/lib/systemd/system/gpm.service ./archlive/airootfs/etc/systemd/system/multi-user.target.wants/
WARNING: Point the symlink to the system file, symbolic links do not care if the target path doesn’t exist. If you set the target to an
airootfs
path, then the environment will still try to use that same path without translating to a system path.
How to enable display manager?
You can also use systemd to add a display manager to your distro, to do this with LXDM, you can check display-manager.service
to see which display manager is set.
ls -l /etc/systemd/system/display-manager.service
And then to enable LXDM by creating a symbolic link.
ln -s /usr/lib/systemd/system/lxdm.service ./archlive/airootfs/etc/systemd/system/display-manager.service
Creating users and passwords
Adding users is pretty complicated but it’s simple to encrypt the password. to add a user named user
, follow these steps:
Step 1: Edit /etc/passwd
To add a user, you can change /etc/passwd
like this
root:x:0:0:root:/root:/usr/bin/zsh
user:x:1000:1000::/home/user:/usr/bin/zsh
and create the respective home directory in airootfs
.
Step 2: Generate encrypted password
To make the encrypted password, create a dummy user with the password you want, then use the following command and copy the encrypted password after the colon (:
) next to the username and before the colon next to 14871
.
cat /etc/shadow
Now, create /etc/shadow in airootfs
and edit it like this.
root::14871::::::
user:enc:14871::::::
Replace enc with the password hash you just copied.
Step 3: Add groups
Groups are an important part of the multi-user linux, it allows to tell programs what permissions someone has. create and edit /etc/group
and add these important groups.
root:x:0:root
adm:x:4:user
wheel:x:10:user
uucp:x:14:user
user:x:1000:
Step 4: Create /etc/gshadow
You can create and edit /etc/gshadow
like this.
root:!*::root
user:!*::
Setting autologin
To set autologin on the console, you must create or change /etc/systemd/[email protected]/autologin.conf
on the airootfs like this.
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin user --noclear %I 38400 linux
Replace user
with the username of the user for the profile.
How to set autologin on LXDM?
to setup autologin on LXDM, copy /etc/lxdm/lxdm.conf
to airootfs and uncomment the following line.
#autologin=dgod
Replace dgod
with the username of the user for the profile.
Info: To setup autologin on any other Display Manager other than LXDM, you must follow their documentation.
Build the ISO
to build the ISO, you must prepare an empty folder that archiso
will use to prepare the ISO for compilation.
Note: If you have enough RAM and the system allows to do so, you can make an empty folder in
/tmp
and use it as the work directory.
After preparing the folder, you must run the following command, replacing each directory path with the ones on your machine:
mkarchiso -v -w /path/to/work_dir -o /path/to/out_dir /path/to/profile/
Tip: After making the ISO, you can try making your ISO bootable with secure boot enabled machines, but I’m not that experienced to describe it for beginners yet.
Warning: you must delete everything in the folder before building again, or archiso will skip the building entirely!
Testing
To test your new ISO on an emulator, you can install the required packages using this command as root
:
pacman -Syu qemu-desktop edk2-ovmf
And after installing qemu
, run archiso
’s built-in command for testing the ISO, replacing the file path(s) with the path(s) on your machine:
run_archiso -i /path/to/file.iso
Tip: you can emulate UEFI by adding the
-u
argument to the command.
Now what?
Now that you have created your own distro, go ahead and customize it as you like and improve it to the way you want it to be.
If you liked this tutorial, please like this post and subscribe to SweeBlogs for more Tutorials and blogs!
Arch Linux and the Arch Linux Logo are trademarks of the Arch Linux project.