You are not logged in.

#1 2020-07-07 18:38:04

nima3443
Member
Registered: 2020-07-01
Posts: 1

[GUIDE] Create your very own archiso

***** NOTE: I don't know if this is the right category to post this topic in, but it's the most appropriate I found. Feel free to move it if it fits better somewhere else.

Maybe you're wondering how to make your own archiso without messing with skels or tweaking too much things, but still be able to install a GUI, like Plasma, Gnome or what you want and customize it the way you want it. Maybe there's only a small number of people who will get interested in this, but I write that for them. First, let's start with one simple sentence that I hope, will give you hope in what you'll be doing in this guide:

Yes, it's possible to build your distro almost if you were using Linux Respin (which is a tool for customizing debian-based systems by taking your settings from your installed system. Simply, we'll be using

chroot

in that case.

And to encourage you in this process, I'm writing this guide in an Archiso non-persistent system, with KDE Plasma 5.19.2, latest kernel and Vivaldi browser. It works flawlessly.
Let's start, now!

1. I strongly recommend using an Arch-based system if it's not Arch Linux. The simplest way to do this is to install it, then install with pacman:

pacman -Syu
pacman -S archiso

If you're not using Arch, then use an Arch-based distro, like Manjaro, and clone the archiso-git (AUR) package, then install it with makepkg.

2. Copy the desired profile for your ISO. In our case, it's "releng", because we'll have to install more packages than in the "baseline" profile. It's important to copy it to an ext4-formatted partition, because I've experienced some issues with NTFS or FAT-32 (some permissions problems)

cp -r /usr/share/archiso/configs/profile/ archlive

Finally, I'd recommend setting an environment variable such as ARCHLIVE to save you the pain to type each time the path to your archlive folder. We can do this by typing this:

export ARCHLIVE=/path/to/your/archlive/dir

3. We'll start our customization by modifying the "packages.x86_64" text file. There you can write the list of the packages you want to install. Important: you have to leave there the packages that are already written, unless you know what you're doing. Here's an example list which I used for my custom archiso (I do some CG with Blender and some programming in Python). It is recommended to add all your required packages here, but it is possible to install others after if needed.

Contents of $ARCHLIVE/packages.x86_64

arch-install-scripts
b43-fwcutter
broadcom-wl
btrfs-progs
clonezilla
crda
darkhttpd
ddrescue
dhclient
dhcpcd
dialog
diffutils
dmraid
dnsmasq
dnsutils
dosfstools
ethtool
exfat-utils
f2fs-tools
fsarchiver
gnu-netcat
gpm
gptfdisk
grml-zsh-config
grub
hdparm
ipw2100-fw
ipw2200-fw
irssi
iwd
jfsutils
lftp
linux-atm
linux-firmware
lsscsi
lvm2
man-db
man-pages
mc
mdadm
mtools
nano
ndisc6
netctl
nfs-utils
nilfs-utils
nmap
ntfs-3g
ntp
openconnect
openssh
openvpn
partclone
parted
partimage
ppp
pptpclient
refind-efi
reiserfsprogs
rp-pppoe
rsync
sdparm
sg3_utils
smartmontools
sudo
tcpdump
testdisk
usb_modeswitch
usbutils
vi
vim-minimal
vpnc
wget
wireless-regdb
wireless_tools
wpa_supplicant
wvdial
xfsprogs
xl2tpd
htop
gparted
gnome-disk-utility
k3b
dvd+rw-tools
cdrdao
cdrtools
plasma
firefox
dolphin
kate
atom
code
emacs
blender
audacity
lmms
vlc
musescore
kdenlive
thunar
nautilus
konsole
kcalc
minetest
quadrapassel
squashfs-tools
archiso
base-devel
make
oxygen-icons
qemu
qemu-arch-extra
screenfetch
neofetch
xorg
xorg-server
unionfs-fuse
git
gnome-chess
kde-games

4. Now that your package list is updated regarding your needs, it's time to edit the $ARCHLIVE/airootfs/root/customize_airootfs.sh . Open a text editor and change it to your needs. For using a graphical user interface (GUI) I recommend using a sudo-enabled standard user. Here's my customize_airootfs.sh :

Contents of $ARCHLIVE/airootfs/root/customize_airootfs.sh

#!/bin/bash

set -e -u

sed -i 's/#\(en_US\.UTF-8\)/\1/' /etc/locale.gen
locale-gen

ln -sf /usr/share/zoneinfo/UTC /etc/localtime

usermod -s /usr/bin/zsh root
cp -aT /etc/skel/ /root/
chmod 700 /root

sed -i 's/#\(PermitRootLogin \).\+/\1yes/' /etc/ssh/sshd_config
sed -i "s/#Server/Server/g" /etc/pacman.d/mirrorlist
sed -i 's/#\(Storage=\)auto/\1volatile/' /etc/systemd/journald.conf

sed -i 's/#\(HandleSuspendKey=\)suspend/\1ignore/' /etc/systemd/logind.conf
sed -i 's/#\(HandleHibernateKey=\)hibernate/\1ignore/' /etc/systemd/logind.conf
sed -i 's/#\(HandleLidSwitch=\)suspend/\1ignore/' /etc/systemd/logind.conf


