- ArchPKGs
- The Simplest Guide on raw-to-img Installation on Arch Linux/Manjaro/ArcoLinux
- Table of Contents
- Install link
- Install with Pacman (Package Manager) link
- Install with Yay (AUR Helper) link
- Update link
- Update with Pacman (Package Manager) link
- Update with Yay (AUR Helper) link
- Uninstall link
- Remove with Pacman (Package Manager) link
- Remove with Yay (AUR Helper) link
- More Guides
- Installing ocfs2-tools in Single Command on Arch Linux/Manjaro/Anarchy
- How to Install nessus-agent in One Command on Arch Linux (Manjaro/ArcoLinux)
- magma-hip Install (Update/Remove) Guide on Arch Linux, Manjaro and Anarchy
- How to Install flamegraph with Command Line on Arch-Based Linux (Manjaro, Garuda)
- Guide on Install, Update and Remove python-pynlpl-git on Arch Linux (Manjaro, RebornOS)
- How to Install python-pocketsphinx-git (Complete Guide) on Arch Linux (Manjaro, ArcoLinux)
- Modify raw image file in Linux
- Mount the image
- Dismount the image
- Modify ISO Images
- Reference
- Additional information
- Add space to the image
- Ubuntu x64 — Guide
- ¶Step 1 — Decompressing = DAT (sparse data) -> EXT4 raw image)
- ¶Step 2 — Decompress EXT4 (raw image) -> OUTPUT folder -> Compress EXT4 (raw image)
- ¶Step 3 — Converting = EXT4 (raw image) -> DAT (sparse data)
ArchPKGs
The Simplest Guide on raw-to-img Installation on Arch Linux/Manjaro/ArcoLinux
«Convert raw files to regular image files» is the developer’s gist of raw-to-img . To install and update this package ( raw-to-img ) from AUR (Arch User Repository) on Arch Linux and Arch-based Linux distributions (e.g. Manjaro, EndeavourOS, ArcoLinux, BlackArch) is relatively straightforward. This tutorial will be covering how to install/update/uninstall the package with either the built-in package manager pacman or an AUR helper (e.g. yay ).
Table of Contents
Install link
There are commonly two approaches to install raw-to-img from AUR. pacman is what you’re looking for if you’re a seasoned Linux user and have the idea of how packages are built. Otherwise, yay is an acceptable alternative to install packages without the necessity to review PKGBUILD and build packages with makepkg afterwards.
Install with Pacman (Package Manager) link
sudo pacman -S --needed git && git clone https://aur.archlinux.org/raw-to-img.git && cd raw-to-img && makepkg -si
- Install git if it is not already installed.
- clone the package’s git repository from upstream URL.
- cd into the folder that we just cloned.
- Use makepkg to build the package, then install it with pacman .
Install with Yay (AUR Helper) link
yay -S raw-to-img
Update link
Updating AUR packages is almost the same as installing them. All you have to do is pull it from source then re-build it. Nevertheless, it is still recommended to upgrade your whole system first with sudo pacman -Syu before updating any packages to avoid dependency issues, since Arch is a rolling-release Linux distribution.
Update with Pacman (Package Manager) link
Before running the command, make certain you’re in the directory of the repository you previously cloned:
git pull && makepkg -si
- pull from the package’s git repository.
- Build the package with makepkg . Also, it will automatically be updated with pacman afterwards.
Update with Yay (AUR Helper) link
Uninstall link
Removing packages is the simplest of these three,all you have to do is choose whether to remove the unused dependencies and the configuration files used by the package.
Remove with Pacman (Package Manager) link
sudo pacman -R raw-to-img
sudo pacman -Rs raw-to-img
sudo pacman -Rns raw-to-img
Remove with Yay (AUR Helper) link
yay -R raw-to-img
yay -Rs raw-to-img
yay -Rns raw-to-img
Learn more information about AUR packages installation or how to get yay , please refer to this tutorial.
More Guides
Installing ocfs2-tools in Single Command on Arch Linux/Manjaro/Anarchy
ocfs2-tools is «ocfs2 tool chain by Oracle, including mkfs, tunefs, fsck, debugfs and utilities for ocfs2» quoting from its profile. To install or uninstall ocfs2-tools from AUR (Arch User Repository) on Arch Linux, Manjaro, EndeavourOS, Garuda, ArcoLinux, Parabola and Anarchy is relatively uncomplicated. This tutorial will cover how to install, update and remove the package with either the default package manager pacman or an AUR helper (e.g. yay).
How to Install nessus-agent in One Command on Arch Linux (Manjaro/ArcoLinux)
Referring to nessus-agent’s own definition, it is «Nessus vulnerability scanner agent». To get this package (nessus-agent) from AUR (Arch User Repository) on Arch Linux and Arch-based Linux distros (e.g. Manjaro, EndeavourOS, RebornOS, BlackArch) is fairly easy. This tutorial will show you step-by-step how to install/update/uninstall the package with either the built-in package manager pacman or an AUR helper (e.g. yay).
magma-hip Install (Update/Remove) Guide on Arch Linux, Manjaro and Anarchy
extra/magma-hip is «Matrix Algebra on GPU and Multicore Architectures (with ROCm/HIP)» according to its description. To install this package (extra/magma-hip) from Arch official repository (Extra) on Arch Linux and Arch-based Linux distributions (e.g. Manjaro, EndeavourOS, Garuda, Parabola, Anarchy, RebornOS) is quite straightforward. This guide will cover how to install, update and uninstall the package with either the built-in package manager pacman or an AUR helper (e.g. yay).
How to Install flamegraph with Command Line on Arch-Based Linux (Manjaro, Garuda)
Quoting from flamegraph’s description, it is «Flame Graphs visualize profiled code». To install flamegraph from AUR (Arch User Repository) on Arch Linux, Manjaro, EndeavourOS and RebornOS is relatively simple. This guide will be covering how to install/update/remove the package with either the default package manager pacman or an AUR helper (e.g. yay).
Guide on Install, Update and Remove python-pynlpl-git on Arch Linux (Manjaro, RebornOS)
python-pynlpl-git is «Python Natural Language Processing Library (pronounce as: pineapple). Contains various modules useful for common, and less common, NLP tasks. Includes full FoLiA library.» based on its own outline. To install and update python-pynlpl-git from AUR (Arch User Repository) on Arch Linux and Arch-based distributions (e.g. Manjaro, EndeavourOS, Anarchy, Garuda, Artix) is pretty uncomplicated. This guide will show you step-by-step how to install, update and remove the package with either the built-in package manager pacman or an AUR helper (e.g. yay).
How to Install python-pocketsphinx-git (Complete Guide) on Arch Linux (Manjaro, ArcoLinux)
python-pocketsphinx-git is «Python interface to CMU SphinxBase and PocketSphinx libraries» according to its gist. To install or uninstall python-pocketsphinx-git from AUR (Arch User Repository) on Arch Linux, Manjaro, EndeavourOS, Anarchy and Artix is rather easy. This tutorial will be covering how to install/update/uninstall the package with either the built-in package manager pacman or an AUR helper (e.g. yay).
More guides… copyright 2023 ArchPKGs. All Rights Reserved.
Modify raw image file in Linux
In this section we talk about how to modify raw images.
Mount the image
First we have to mount the image to poke around its content. In a GUI you might just double-click the image file. This would normally mount the image in read-only mode which means you can check its content, but there’s not much more you can do about the content.
Instead you should mount it as read/write mode, which is the default mode of mount . But before any mount command, you should figure out which partition you want to mount since there are several partitions in that image. To do that you can use the fdisk command
A sample output could look like
raw_img_file.img: 128 MiB, 134217728 bytes, 262144 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: dos Disk identifier: 0xf110ee87 Device Boot Start End Sectors Size Id Type raw_img_file.img1 2048 100351 98304 48M 83 Linux raw_img_file.img2 100352 253951 153600 75M 83 Linux raw_img_file.img3 253952 262143 8192 4M 83 Linux
As we can see, firstly, it says that each sector is 512 bytes long (Sector size (logical/physical): 512 bytes / 512 bytes ), then that there’s a mountable partition that starts on sector 2048. If you want to mount that partition, you’ll have to pass that information along
mount -o loop,offset=1048576 raw_img_file.img /path/to/img/mount/point
Please check the mannual page of mount for details about these parameters.
Dismount the image
After done modifying the content, dismount the image with
umount /path/to/img/mount/point
And then you can copy it to a USB flash drive with dd
dd bs=1M if=raw_img_file.img of=/dev/sdX
where sdX is wherever your system maps your USB driver.
Modify ISO Images
For an ISO image, you have to copy its content out, edit as you wish, then re-burn the whole image.
Reference
Additional information
Add space to the image
This section is just copied from a web post. I haven’t tried it yet since the tool it uses works for ext2/3/4 file systems, not the one my image file is using.
You might find there’s not many space left on the img file for your modification
df -h /path/to/img/mount/point Filesystem Size Used Avail Use% Mounted on /dev/loop0 3.1G 2.7G 265M 92%
You have to make the mounted partition bigger and this is where things get sticky.
Use parted to check some basic info about this image
# parted ArduinoOS_Redux.x86_64-0.0.XX.raw GNU Parted 3.2 Using /home/[your user]/ArduinoOS_Redux.x86_64-0.0.XX.raw Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) print free Model: (file) Disk /home/[your user]/ArduinoOS_Redux.x86_64-0.0.XX.raw: 3427MB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 32.3kB 1049kB 1016kB Free Space 1 1049kB 3427MB 3426MB primary ext3 boot, type=83
The ~1MB free space at the beginning is actually the partition info. We have to add space at the end.
dd if=/dev/zero bs=1M count=512 >> ArduinoOS_Redux.x86_64-0.0.XX.raw
# parted ArduinoOS_Redux.x86_64-0.0.XX.raw GNU Parted 3.2 Using /home/[your user]/ArduinoOS_Redux.x86_64-0.0.XX.raw Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) print free Model: (file) Disk /home/[your user]/ArduinoOS_Redux.x86_64-0.0.XX.raw: 3964MB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 32.3kB 1049kB 1016kB Free Space 1 1049kB 3427MB 3426MB primary ext3 boot, type=83 3427MB 3964MB 537MB Free Space (parted) resizepart 1 3964MB (parted) print free Model: (file) Disk /home/[your user]/ArduinoOS_Redux.x86_64-0.0.XX.raw: 3964MB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 32.3kB 1049kB 1016kB Free Space 1 1049kB 3964MB 3963MB primary ext3 boot, type=83
parted ‘s resizepart instruction takes two parameters: the partition to resize — in this case 1 — and the new end of the partition. As you saw two listings up, the empty space you created ends at the 3964MB mark, so you use that with resizepart .
But, resizepart works fine with real disks, for raw image, this is not enough. Therefore comes the kpartx tool. It take a raw image of a disc and create a “virtual device” in /dev/mapper that can then be manipulated as a real device with real partitions:
# kpartx -a ArduinoOS_Redux.x86_64-0.0.XX.raw
The -a option adds an entry, so if you now look under /dev/mapper :
$ ls /dev/mapper/ control loop0p1
We first check the virtual partition:
# e2fsck -f -y -v -C 0 /dev/mapper/loop0p1 e2fsck 1.42.13 (17-May-2015) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information 86010 inodes used (41.10%, out of 209248) 5413 non-contiguous files (6.3%) 83 non-contiguous directories (0.1%) # of inodes with ind/dind/tind blocks: 5404/51/0 726741 blocks used (86.89%, out of 836352) 0 bad blocks 1 large file 69360 regular files 8272 directories 7 character device files 4 block device files 0 fifos 7797 links 8358 symbolic links (8166 fast symbolic links) 0 sockets ------------ 93798 files
Then we try to resizing the file system
# resize2fs -p /dev/mapper/loop0p1 resize2fs 1.42.13 (17-May-2015) Resizing the filesystem on /dev/mapper/loop0p1 to 967424 (4k) blocks. Begin pass 1 (max = 4) Extending the inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX The filesystem on /dev/mapper/loop0p1 is now 967424 (4k) blocks long.
We can now delete the virtual device
# kpartx -d ArduinoOS_Redux.x86_64-0.0.XX.raw
Ubuntu x64 — Guide
¶Step 1 — Decompressing = DAT (sparse data) -> EXT4 raw image)
- = input, system.transfer.list from rom zip
- = input, system.new.dat from rom zip
- = output ext4 raw image file
./sdat2img.py system.transfer.list system.new.dat system.img
by running this command you will get as output the file my_new_system.img which is the raw ext4 image.
¶Step 2 — Decompress EXT4 (raw image) -> OUTPUT folder -> Compress EXT4 (raw image)
Now we need to mount or ext4 raw image into an output folder so we can see apks/jars etc.
To do this we need to type this command:
sudo mount -t ext4 -o loop system.img output/
As you can see there is a new folder called output which we can edit/modify/delete your files (not able to? see here)
Now we need to compress it back to a raw ext4 image, to do this we need the make_ext4fs binary. Make sure you have thefile_contexts file (taken from the Rom zip) inside the make_ext4fs path. Then type this (got issues? see here)
./make_ext4fs -T 0 -S file_contexts -l 1073741824 -a system system_new.img output/
You will get the new raw ext4 image called ‘system_new.img’ ready for the next step.
¶Step 3 — Converting = EXT4 (raw image) -> DAT (sparse data)
Now we need the rimg2sdat binary, the usage is very simple:
./rimg2sdat my_new_system.img
As you can see the output is composed by system.transfer.list, (system.patch.dat) & system.new.dat, ready to be replaced inside your Rom zip.