This commit is contained in:
nm1 2026-11-04 00:33:23 +05:30
commit 74ae93a96e

View file

@ -0,0 +1,136 @@
offline installation of arch
To bundle packages in an Arch ISO file, modify pacstrap to install packages from the bundled version of the ISO rather than the Arch repositories, and to run a script that is also bundled in the ISO, you'll need to follow several steps. This process involves creating a custom Arch Linux ISO that includes your desired packages and scripts, then modifying the installation scripts to use these bundled resources. Below is an outline of how you can achieve this. Keep in mind, this is a high-level overview and certain steps might require deeper knowledge of Arch Linux, bash scripting, and the inner workings of the Arch ISO.
### Step 1: Download the Arch ISO
Download the latest Arch ISO from the official Arch Linux website.
### Step 2: Extract the ISO
Mount the ISO to a directory or extract its contents using tools like `7z` or `bsdtar` to a working directory.
```bash
mkdir archiso
bsdtar -xpf archlinux.iso -C archiso
```
### Step 3: Customize the AIROOTFS (Arch ISO Root File System)
This section includes adding your packages and scripts.
#### Adding Packages:
1. Custom packages that are not in the official repositories (or any AUR packages) should be built into `.pkg.tar.zst` files.
2. Copy these package files into the `archiso/airootfs/root/` directory (or a subdirectory). This way, they will be available on the live filesystem.
#### Adding Scripts:
1. Write your custom script that performs the desired tasks (e.g., post-installation setup).
2. Add this script to the `archiso/airootfs/root/` directory so that you can run it after booting into your custom ISO.
### Step 4: Modify Pacstrap (Optional)
Modifying `pacstrap` itself might not be necessary. Instead, consider using a script to manually install the packages using `pacman -U` command from your bundled packages:
1. Inside your custom script added in the previous step, navigate to where you've stored your packages (e.g., `/root/your_packages/`).
2. Install them using `pacman -U /path/to/package.pkg.tar.zst`
 
 
 
 
Customizing an Arch Linux ISO to include additional packages and modify the `pacstrap` script can be quite involved but entirely feasible. To add packages directly into your ISO and change how `pacstrap` operates to install these packages, you'll need to work with the Arch ISO build system and the `airootfs` (Arch ISO root filesystem) environment. Moreover, to run a custom script bundled in the ISO, you'll need to modify the system's startup process.
Here are the broad steps you'd follow to achieve your goals:
### 1. Prepare the Environment
First, ensure you have all the necessary tools and dependencies. You'll need the `archiso` package, which gives you the tools to create custom live CDs.
```bash
sudo pacman -S archiso
```
### 2. Create Your Working Directory
Copy the `archiso` profile to create your own customizable profile.
```bash
cp -r /usr/share/archiso/configs/releng/ ~/customiso
cd ~/customiso
```
### 3. Bundle Packages
To add packages directly to the ISO, modify the `packages.x86_64` file located in your custom ISO directory. Just add the names of the packages you wish to include. Note that these packages must be available in the regular Arch repositories or on your custom repository.
### 4. Modify the Pacstrap Script
The `pacstrap` script is part of the `arch-install-scripts` package, and it's not directly included in your ISO. `pacstrap` pulls packages from the official repositories during system installation. To change this functionality, you have several options:
- **Pre-install Packages**: Instead of modifying `pacstrap`, you could pre-install your desired packages into the `airootfs` root file system using the `mkarchiso` command. You can do this by specifying additional packages in the `packages.x86_64` file, as mentioned before, and they'll be installed when you build your ISO.
- If you insist on modifying `pacstrap` behavior, consider this: When `pacstrap` is run in the Arch ISO environment, it's actually pulling from the live environment (including any modifications you've made). If you want `pacstrap` to pull packages from a specific source, such as packages bundled within the ISO, you would likely need to create a local repository within your ISO and modify the `pacstrap` script (or a custom script called from `airootfs/root/.automated_script.sh`) to prioritize or exclusively use this repository.
### 5. Include and Run a Custom Script
To run a custom script from the ISO:
1. **Place Your Script**: Put your custom script in the `airootfs/root/` directory of your custom ISO project. This ensures it is part of the filesystem that is built into the ISO.
2. **Autostart Your Script**: Modify the `airootfs/root/customize_airootfs.sh` file to call your script upon boot. This script runs as the last step of the ISO customization process.
```bash
echo "/root/mycustomscript.sh" >> airootfs/root/.zlogin
```
Or, directly invoke your script from `airootfs/root/.automated_script.sh` if you are aiming for an automated installation.
### 6. Build Your ISO
Follow the `archiso` instructions to build your ISO. This typically involves running the `mkarchiso` command in your custom ISO directory.
```bash
sudo mkarchiso -v ~/customiso
```
### Final Notes
- **Handling Repositories**: Bundling packages inside the ISO for `pacstrap` to use is unconventional. Instead, consider either pre-installing packages or setting up a local repository within your ISO and having `pacstrap` use it. Handling dependencies correctly is crucial here.
- **Testing**: Always test your custom ISO in a safe environment (like a VM) before using it in a production context.
- **Custom `pacstrap` Logic**: If you modify how `pacstrap` operates (e.g., to use a local repository), you might need to also ensure that the mirrorlist or `pacman` configuration used respects this customization.
- **Resolution**: Depending on your precise use case (specific packages or scripts execution), there might be simpler or more straightforward approaches to achieving your goals, such as scripting post-install actions instead of deeply customizing the install process.
Customizing Arch Linux and automating installations can be a powerful way to create a tailored environment, but it requires careful planning and testing to ensure system stability and security.
 
 
 
```bash
# 1. Prepare your packages
# Download packages or use pacman to download them along with dependencies
# 2. Create a custom repository
# Create a directory to store your packages
mkdir custom_repo
# Add packages to your custom repository
repo-add custom_repo/custom.db.tar.gz <package1>.pkg.tar.zst <package2>.pkg.tar.zst ...
# 3. Modify the Arch Linux ISO
# Extract the Arch Linux ISO
mkdir arch_iso
bsdtar -xf archlinux.iso -C arch_iso
# Add your custom repository to the Arch Linux ISO
cp -r custom_repo arch_iso
# 4. Modify pacstrap
# Edit the pacstrap script in the arch_iso directory to use your custom repository
# 5. Create a script
# Create your script and make it executable
chmod +x your_script.sh
# 6. Bundle everything into a new ISO
# Create a new ISO with your modifications
xorriso -as mkisofs -iso-level 3 -full-iso9660-filenames -volid "Custom Arch Linux" -o custom_archlinux.iso arch_iso
# Clean up temporary files if necessary
```