User:Nima3443/Another way to create a custom archiso
Maybe you are 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. Here you will learn how.
1. Install thepackage.
2. Copy the desired profile for your ISO. In our case, it's
releng, because we will have to install more packages than in the
baseline profile. It's important to copy it to an ext4-formatted partition, because I have experienced some issues with NTFS or FAT-32 (some permissions problems)
# cp -r /usr/share/archiso/configs/releng/ archlive
Finally, I 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 will start our customization by modifying the
packages.x86_64 text file. There you can write the list of the packages you want to install. Here is an example list which I used for my custom archiso (I do some CG with Blender and some programming in Python, and I installed KDE Plasma as main DE). It is recommended to add all your required packages here, but it is possible to install others after if needed.
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 is my
#!/bin/bash set -e -used -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 nano /etc/sudoers useradd -m -G wheel user # Do not forget to add a password, otherwise you will not be able to 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. It's time to start the making of our ISO, now. Be SURE to be on your
$ARCHLIVE dir BEFORE you run the archiso script. Otherwise, it may cause problems later.
# cd $ARCHLIVE
# ./build.sh -v
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 will not have a customized GUI. And if you want to customize the GUI or GUI programs, you will have to be on a GUI while following this step. Now, open a new tty or terminal tab or window (and DO not 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:
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. Do not worry if your applications look a little strange, it's normal. They will look clean after booted in the very real archlive environment in the LiveUSB/CD/DVD.
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, do not worry, it will not be there in the final live system. But the problem there is you cannot execute apps or commands as root in arch-chroot (for now, I do not 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. I recommend cleaning 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 do not unplug the device where your
$ARCHLIVE directory is. This will clean up the system, erase the
/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 are on your default Arch system, redefine the
ARCHLIVE environment variable and cd into it. Then, when you are sure nothing is left to add of 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 have 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 have 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:
# ./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, like in QEMU. I use these QEMU options:
# qemu-system-x86_64 -cdrom arch.iso -m 2048 -enable-kvm