systemctl enable pacman-init.service choose-mirror.service
systemctl set-default multi-user.target
systemctl enable sddm.service
# NOTE THESE STEPS: THEY ARE VERY IMPORTANT
nano /etc/sudoers
useradd -m -G wheel user
# Don't forget to add a password, otherwise you'll cannot access sudo later.
passwd user
# This next step is the most important: it will permit us to "pause" the mkarchiso process and customize it regarding our needs.
su user
pacman -Sy
pacman-key --init
pacman-key --populate archlinux

5. Well, it's time to start the process! Be SURE to be on your $ARCHLIVE dir BEFORE you run the archiso script. Otherwise, it may cause problems later.

cd $ARCHLIVE

Now, you're all set! Let's go and type

sudo ./build.sh -v

or simply without sudo if you already have root privileges.
The process will begin by installing the packages you instructed it to. It may take a while, depending on the speed of your Internet connection. After, it will execute the customize_airootfs.sh script. This leads us to our next step.

6. Now, hopefully all previous steps have worked well for you. We now have to customize the tiny details of our GUI (or programs, if needed), for example the theme, wallpaper, etc. You can skip this step if you want, but you'll not have a customized GUI. And if you want to customize the GUI or GUI programs, you'll have to be on a GUI while following this step. Now, open a new tty or terminal tab or window (and DON'T close the chrooted one), then type in:

xhost +local:
export DISPLAY=:0

Where :0 is the ID of your screen.
This will allow us to open GUI applications and GUI interface on our main system from the chroot.
In this example, I use KDE Plasma. To initiate the session, I usually type, in the chrooted terminal:

plasmashell

There I can open the settings and all these things, modify the wallpaper, the same way (or almost!) that I would do it in a normal system. Don't worry if your applications look a little strangely, it's normal. They'll look clean after booted in the very real archlive environment in the LiveUSB/CD/DVD. But important: DON'T installl the

gsfonts

package (which is included with GIMP in Pacman), or otherwise you'll get a complete font mess in your system. I'll talk of workarounds of this problem later, particularly with GIMP, where you can simply grab an AppImage from an online repo.
When I'm finished, I just hit CTRL+C and it kills the GUI.
If you encounter a strange sudo error with something related to nosuid or so, don't worry, it will not be there in the final live system. But the problem there is you can't execute apps or commands as root in arch-chroot (for now, I don't know if it will change later). I have a workaround for this, but only for commands, not modifying apps settings: you can simply go on another terminal and chroot (not arch-chroot) to $ARCHLIVE/work/x86_64/airootfs . It will login as root automatically. Also, note here that the airootfs folder is your base system which will be compressed into a squashfs at the end.

7. Now you are near the end! I recommend clean up the system a little bit, clearing the history, make sure that all the settings are what you want they be. Once it's done, type "exit" on the chrooted terminal, and immediately after, CTRL+C. It will kill the mkarchiso process. But our work is saved and when we execute it later, it will start where it ended earlier, thanks to the "locks" in the work folder. Now, restart your computer and don't unplug the device where your $ARCHLIVE directory is. This will clean up the system, erase the /run, /tmp and other folders that eat a little disk space there, and will clean up our system a little bit for the making of the squashfs.

8. Once you're on your default Arch system, redefine the ARCHLIVE environment variable and cd into it. Then, when you're sure nothing is left to add or modify in your system, open up a text editor and modify the /usr/bin/mkarchiso file in your main system to change the squashfs settings. The best I've ever found that I use everytime I make an archiso, are these:

mksquashfs /dir /file.sqsh -b 1048576 -comp xz -Xdict-size 100% -always-use-fragments -noappend

So a quick CTRL+F in your file to find the mksquashfs command will soon lead you to edit the options after. Change these to your needs, you can also leave them as they are, but the options above are the best compression choice I could find. And it works very well! I obtained a final size of squashfs of around 2.4 GiB with all packages shown above, plus the Vivaldi browser and some other tiny software. And I've other tips on how to add more software almost without touching to your airootfs.sfs file. Save the mkarchiso file, then cd into your $ARCHLIVE dir and finally, type the magic command:

sudo ./build.sh -v

Now let the process finish, make your squashfs and your ISO, then burn it to a DVD/CD/USB depending on the size of it, or test it on a virtual machine.

Hope you've enjoyed that tutorial, and I will post updates on adding software outside the main squashfs with overlays of tiny squashfs mounted by unionfs in your Documents, Music dirs for example.
I want to hear your impressions and see your results, if you make one!

Last edited by nima3443 (2020-07-07 18:42:00)

Offline

#2 2020-07-07 18:45:11

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,444
Website

Re: [GUIDE] Create your very own archiso

nima3443 wrote:

***** NOTE: I don't know if this is the right category to post this topic in, but it's the most appropriate I found.

No, it isn't.  This doesn't belong on the forum at all, but rather on the wiki - but there's already very good information on this in a wiki.  Contribute to the existing wiki page if you think anything needs to be added, or get a blog.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2020-07-07 18:53:00

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [GUIDE] Create your very own archiso

As Trilby says, the forum isn't the correct place for this.

Closing.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

Board footer

Powered by FluxBB