You are not logged in.
Pages: 1
Is it possible to install Arch Linux on a .img file, without the target PC? Or the target PC with its peripherals is needed, or at least a virtual machine https://wiki.archlinux.org/title/Virtua … as_a_guest ?
The .img created, then just
sudo dd if=/a_path/.img of=/a_path/target_PC_drive?
But from the beginning
$ sudo fdisk /run/media/a/1637320b-b0c7-4f87-8b85-b635dee9595d/.img
Welcome to fdisk (util-linux 2.41.3).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
fdisk: cannot open /run/media/a/1637320b-b0c7-4f87-8b85-b635dee9595d/.img: Invalid argument...
Last edited by bivan (2026-03-15 12:45:09)
Arch Linux KDE
Offline
Yes, you can install it to any mounted block device. Including an image file. Then you can just copy the image file to the destination device using cp:
$ sudo cp /path/to/image/file.img /dev/deviceThe error you’re encountering is rather caused by the path simply not existing. Fdisk has no issues working with image files:
$ truncate -s 4G image
$ fdisk image
Welcome to fdisk (util-linux 2.41.3).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS (MBR) disklabel with disk identifier 0xda21a31c.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p):
Using default response p.
Partition number (1-4, default 1):
First sector (2048-8388607, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-8388607, default 8388607):
Created a new partition 1 of type 'Linux' and of size 4 GiB.
Command (m for help): w
The partition table has been altered.The latter steps also do not care if the block device is an actual disk or a loop-mounted file.
While deploying the image to the actual computer mind two things:
The target device must be big enough and extra space is lost too unless you grow the partition and the filesystem later.
It’s a byte-to-byte copy, which also copies UUIDs. You can’t deploy it this way twice on a single computer. This includes loop-mounting the image while it’s also written on the actual disk.
Offline
Nice! But how to format the partitions?
$ truncate -s 10GiB /run/media/a/e093bb97-7206-4076-9946-4a3e0fb78230/.img
fdisk /run/media/a/e093bb97-7206-4076-9946-4a3e0fb78230/.img<<<'g
n
133119
n
w'
mkfs.fat /run/media/a/e093bb97-7206-4076-9946-4a3e0fb78230/.img1
mkfs.ext4 /run/media/a/e093bb97-7206-4076-9946-4a3e0fb78230/.img2
Welcome to fdisk (util-linux 2.41.3).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS (MBR) disklabel with disk identifier 0x90a5cefb.
Command (m for help): Created a new GPT disklabel (GUID: 633EA8F3-22E7-44C0-837E-2BBE51E737CB).
Command (m for help): Partition number (1-128, default 1): First sector (2048-20971486, default 2048): Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-20971486, default 20969471):
Created a new partition 1 of type 'Linux filesystem' and of size 64 MiB.
Command (m for help): Partition number (2-128, default 2): First sector (133120-20971486, default 133120): Last sector, +/-sectors or +/-size{K,M,G,T,P} (133120-20971486, default 20969471):
Created a new partition 2 of type 'Linux filesystem' and of size 9.9 GiB.
Command (m for help): The partition table has been altered.
mkfs.fat 4.2 (2021-01-31)
mkfs.fat: unable to open /run/media/a/e093bb97-7206-4076-9946-4a3e0fb78230/.img1: No such file or directory
mke2fs 1.47.4 (6-Mar-2025)
The file /run/media/a/e093bb97-7206-4076-9946-4a3e0fb78230/.img2 does not exist and no size was specified.indeed:
$ fdisk -l /run/media/a/e093bb97-7206-4076-9946-4a3e0fb78230/.img
Disk /run/media/a/e093bb97-7206-4076-9946-4a3e0fb78230/.img: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 633EA8F3-22E7-44C0-837E-2BBE51E737CB
Device Start End Sectors Size Type
/run/media/a/e093bb97-7206-4076-9946-4a3e0fb78230/.img1 2048 133119 131072 64M Linux filesystem
/run/media/a/e093bb97-7206-4076-9946-4a3e0fb78230/.img2 133120 20969471 20836352 9.9G Linux filesystemArch Linux KDE
Offline
just calling it ".img" on what seems to be some external drive mounted by udisks2 you may should give at least some name - otherwise the leading dot marks it as hidden
Offline
No worry cryptearth, less is more.
Thanks, I did it!
sudo -i{
truncate -s 5GiB /run/media/a/8688e754-c2e4-40d1-a9c8-c205211ca8d9/.img
losetup -fP /run/media/a/8688e754-c2e4-40d1-a9c8-c205211ca8d9/.img
fdisk /dev/loop0<<<'g
n
133119
n
10485726
w'
mkfs.fat /dev/loop0p1
mkfs.f2fs /dev/loop0p2
mount /dev/loop0p2 /mnt
chmod 777 /mnt
mount --mkdir /dev/loop0p1 /mnt/efi
chmod 777 /mnt/efi
mkdir /mnt/efi/efi
mkdir /mnt/efi/efi/boot
mkdir /mnt/etc
mkdir /mnt/etc/mkinitcpio.d
echo -en ALL_kver='$(ls /usr/lib/modules)\'nPRESETS='\'n_uki=/efi/efi/boot/bootx64.efi>/mnt/etc/mkinitcpio.d/linux.preset
mkdir /mnt/etc/kernel
echo -n root=/dev/disk/by-id/usb-JetFlash_Transcend_32GB_01JDP4E3DVWKHULY-0:0-part2 rw>/mnt/etc/kernel/cmdline
pacstrap -icMK /mnt base linux linux-firmware-amdgpu linux-firmware-atheros dosfstools f2fs-tools man-db nano sudo plasma-meta<<<'
2
'
rm -r /tmp/!
arch-chroot /mnt bash -c "pacman -Qqd|pacman -Rsun --noconfirm -
systemctl enable NetworkManager plasmalogin
ln -s /usr/share/zoneinfo/UTC /etc/localtime
hwclock -w
echo -en /dev/disk/by-id/usb-JetFlash_Transcend_32GB_01JDP4E3DVWKHULY-0:0-part1 /efi auto>/etc/fstab
sed -i 15,17d /usr/lib/tmpfiles.d/var.conf
rm /var/log/wtmp /var/log/btmp /var/log/lastlog
useradd -m a
sed -i '1s/x//
\$s/x//' /etc/passwd
sed -i '/t A/s/^/# /
/L A/s/^..//' /etc/sudoers
sed -i /W/,/^$/{//!s/.//} /etc/pacman.d/mirrorlist
sed -i '/Ca/cCacheDir=/tmp/!
/b]/,+1s/.//' /etc/pacman.conf
echo -n unset HISTFILE>>/etc/bash.bashrc"
}|tee /run/media/a/8688e754-c2e4-40d1-a9c8-c205211ca8d9/.txt
umount /mnt/efi
umount /mntreboot (because the only error: umount: /mnt: target is busy. , why?)
cp /run/media/a/8688e754-c2e4-40d1-a9c8-c205211ca8d9/.img /dev/disk/by-id/usb-JetFlash_Transcend_32GB_01JDP4E3DVWKHULY-0:0boot the USB drive.
I noticed a difference between install by archlinux-x86_64.iso & here: bootx64.efi 59M or 28M, why?
Arch Linux KDE
Offline
Pages: 1