# Linux

# 5 Best Tools to Find and Remove Duplicate Files in Linux

<header class="entry-header" id="bkmrk-marin-todorovlast-up"><div class="entry-meta"><span class="byline"><span class="author vcard">[<span class="author-name">Marin Todorov</span>](https://www.tecmint.com/author/marintodorov89/ "View all posts by Marin Todorov")</span></span><span class="posted-on"><time class="entry-date updated-date" datetime="2023-07-14T07:47:13+05:30">Last Updated: July 14, 2023</time></span> <span class="cat-links"><span class="screen-reader-text">Categories</span>[Linux Commands](https://www.tecmint.com/category/linux-commands/)</span> <span class="comments-link">[34 Comments](https://www.tecmint.com/find-and-delete-duplicate-files-in-linux/#comments)</span></div><div class="hide-on-mobile"><div style="text-align:center;"></div>  
</div></header>Organizing your home directory or even system can be particularly hard if you have the habit of downloading all kinds of stuff from the internet using your [download managers](https://www.tecmint.com/download-managers-for-linux/ "Download Managers for Linux").

Often you may find you have downloaded the same mp3, pdf, and epub (and all kinds of [other file extensions](https://www.tecmint.com/find-file-types-in-linux/ "Find File Types in Linux")) and [copied it to different directories](https://www.tecmint.com/cp-command-examples/ "Copy Files in Linux"). This may cause your directories to become cluttered with all kinds of useless duplicated stuff.

In this tutorial, you are going to learn how to find and delete duplicate files in Linux using **rdfind**, **fdupes,** and **rmlint** command-line tools, as well as using GUI tools called **DupeGuru** and [FSlint](https://www.tecmint.com/fslint-find-and-remove-duplicate-unwanted-files-in-linux/).

A note of caution – always be careful what you delete on your system as this may lead to unwanted data loss. If you are using a new tool, first try it in a [test directory where deleting files](https://www.tecmint.com/remove-directory-linux/ "Delete Directory in Linux") will not be a problem.

## 1. Rdfind – Find Duplicate Files in Linux

**[Rdfind](https://github.com/pauldreik/rdfind "Rdfind - Find Duplicate Files")** comes from redundant data find, which is a free command-line tool used to find duplicate files across or within multiple directories. It recursively scans directories and identifies files that have identical content, allowing you to take appropriate actions such as deleting or moving the duplicates.

**Rdfind** uses an algorithm to classify the files and detects which of the duplicates is the original file and considers the rest as duplicates.

The rules of ranking are:

<div class="entry-content" id="bkmrk-if%C2%A0a%C2%A0was-found-while">- If **A** was found while scanning an input argument earlier than **B**, **A** is higher ranked.
- If **A** was found at a depth lower than **B**, **A** is higher ranked.
- If **A** was found earlier than **B**, **A** is higher ranked.

</div>The last rule is used particularly when two files are found in the same directory.

### Install Rdfind on Linux

To install **rdfind** in Linux, use the following command as per your Linux distribution.

```
$ sudo apt install rdfind         [On <strong>Debian, Ubuntu and Mint</strong>]
$ sudo yum install rdfind         [On <strong>RHEL/CentOS/Fedora</strong> and <strong>Rocky/AlmaLinux</strong>]
$ sudo emerge -a sys-apps/rdfind  [On <strong>Gentoo Linux</strong>]
$ sudo apk add rdfind             [On <strong>Alpine Linux</strong>]
$ sudo pacman -S rdfind           [On <strong>Arch Linux</strong>]
$ sudo zypper install rdfind      [On <strong>OpenSUSE</strong>]    
```

To run **rdfind** on a directory simply type **rdfind** and the target directory.

```
$ rdfind /home/user
```

<div class="entry-content" id="bkmrk-find-duplicate-files"><figure class="wp-caption aligncenter" id="bkmrk-find-duplicate-files-1">![Find Duplicate Files in Linux](https://www.tecmint.com/wp-content/uploads/2018/10/Find-Duplicate-Files-in-Linux.png)<figcaption class="wp-caption-text" id="bkmrk-find-duplicate-files-2">Find Duplicate Files in Linux</figcaption></figure></div>As you can see **rdfind** will save the results in a file called **results.txt** located in the same directory from where you ran the program. The file contains all the duplicate files that rdfind has found. You can review the file and remove the duplicate files manually if you want to.

Another thing you can do is to use the `-dryrun` an option that will provide a list of duplicates without taking any actions:

```
$ rdfind -dryrun true /home/user
```

When you find the duplicates, you can choose to replace them with hard links.

```
$ rdfind -makehardlinks true /home/user
```

And if you wish to delete the duplicates you can run.

```
$ rdfind -deleteduplicates true /home/user
```

To check other useful options of **rdfind** you can use the **rdfind** manual.

```
$ man rdfind 
```

## 2. Fdupes – Scan for Duplicate Files in Linux

[Fdupes](https://www.tecmint.com/fdupes-find-and-delete-duplicate-files-in-linux/) is another command-line program that allows you to identify duplicate files on your system. It searches directories recursively, comparing file sizes and content to identify duplicates.

It uses the following methods to determine duplicate files:

<div class="entry-content" id="bkmrk-comparing-partial-md">- Comparing partial md5sum signatures
- Comparing full md5sum signatures
- byte-by-byte comparison verification

</div>Just like **rdfind,** it has similar options:

<div class="entry-content" id="bkmrk-search-recursively-e">- Search recursively
- Exclude empty files
- Shows the size of duplicate files
- Delete duplicates immediately
- Exclude files with a different owner

</div>### Install Fdupes in Linux

To install **fdupes** in Linux, use the following command as per your Linux distribution.

```
$ sudo apt install fdupes         [On <strong>Debian, Ubuntu and Mint</strong>]
$ sudo yum install fdupes         [On <strong>RHEL/CentOS/Fedora</strong> and <strong>Rocky/AlmaLinux</strong>]
$ sudo emerge -a sys-apps/fdupes  [On <strong>Gentoo Linux</strong>]
$ sudo apk add fdupes             [On <strong>Alpine Linux</strong>]
$ sudo pacman -S fdupes           [On <strong>Arch Linux</strong>]
$ sudo zypper install fdupes      [On <strong>OpenSUSE</strong>]    
```

**Fdupes** syntax is similar to **rdfind**. Simply type the command followed by the directory you wish to scan.

```
$ fdupes <dir>
```

To search files recursively, you will have to specify the `-r` an option like this.

```
$ fdupes -r <dir>
```

You can also specify multiple directories and specify a **dir** to be searched recursively.

```
$ fdupes <dir1> -r <dir2>
```

To have fdupes calculate the size of the duplicate files use the `-S` option.

```
$ fdupes -S <dir>
```

To gather summarized information about the found files use the `-m` option.

```
$ fdupes -m <dir>
```

<div class="entry-content" id="bkmrk-scan-duplicate-files"><figure class="wp-caption aligncenter" id="bkmrk-scan-duplicate-files-1">![Scan Duplicate Files in Linux](https://www.tecmint.com/wp-content/uploads/2018/10/Scan-Duplicate-Files-in-Linux.png)<figcaption class="wp-caption-text" id="bkmrk-scan-duplicate-files-2">Scan Duplicate Files in Linux</figcaption></figure></div>Finally, if you want to delete all duplicates use the `-d` an option like this.

```
$ fdupes -d <dir>
```

**Fdupes** will ask which of the found files to delete. You will need to enter the file number:

<div class="entry-content" id="bkmrk-delete-duplicate-fil"><figure class="wp-caption aligncenter" id="bkmrk-delete-duplicate-fil-1">![Delete Duplicate Files in Linux](https://www.tecmint.com/wp-content/uploads/2018/10/Delete-Duplicate-Files-in-Linux.png)<figcaption class="wp-caption-text" id="bkmrk-delete-duplicate-fil-2">Delete Duplicate Files in Linux</figcaption></figure></div>A solution that is definitely not recommended is to use the `-N` option which will result in preserving the first file only.

```
$ fdupes -dN <dir>
```

To get a list of available options to use with **fdupes** review the help page by running.

```
$ fdupes -help
```

## 3. Rmlint – Remove Duplicate Files

[Rmlint](https://github.com/sahib/rmlint "Rmlint - Remove Duplicate Files") is a command-line tool that is used for finding and removing duplicate and lint-like files in Linux systems. It helps identify files with identical content, as well as various forms of redundancy or lint, such as empty files, broken symbolic links, and orphaned files.

### Install Rmlint on Linux

To install **Rmlint** in Linux, use the following command as per your Linux distribution.

```
$ sudo apt install rmlint         [On <strong>Debian, Ubuntu and Mint</strong>]
$ sudo yum install rmlint         [On <strong>RHEL/CentOS/Fedora</strong> and <strong>Rocky/AlmaLinux</strong>]
$ sudo emerge -a sys-apps/rmlint  [On <strong>Gentoo Linux</strong>]
$ sudo apk add rmlint             [On <strong>Alpine Linux</strong>]
$ sudo pacman -S rmlint           [On <strong>Arch Linux</strong>]
$ sudo zypper install rmlint      [On <strong>OpenSUSE</strong>]    
```

<div class="entry-content" id="bkmrk-rmlint-%E2%80%93-remove-dupl"><figure class="wp-caption aligncenter" id="bkmrk-rmlint-%E2%80%93-remove-dupl-1">![Rmlint - Remove Duplicate Files](https://www.tecmint.com/wp-content/uploads/2018/11/Rmlint-Remove-Duplicate-Files.png)<figcaption class="wp-caption-text" id="bkmrk-rmlint-%E2%80%93-remove-dupl-2">Rmlint – Remove Duplicate Files</figcaption></figure></div>## 4. dupeGuru – Find Duplicate Files in a Linux

**[dupeGuru](https://dupeguru.voltaicideas.net/ "dupeGuru - Find Duplicate Files")** is an open-source and cross-platform tool that can be used to find duplicate files in a Linux system. The tool can either scan filenames or content in one or more folders. It also allows you to find the filename that is similar to the files you are searching for.

**dupeGuru** comes in different versions for Windows, Mac, and Linux platforms. Its quick fuzzy matching algorithm feature helps you to find duplicate files within a minute. It is customizable, you can pull the exact duplicate files you want to, and Wipeout unwanted files from the system.

### Install dupeGuru on Linux

To install **dupeGuru** in Linux, use the following command as per your Linux distribution.

```
$ sudo apt install dupeguru         [On <strong>Debian, Ubuntu and Mint</strong>]
$ sudo yum install dupeguru         [On <strong>RHEL/CentOS/Fedora</strong> and <strong>Rocky/AlmaLinux</strong>]
$ sudo emerge -a sys-apps/dupeguru  [On <strong>Gentoo Linux</strong>]
$ sudo apk add dupeguru             [On <strong>Alpine Linux</strong>]
$ sudo pacman -S dupeguru           [On <strong>Arch Linux</strong>]
$ sudo zypper install dupeguru      [On <strong>OpenSUSE</strong>]    
```

<div class="entry-content" id="bkmrk-dupeguru-%E2%80%93-find-dupl"><figure class="wp-caption aligncenter" id="bkmrk-dupeguru-%E2%80%93-find-dupl-1">![DupeGuru - Find Duplicate Files in Linux](https://www.tecmint.com/wp-content/uploads/2018/11/DupeGuru-Find-Duplicate-Files-in-Linux.png)<figcaption class="wp-caption-text" id="bkmrk-dupeguru-%E2%80%93-find-dupl-2">DupeGuru – Find Duplicate Files in Linux</figcaption></figure></div>## 5. FSlint – Duplicate File Finder for Linux

**[FSlint](https://www.tecmint.com/fslint-find-and-remove-duplicate-unwanted-files-in-linux/)** is a free utility that is used to find and clean various forms of lint on a filesystem. It also reports duplicate files, empty directories, temporary files, duplicate/conflicting (binary) names, bad symbolic links, and many more. It has both command-line and GUI modes.

However, it’s important to note that as of my knowledge cutoff in September 2022, **FSlint** was last updated in 2013 and may not be actively maintained or compatible with newer Linux distributions.

### Install FSlint on Linux

To install **FSlint** in Linux, use the following command as per your Linux distribution.

```
$ sudo apt install fslint         [On <strong>Debian, Ubuntu and Mint</strong>]
$ sudo yum install fslint         [On <strong>RHEL/CentOS/Fedora</strong> and <strong>Rocky/AlmaLinux</strong>]
$ sudo emerge -a sys-apps/fslint  [On <strong>Gentoo Linux</strong>]
$ sudo apk add fslint             [On <strong>Alpine Linux</strong>]
$ sudo pacman -S fslint           [On <strong>Arch Linux</strong>]
$ sudo zypper install fslint      [On <strong>OpenSUSE</strong>]    
```

<div class="entry-content" id="bkmrk-fslint-%E2%80%93-duplicate-f"><figure class="wp-caption aligncenter" id="bkmrk-fslint-%E2%80%93-duplicate-f-1">![FSlint - Duplicate File Finder for -Linux](https://www.tecmint.com/wp-content/uploads/2018/11/FSlint-Duplicate-File-Finder-for-Linux.png)<figcaption class="wp-caption-text" id="bkmrk-fslint-%E2%80%93-duplicate-f-2">FSlint – Duplicate File Finder for -Linux</figcaption></figure></div>##### Conclusion

These are very useful tools to find duplicated files on your Linux system, but you should be very careful when deleting such files.

If you are unsure if you need a file or not, it would be better to create a backup of that file and remember its directory prior to deleting it. If you have any questions or comments, please submit them in the comment section below.

# Archiso

<header class="mw-body-header vector-page-titlebar" id="bkmrk-"></header><div class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" id="bkmrk--1"><div class="mw-body-content mw-content-ltr" dir="ltr" lang="en"><div class="mw-parser-output"><div class="archwiki-template-meta-related-articles"></div></div></div></div>[Archiso](https://gitlab.archlinux.org/archlinux/archiso) is a highly-customizable tool for building Arch Linux live CD/USB ISO images. The [official images](https://archlinux.org/download/) are built with Archiso. It can be used as the basis for rescue systems, linux installers or other systems. This wiki article explains how to install Archiso, and how to configure it to control aspects of the resulting ISO image such as included packages and files. Technical requirements and build steps can be found in the [official project documentation](https://gitlab.archlinux.org/archlinux/archiso/-/tree/master/docs). Archiso is implemented with a number of bash scripts. The core component of Archiso is the *mkarchiso* command. Its options are documented in *mkarchiso -h* and not covered here.

## <span class="mw-headline" id="bkmrk-installation-1">Installation</span>

[Install](https://wiki.archlinux.org/title/Install "Install") the <span class="plainlinks archwiki-template-pkg">[archiso](https://archlinux.org/packages/?name=archiso)</span> or <span class="plainlinks archwiki-template-pkg">[archiso-git](https://aur.archlinux.org/packages/archiso-git/)</span><sup><small>AUR</small></sup> package. The <span class="plainlinks archwiki-template-pkg">[archiso-profiles](https://aur.archlinux.org/packages/archiso-profiles/)</span><sup><small>AUR</small></sup><sup>\[[broken link](https://wiki.archlinux.org/title/Help:Procedures#Fix_broken_package_links "Help:Procedures"): package not found\]</sup> package contains additional community-provided profiles.

## <span class="mw-headline" id="bkmrk-prepare-a-custom-pro-1">Prepare a custom profile</span>

Archiso comes with two profiles, **releng** and **baseline**.

<div class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" id="bkmrk-releng%C2%A0is-used-to-cr"><div class="mw-body-content mw-content-ltr" dir="ltr" lang="en"><div class="mw-parser-output">- **releng** is used to create the official monthly installation ISO. It can be used as a starting point for creating a customized ISO image.
- **baseline** is a minimalistic configuration, that includes only the bare minimum packages required to boot the live environment from the medium.

</div></div></div>To build an unmodified version of the profiles, skip to [\#Build the ISO](https://wiki.archlinux.org/title/Archiso#Build_the_ISO). Otherwise, if you wish to adapt or customize one of archiso's shipped profiles, copy it from `/usr/share/archiso/configs/<em>profile-name</em>/` to a writable directory with a name of your choice. For example:

```
$ cp -r /usr/share/archiso/configs/releng/ archlive
```

Proceed to the following sections to customize and build the custom profile.

### <span class="mw-headline" id="bkmrk-profile-structure-1">Profile structure</span>

An archiso profile contains configuration that defines the resulting ISO image. The profile structure is documented in `/usr/share/doc/archiso/README.profile.rst`[\[1\]](https://gitlab.archlinux.org/archlinux/archiso/-/blob/master/docs/README.profile.rst).

### <span class="mw-headline" id="bkmrk-selecting-packages-1">Selecting packages</span>

Edit `packages.x86_64` to select which packages are to be installed on the live system image, listing packages line by line.

#### <span class="mw-headline" id="bkmrk-custom-local-reposit-1">Custom local repository</span>

To add packages not located in standard Arch repositories (e.g. custom packages or packages from [AUR](https://wiki.archlinux.org/title/AUR "AUR")/[ABS](https://wiki.archlinux.org/title/ABS "ABS")), set up a [custom local repository](https://wiki.archlinux.org/title/Custom_local_repository "Custom local repository") and add your custom packages to it. Then add your repository to `pacman.conf` as follows:

```
<em>archlive</em>/pacman.conf
```

```
...
[<em>customrepo</em>]
SigLevel = Optional TrustAll
Server = file://<em>/path/to/customrepo</em>
...
```

<div class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" id="bkmrk-note%3A-the-ordering-w"><div class="mw-body-content mw-content-ltr" dir="ltr" lang="en"><div class="mw-parser-output"><div class="archwiki-template-box archwiki-template-box-note">**Note:**- The ordering within `pacman.conf` matters. To give top priority to your custom repository, place it above the other repository entries.
- This `pacman.conf` is only used for building the image. It will not be used in the live environment. To do this, see [\#Adding repositories to the image](https://wiki.archlinux.org/title/Archiso#Adding_repositories_to_the_image).

</div></div></div></div>#### <span class="mw-headline" id="bkmrk-packages-from-multil-1">Packages from multilib</span>

To install packages from the [multilib](https://wiki.archlinux.org/title/Multilib "Multilib") repository, simply uncomment that repository in `pacman.conf`.

### <span class="mw-headline" id="bkmrk-adding-files-to-imag-1">Adding files to image</span>

The airootfs directory is used as the starting point for the [root directory](https://en.wikipedia.org/wiki/Root_directory "wikipedia:Root directory") (`/`) of the live system on the image. All its contents will be copied over to the working directory before packages are installed.

Place any custom files and/or directories in the desired location under `airootfs/`. For example, if you have a set of iptables scripts on your current system you want to be used on you live image, copy them over as such:

```
$ cp -r /etc/iptables <em>archlive</em>/airootfs/etc
```

Similarly, some care is required for special configuration files that reside somewhere down the hierarchy. Missing parts of the directory structure can be simply created with <span class="plainlinks archwiki-template-man" title="$ man 1 mkdir">[mkdir(1)](https://man.archlinux.org/man/mkdir.1)</span>.

<div class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" id="bkmrk-tip%3A%C2%A0to-add-a-file-t"><div class="mw-body-content mw-content-ltr" dir="ltr" lang="en"><div class="mw-parser-output"><div class="archwiki-template-box archwiki-template-box-tip">**Tip:** To add a file to the install user's home directory, place it in `<em>archlive</em>/airootfs/root/`. To add a file to all other users home directories, place it in `<em>archlive</em>/airootfs/etc/skel/`.</div><div class="archwiki-template-box archwiki-template-box-note">**Note:** Custom files that conflict with those provided by packages will be overwritten unless a package specifies them as [backup files](https://wiki.archlinux.org/title/Pacman/Pacnew_and_Pacsave#Package_backup_files "Pacman/Pacnew and Pacsave").</div></div></div></div>By default, [permissions](https://wiki.archlinux.org/title/Permissions "Permissions") will be `644` for files and `755` for directories. All of them will be owned by the root user. To set different permissions or ownership for specific files and/or folders, use the `file_permissions` associative array in `profiledef.sh`. See [README.profile.rst](https://gitlab.archlinux.org/archlinux/archiso/-/blob/master/docs/README.profile.rst) for details.

### <span class="mw-headline" id="bkmrk-adding-repositories--1">Adding repositories to the image</span>

To add a repository that can be used in the live environment, create a [suitably modified](https://wiki.archlinux.org/title/Pacman#Repositories_and_mirrors "Pacman") `pacman.conf` and place it in `<em>archlive</em>/airootfs/etc/`.

If the repository also uses a key, place the key in `<em>archlive</em>/airootfs/usr/share/pacman/keyrings/`. The key file name must end with `.gpg`. Additionally, the key must be trusted. This can be accomplished by creating a GnuPG exported trust file in the same directory. The file name must end with `-trusted`. The first field is the key fingerprint, and the second is the trust. You can reference `/usr/share/pacman/keyrings/archlinux-trusted` for an example.

#### <span class="mw-headline" id="bkmrk-archzfs-example-1">archzfs example</span>

The files in this example are:

```
airootfs
├── etc
│   ├── pacman.conf
│   └── pacman.d
│       └── archzfs_mirrorlist
└── usr
    └── share
        └── pacman
            └── keyrings
                ├── archzfs.gpg
                └── archzfs-trusted
```

```
airootfs/etc/pacman.conf
```

```
...
[archzfs]
Include = /etc/pacman.d/archzfs_mirrorlist
...
```

```
airootfs/etc/pacman.d/archzfs_mirrorlist
```

```
Server = https://archzfs.com/$repo/$arch
Server = https://mirror.sum7.eu/archlinux/archzfs/$repo/$arch
Server = https://mirror.biocrafting.net/archlinux/archzfs/$repo/$arch
Server = https://mirror.in.themindsmaze.com/archzfs/$repo/$arch
Server = https://zxcvfdsa.com/archzfs/$repo/$arch
```

```
airootfs/usr/share/pacman/keyrings/archzfs-trusted
```

```
DDF7DB817396A49B2A2723F7403BD972F75D9D76:4:
```

`archzfs.gpg` itself can be obtained directly from the repository site at [https://archzfs.com/archzfs.gpg](https://archzfs.com/archzfs.gpg).

### <span class="mw-headline" id="bkmrk-kernel-1">Kernel</span>

Although both archiso's included profiles only have <span class="plainlinks archwiki-template-pkg">[linux](https://archlinux.org/packages/?name=linux)</span>, ISOs can be made to include other or even multiple [kernels](https://wiki.archlinux.org/title/Kernels "Kernels").

First, edit `packages.x86_64` to include kernel package names that you want. When *mkarchiso* runs, it will include all `<em>work_dir</em>/airootfs/boot/vmlinuz-*` and `<em>work_dir</em>/boot/initramfs-*.img` files in the ISO (and additionally in the FAT image used for UEFI booting).

[mkinitcpio](https://wiki.archlinux.org/title/Mkinitcpio "Mkinitcpio") presets by default will build fallback initramfs images. For an ISO, the main initramfs image would not typically include the `autodetect` hook, thus making an additional fallback image unnecessary. To prevent the creation of an fallback initramfs image, so that it does not take up space or slow down the build process, place a custom preset in `<em>archlive</em>/airootfs/etc/mkinitcpio.d/<em>pkgbase</em>.preset`. For example, for <span class="plainlinks archwiki-template-pkg">[linux-lts](https://archlinux.org/packages/?name=linux-lts)</span>:

```
<em>archlive</em>/airootfs/etc/mkinitcpio.d/linux-lts.preset
```

```
PRESETS=('archiso')

ALL_kver='/boot/vmlinuz-linux-lts'
ALL_config='/etc/mkinitcpio.conf'

archiso_image="/boot/initramfs-linux-lts.img"
```

Finally create [boot loader configuration](https://wiki.archlinux.org/title/Archiso#Boot_loader) to allow booting the kernel(s).

### <span class="mw-headline" id="bkmrk-boot-loader-1">Boot loader</span>

Archiso supports [syslinux](https://wiki.archlinux.org/title/Syslinux "Syslinux") for BIOS booting and [GRUB](https://wiki.archlinux.org/title/GRUB "GRUB") or [systemd-boot](https://wiki.archlinux.org/title/Systemd-boot "Systemd-boot") for UEFI booting. Refer to the articles of the boot loaders for information on their configuration syntax.

<div class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" id="bkmrk-tip%3A-the%C2%A0releng%C2%A0prof"><div class="mw-body-content mw-content-ltr" dir="ltr" lang="en"><div class="mw-parser-output"><div class="archwiki-template-box archwiki-template-box-tip">**Tip:**- The **releng** profile by default builds into an ISO that supports both BIOS and UEFI booting when burned to an optical disc using El Torito, or when written to a hard disk (or USB flash drive, or similar) using [Isohybrid](https://wiki.syslinux.org/wiki/index.php?title=Isohybrid).
- Due to the modular nature of isolinux, you are able to use lots of addons since all *.c32* files are copied and available to you. Take a look at the [official syslinux site](https://wiki.syslinux.org/wiki/index.php/SYSLINUX) and the [archiso git repo](https://gitlab.archlinux.org/archlinux/archiso/-/tree/master/configs/releng/syslinux). Using said addons, it is possible to make visually attractive and complex menus. See [\[2\]](https://wiki.syslinux.org/wiki/index.php?title=Comboot/menu.c32).

</div></div></div></div>mkarchiso expects that GRUB configuration is in the `grub` directory, [systemd-boot](https://wiki.archlinux.org/title/Systemd-boot "Systemd-boot") configuration is in the `efiboot` directory, and [syslinux](https://wiki.archlinux.org/title/Syslinux "Syslinux") configuration in `syslinux` and `isolinux` directories.

#### <span class="mw-headline" id="bkmrk-uefi-secure-boot-1">UEFI Secure Boot</span>

If you want to make your Archiso bootable on a UEFI Secure Boot enabled environment, you must use a signed boot loader. You can follow the instructions on [Secure Boot#Booting an installation medium](https://wiki.archlinux.org/title/Secure_Boot#Booting_an_installation_medium "Secure Boot").

### <span class="mw-headline" id="bkmrk-systemd-units-1">systemd units</span>

To [enable](https://wiki.archlinux.org/title/Enable "Enable") systemd services/sockets/timers for the live environment, you need to manually create the symbolic links just as `systemctl enable` does it.

For example, to enable `gpm.service`, which contains `WantedBy=multi-user.target`, run:

```
$ mkdir -p <em>archlive</em>/airootfs/etc/systemd/system/multi-user.target.wants
$ ln -s /usr/lib/systemd/system/gpm.service <em>archlive</em>/airootfs/etc/systemd/system/multi-user.target.wants/
```

The required symlinks can be found out by reading the systemd unit, or if you have the service installed, by [enabling](https://wiki.archlinux.org/title/Enabling "Enabling") it and observing the systemctl output.

#### <span class="mw-headline" id="bkmrk-login-manager-1">Login manager</span>

Starting X at boot is done by enabling your login manager's [systemd](https://wiki.archlinux.org/title/Systemd "Systemd") service. If you do not know which *.service* to enable, you can easily find out in case you are using the same program on the system you build your ISO on. Just use:

```
$ ls -l /etc/systemd/system/display-manager.service
```

Now create the same symlink in `<em>archlive</em>/airootfs/etc/systemd/system/`. For LXDM:

```
$ ln -s /usr/lib/systemd/system/lxdm.service <em>archlive</em>/airootfs/etc/systemd/system/display-manager.service
```

This will enable LXDM at system start on your live system.

#### <span class="mw-headline" id="bkmrk-changing-automatic-l-1">Changing automatic login</span>

The configuration for getty's automatic login is located under `airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf`.

You can modify this file to change the auto login user:

```
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin <em><strong>username</strong></em> --noclear %I 38400 linux
```

Or remove `autologin.conf` altogether to disable auto login.

If you are using the serial console, create `airootfs/etc/systemd/system/serial-getty@ttyS0.service.d/autologin.conf` with the following content instead:

```
[Service]
ExecStart=
ExecStart=-/sbin/agetty -o '-p -- \\u' --noclear --autologin root --keep-baud 115200,57600,38400,9600 - $TERM
```

### <span class="mw-headline" id="bkmrk-users-and-passwords-1">Users and passwords</span>

To create a [user](https://wiki.archlinux.org/title/User "User") which will be available in the live environment, you must manually edit `<em>archlive</em>/airootfs/etc/passwd`, `<em>archlive</em>/airootfs/etc/shadow`, `<em>archlive</em>/airootfs/etc/group` and `<em>archlive</em>/airootfs/etc/gshadow`.

<div class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" id="bkmrk-note%3A%C2%A0if-these-files"><div class="mw-body-content mw-content-ltr" dir="ltr" lang="en"><div class="mw-parser-output"><div class="archwiki-template-box archwiki-template-box-note">**Note:** If these files exist, they must contain the root user and group.</div></div></div></div>For example, to add a user `archie`. Add them to `<em>archlive</em>/airootfs/etc/passwd` following the <span class="plainlinks archwiki-template-man" title="$ man 5 passwd">[passwd(5)](https://man.archlinux.org/man/passwd.5)</span> syntax:

```
<em>archlive</em>/airootfs/etc/passwd
```

```
root:x:0:0:root:/root:/usr/bin/zsh
archie:x:1000:1000::/home/archie:/usr/bin/zsh
```

<div class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" id="bkmrk-note%3A%C2%A0the%C2%A0passwd%C2%A0fil"><div class="mw-body-content mw-content-ltr" dir="ltr" lang="en"><div class="mw-parser-output"><div class="archwiki-template-box archwiki-template-box-note">**Note:** The `passwd` file must end with a newline.</div></div></div></div>Add the user to `<em>archlive</em>/airootfs/etc/shadow` following the syntax of <span class="plainlinks archwiki-template-man" title="$ man 5 shadow">[shadow(5)](https://man.archlinux.org/man/shadow.5)</span>. If you want to define a password for the user, generate a password hash with `openssl passwd -6` and add it to the file. For example:

```
<em>archlive</em>/airootfs/etc/shadow
```

```
root::14871::::::
archie:$6$randomsalt$cij4/pJREFQV/NgAgh9YyBIoCRRNq2jp5l8lbnE5aLggJnzIRmNVlogAg8N6hEEecLwXHtMQIl2NX2HlDqhCU1:14871::::::
```

Otherwise, you may keep the password field empty, meaning that the user can log in with no password.

Add the user's group and the groups which they will part of to `<em>archlive</em>/airootfs/etc/group` according to <span class="plainlinks archwiki-template-man" title="$ man 5 group">[group(5)](https://man.archlinux.org/man/group.5)</span>. For example:

```
<em>archlive</em>/airootfs/etc/group
```

```
root:x:0:root
adm:x:4:archie
wheel:x:10:archie
uucp:x:14:archie
archie:x:1000:
```

Create the appropriate `<em>archlive</em>/airootfs/etc/gshadow` according to <span class="plainlinks archwiki-template-man" title="$ man 5 gshadow">[gshadow(5)](https://man.archlinux.org/man/gshadow.5)</span>:

```
<em>archlive</em>/airootfs/etc/gshadow
```

```
root:!*::root
archie:!*::
```

Make sure `/etc/shadow` and `/etc/gshadow` have the correct permissions:

```
<em>archlive</em>/profiledef.sh
```

```
...
file_permissions=(
  ...
  ["/etc/shadow"]="0:0:0400"
  ["/etc/gshadow"]="0:0:0400"
)
```

After package installation, *mkarchiso* will create all specified home directories for users listed in `<em>archlive</em>/airootfs/etc/passwd` and copy `<em>work_directory</em>/x86_64/airootfs/etc/skel/*` to them. The copied files will have proper user and group ownership.

### <span class="mw-headline" id="bkmrk-changing-the-distrib-1">Changing the distribution name used in the ISO</span>

Start by copying the file `/etc/os-release` into the `etc/` folder in the rootfs. Then, edit the file accordingly. You can also change the name inside of GRUB and syslinux.

## <span class="mw-headline" id="bkmrk-build-the-iso-1">Build the ISO</span>

Build an ISO which you can then burn to CD or USB by running:

```
# mkarchiso -v -w <em>/path/to/work_dir</em> -o <em>/path/to/out_dir</em> <em>/path/to/profile/</em>
```

<div class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" id="bkmrk--w%C2%A0specifies-the-wor"><div class="mw-body-content mw-content-ltr" dir="ltr" lang="en"><div class="mw-parser-output">- `-w` specifies the working directory. If the option is not specified, it will default to `work` in the current directory.
- `-o` specifies the directory where the built ISO image will be placed. If the option is not specified, it will default to `out` in the current directory.
- It should be noted the profile file `profiledef.sh` cannot be specified when running mkarchiso, only the path to the file.

</div></div></div>Replace `<em>/path/to/profile/</em>` with the path to your custom profile, or with `/usr/share/archiso/configs/releng/` if you are building an unmodified profile.

<div class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" id="bkmrk-tip%3A%C2%A0if-memory-allow"><div class="mw-body-content mw-content-ltr" dir="ltr" lang="en"><div class="mw-parser-output"><div class="archwiki-template-box archwiki-template-box-tip">**Tip:** If memory allows, it is preferred to place the working directory on [tmpfs](https://wiki.archlinux.org/title/Tmpfs "Tmpfs"). E.g.:</div></div></div></div>```
# mkarchiso -v -w /tmp/archiso-tmp <em>/path/to/profile/</em>
```

When run, the script will download and install the packages you specified to `<em>work_directory</em>/x86_64/airootfs`, create the kernel and init images, apply your customizations and finally build the ISO into the output directory.

### <span class="mw-headline" id="bkmrk-removal-of-work-dire-1">Removal of work directory</span>

<div class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" id="bkmrk-warning%3A%C2%A0if%C2%A0mkarchis"><div class="mw-body-content mw-content-ltr" dir="ltr" lang="en"><div class="mw-parser-output"><div class="archwiki-template-box archwiki-template-box-warning">**Warning:** If *mkarchiso* is interrupted, run <span class="plainlinks archwiki-template-man" title="$ man 8 findmnt">[findmnt(8)](https://man.archlinux.org/man/findmnt.8)</span> to make sure there are no mount binds before deleting it - otherwise, **you may lose data** (e.g. an external device mounted at `/run/media/<em>user</em>/<em>label</em>` gets bound within `work/x86_64/airootfs/run/media/<em>user</em>/<em>label</em>` during the build process).</div></div></div></div>The temporary files are copied into work directory. After successfully building the ISO , the work directory and its contents can be deleted. E.g.:

```
# rm -rf <em>/path/to/work_dir</em>
```

## <span class="mw-headline" id="bkmrk-using-the-iso-1">Using the ISO</span>

See [Installation guide#Prepare an installation medium](https://wiki.archlinux.org/title/Installation_guide#Prepare_an_installation_medium "Installation guide") for various options.

## <span class="mw-headline" id="bkmrk-test-the-iso-in-qemu-1">Test the ISO in QEMU</span>

[Install](https://wiki.archlinux.org/title/Install "Install") the optional dependencies <span class="plainlinks archwiki-template-pkg">[qemu-desktop](https://archlinux.org/packages/?name=qemu-desktop)</span> and <span class="plainlinks archwiki-template-pkg">[edk2-ovmf](https://archlinux.org/packages/?name=edk2-ovmf)</span>.

Use the convenience script `run_archiso` to run a built image using [QEMU](https://wiki.archlinux.org/title/QEMU "QEMU").

```
$ run_archiso -i <em>/path/to/</em>archlinux-<em>yyyy.mm.dd</em>-x86_64.iso
```

The virtual machine can also be run using UEFI emulation:

```
$ run_archiso -u -i <em>/path/to/</em>archlinux-<em>yyyy.mm.dd</em>-x86_64.iso
```

## <span class="mw-headline" id="bkmrk-tips-and-tricks-1">Tips and tricks</span>

### <span class="mw-headline" id="bkmrk-online-build-1">Online build</span>

If you do not have an arch system available or you need to setup Archiso from another GNU/Linux distribution, be aware there exists an [online builder](https://colab.research.google.com/github/tallero/archiso-profiles/).

### <span class="mw-headline" id="bkmrk-prepare-an-iso-for-a-1">Prepare an ISO for an installation via SSH</span>

<div class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" id="bkmrk-note%3A%C2%A0since%C2%A0archlinu"><div class="mw-body-content mw-content-ltr" dir="ltr" lang="en"><div class="mw-parser-output"><div class="archwiki-template-box archwiki-template-box-note">**Note:** Since `archlinux-2021.02.01-x86_64.iso`, [cloud-init support](https://gitlab.archlinux.org/archlinux/archiso/-/tree/bd2b861aa39167e4fc658a354071b95fbd050c0f/configs/releng/airootfs/etc/systemd/system/cloud-init.target.wants) is provided, and `sshd.service` is [enabled by default](https://gitlab.archlinux.org/archlinux/archiso/-/blob/bd2b861aa39167e4fc658a354071b95fbd050c0f/configs/releng/airootfs/etc/systemd/system/multi-user.target.wants/sshd.service).</div></div></div></div>To [install Arch Linux via SSH](https://wiki.archlinux.org/title/Install_Arch_Linux_via_SSH "Install Arch Linux via SSH") without any interaction with the system, an SSH public key must be placed in `authorized_keys`.

Adding the SSH key can either be done manually (explained here), or [by cloud-init](https://wiki.archlinux.org/title/Install_Arch_Linux_via_SSH#Installation_on_a_headless_server "Install Arch Linux via SSH").

To add the key manually, first [copy Archiso's releng profile](https://wiki.archlinux.org/title/Archiso#Prepare_a_custom_profile) to a writable directory. The following example uses `archlive`.

```
$ cp -r /usr/share/archiso/configs/<em>profile/</em> archlive
```

Create a `.ssh` directory in the home directory of the user which will be used to log in. The following example will be using the root user.

```
$ mkdir archlive/airootfs/root/.ssh
```

Add the SSH public key(s), which will be used to log in, to `authorized_keys`:

```
$ cat ~/.ssh/<em>key1</em>.pub >> archlive/airootfs/root/.ssh/authorized_keys
$ cat ~/.ssh/<em>key2</em>.pub >> archlive/airootfs/root/.ssh/authorized_keys
```

Set correct [permissions](https://wiki.archlinux.org/title/Permissions "Permissions") and ownership for the `.ssh` directory and the `authorized_keys` file:

```
archlive/profiledef.sh
```

```
...
file_permissions=(
  ...
  ["/root"]="0:0:0750"
  ["/root/.ssh"]="0:0:0700"
  ["/root/.ssh/authorized_keys"]="0:0:0600"
)
```

Finally [build the ISO](https://wiki.archlinux.org/title/Archiso#Build_the_ISO). Upon booting the ISO, [OpenSSH](https://wiki.archlinux.org/title/OpenSSH "OpenSSH") will start and it will be possible to log in using the corresponding SSH private key(s).

### <span class="mw-headline" id="bkmrk-automatically-connec-1">Automatically connect to a Wi-Fi network using iwd</span>

Create `/var/lib/iwd/` inside the profile's `airootfs` directory and set the correct permissions:

```
$ mkdir -p <em>archlive</em>/airootfs/var/lib/iwd
```

```
archlive/profiledef.sh
```

```
...
file_permissions=(
  ...
  ["/var/lib/iwd"]="0:0:0700"
)
```

Follow the instructions in [iwd#Network configuration](https://wiki.archlinux.org/title/Iwd#Network_configuration "Iwd") and <span class="plainlinks archwiki-template-man" title="$ man 5 iwd.network">[iwd.network(5)](https://man.archlinux.org/man/iwd.network.5)</span> to create a network configuration file for your Wi-Fi network.

Save the configuration file inside `<em>archlive</em>/airootfs/var/lib/iwd/`.

### <span class="mw-headline" id="bkmrk-adjusting-the-size-o-1">Adjusting the size of the root file system</span>

When installing packages in the live environment, for example on hardware requiring [DKMS](https://wiki.archlinux.org/title/DKMS "DKMS") modules, the default size of the root file system might not allow the download and installation of such packages due to its size.

<div class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" id="bkmrk-tip%3A%C2%A0see%C2%A0bbs%23210389%C2%A0"><div class="mw-body-content mw-content-ltr" dir="ltr" lang="en"><div class="mw-parser-output"><div class="archwiki-template-box archwiki-template-box-tip">**Tip:** See [BBS#210389](https://bbs.archlinux.org/viewtopic.php?pid=1628972#p1628972) for the reason behind the chosen size, and [FS#45618](https://bugs.archlinux.org/task/45618) for historical details.</div></div></div></div>It will manifest as the following error message when downloading files or installing packages in the live environment:

```
error: partition / too full: 63256 blocks needed, 61450 blocks free
error: not enough free disk space
error: failed to commit transaction (not enough free disk space)
Errors occurred: no packages were upgraded.
```

To adjust the size on the fly:

```
# mount -o remount,size=<em>SIZE</em> /run/archiso/cowspace
```

See <span class="plainlinks archwiki-template-man" title="$ man 5 tmpfs">[tmpfs(5) § size](https://man.archlinux.org/man/tmpfs.5#size)</span> for the possible parameters of `<em>SIZE</em>`.

To adjust the size at the bootloader stage (by pressing `e` or `Tab`) use the boot option:

```
cow_spacesize=<em>SIZE</em>
```

To adjust the size while building an image add the boot option to:

<div class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" id="bkmrk-efiboot%2Floader%2Fentri"><div class="mw-body-content mw-content-ltr" dir="ltr" lang="en"><div class="mw-parser-output">- `efiboot/loader/entries/*.cfg`
- `grub/*.cfg`
- `syslinux/*.cfg`

</div></div></div>The result can be checked with:

```
$ df -h
```

See [mkinitcpio-archiso boot parameters](https://gitlab.archlinux.org/archlinux/mkinitcpio/mkinitcpio-archiso/blob/master/docs/README.bootparams).

### <span class="mw-headline" id="bkmrk-encryption-1">Encryption</span>

In order for vanilla `mkarchiso` to produce encrypted images, [LUKS](https://wiki.archlinux.org/title/LUKS "LUKS") support in [archiso](https://gitlab.archlinux.org/archlinux/archiso/-/merge_requests/217), [encrypt](https://wiki.archlinux.org/title/Dm-crypt/System_configuration "Dm-crypt/System configuration") hook's compatibility in [mkinitcpio-archiso](https://gitlab.archlinux.org/archlinux/mkinitcpio/mkinitcpio-archiso/-/merge_requests/25) and nested `cryptkey`s support in <span class="plainlinks archwiki-template-pkg">[cryptsetup](https://archlinux.org/packages/?name=cryptsetup)</span> merge requests need to be approved.

Packages with such features already merged are <span class="plainlinks archwiki-template-pkg">[archiso-encryption](https://aur.archlinux.org/packages/archiso-encryption/)</span><sup><small>AUR</small></sup><sup>\[[broken link](https://wiki.archlinux.org/title/Help:Procedures#Fix_broken_package_links "Help:Procedures"): package not found\]</sup>, <span class="plainlinks archwiki-template-pkg">[mkinitcpio-archiso-encryption](https://aur.archlinux.org/packages/mkinitcpio-archiso-encryption/)</span><sup><small>AUR</small></sup><sup>\[[broken link](https://wiki.archlinux.org/title/Help:Procedures#Fix_broken_package_links "Help:Procedures"): package not found\]</sup> and <span class="plainlinks archwiki-template-pkg">[cryptsetup-nested-cryptkey](https://aur.archlinux.org/packages/cryptsetup-nested-cryptkey/)</span><sup><small>AUR</small></sup><sup>\[[broken link](https://wiki.archlinux.org/title/Help:Procedures#Fix_broken_package_links "Help:Procedures"): package not found\]</sup>.

To enable encryption on an existing profile:

<div class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" id="bkmrk-add%C2%A0%2Bluks%C2%A0to-the%C2%A0air"><div class="mw-body-content mw-content-ltr" dir="ltr" lang="en"><div class="mw-parser-output">- add `+luks` to the `airootfs_image_type` value in `profiledef.sh`;
- set an `encryption_key` in `profiledef.sh` (to use a key file instead of a password).
- enable the `encrypt` hook in `/etc/mkinitcpio.conf`;
- add AUR packages (or build custom replacements with the aforementioned sources) to `packages.x86_64`
- add the `keys` buildmode to the `buildmodes` array in `profiledef.sh` (to build a second ISO containing the key file that put on external storage is able to boot the system).

</div></div></div>Example configurations based on the `baseline` and `releng` profiles are available as `ebaseline` and `ereleng` in the <span class="plainlinks archwiki-template-pkg">[archiso-profiles](https://aur.archlinux.org/packages/archiso-profiles/)</span><sup><small>AUR</small></sup><sup>\[[broken link](https://wiki.archlinux.org/title/Help:Procedures#Fix_broken_package_links "Help:Procedures"): package not found\]</sup> package.

### <span class="mw-headline" id="bkmrk-google-compute-engin-1">Google Compute Engine images</span>

A Google Compute Engine-compatible `releng` compressed image is available as <span class="plainlinks archwiki-template-pkg">[archlinux-gce](https://aur.archlinux.org/packages/archlinux-gce/)</span><sup><small>AUR</small></sup><sup>\[[broken link](https://wiki.archlinux.org/title/Help:Procedures#Fix_broken_package_links "Help:Procedures"): package not found\]</sup>.

### <span class="mw-headline" id="bkmrk-libvirt-vm-configura-1">Libvirt VM configuration</span>

A [libvirt](https://wiki.archlinux.org/title/Libvirt "Libvirt") configuration which runs the `releng` image is available as <span class="plainlinks archwiki-template-pkg">[archlinux-libvirt](https://aur.archlinux.org/packages/archlinux-libvirt/)</span><sup><small>AUR</small></sup><sup>\[[broken link](https://wiki.archlinux.org/title/Help:Procedures#Fix_broken_package_links "Help:Procedures"): package not found\]</sup>.

## <span class="mw-headline" id="bkmrk-troubleshooting-1">Troubleshooting</span>

### <span class="mw-headline" id="bkmrk-window-manager-freez-1">Window manager freezes</span>

If you want to use a [window manager](https://wiki.archlinux.org/title/Window_manager "Window manager") in the Live CD, you must add the necessary and correct [video drivers](https://wiki.archlinux.org/title/Video_drivers "Video drivers"), or the WM may freeze on loading.

## <span class="mw-headline" id="bkmrk-see-also-1">See also</span>

<div class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" id="bkmrk-archiso-project-page"><div class="mw-body-content mw-content-ltr" dir="ltr" id="bkmrk-archiso-project-page-1" lang="en"><div class="mw-parser-output">- [Archiso project page](https://gitlab.archlinux.org/archlinux/archiso)
- [Official documentation](https://gitlab.archlinux.org/archlinux/archiso/-/tree/master/docs)
- [Arch Linux Release Engineering mailing list](https://lists.archlinux.org/mailman3/lists/arch-releng.lists.archlinux.org/)
- <a class="external text">\#archlinux-releng — Arch Linux Release Engineering IRC channel</a>
- [archiso-manager — the tool used for building the official monthly ISOs](https://github.com/pierres/archiso-manager)

</div></div></div>