Last active
April 14, 2025 07:11
Revisions
-
NoteAfterNote revised this gist
Apr 14, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -533,7 +533,7 @@ Command successful. /data/data/com.termux/files/home/storage/external-1/test-image6: LUKS encrypted file, ver 2, header size 16384, ID 645, algo sha256, salt 0x74237f9e40e3601..., UUID: f46ca423-7944-4019-9f9c-ae44f60d2dcb, crc 0xc6f5d5ea71671d8f..., at 0x1000 {"keyslots":{"0":{"type":"luks2","key_size":64,"af":{"type":"luks1","stripes":4000,"hash":"sha256"},"area":{"type":"raw","offse ~ $ ~ $ ~ $ cryptsetup reencrypt --verbose --type=luks2 --disable-keyring --disable-locks --header $HOME/storage/external-1/luks-header-test-image6 --decrypt $HOME/storage/external-1/test-image6 WARNING! ======== -
NoteAfterNote revised this gist
Apr 14, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -533,7 +533,7 @@ Command successful. /data/data/com.termux/files/home/storage/external-1/test-image6: LUKS encrypted file, ver 2, header size 16384, ID 645, algo sha256, salt 0x74237f9e40e3601..., UUID: f46ca423-7944-4019-9f9c-ae44f60d2dcb, crc 0xc6f5d5ea71671d8f..., at 0x1000 {"keyslots":{"0":{"type":"luks2","key_size":64,"af":{"type":"luks1","stripes":4000,"hash":"sha256"},"area":{"type":"raw","offse ~ $ ~ $ ~ $ cryptsetup reencrypt --verbose --type=luks2 --disable-keyring --disable-locks --header $HOME/storage/external-1/luks-header-test-image6 --reduce-device-size 32M --decrypt $HOME/storage/external-1/test-image6 WARNING! ======== -
NoteAfterNote revised this gist
Apr 7, 2025 . 1 changed file with 89 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -599,7 +599,96 @@ debugfs: quit e2fsck 1.47.2 (1-Jan-2025) /data/data/com.termux/files/home/storage/external-1/test-image6: clean, 27/327680 files, 42406/1310720 blocks ~ $ ~ $ ~ $ ~ $ dd if=/dev/zero of=$HOME/storage/external-1/test-image7 bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 37.2427 s, 28.8 MB/s ~ $ ~ $ echo $PREFIX /data/data/com.termux/files/usr ~ $ ~ $ du -hsc $PREFIX/etc $PREFIX/bin /storage/emulated/0/Download/directory9 2.6M /data/data/com.termux/files/usr/etc 191M /data/data/com.termux/files/usr/bin 64M /storage/emulated/0/Download/directory9 257M total ~ $ ~ $ echo $HOME /data/data/com.termux/files/home ~ $ ~ $ pwd /data/data/com.termux/files/home ~ $ ~ $ tar -c -f - -C $PREFIX ./etc -C /storage/emulated/0/Download ./directory9 -C $HOME ./directory* -C $PREFIX ./bin | mkfs.ext4 -m0 -d - $HOME/storage/external-1/test-image7 1G mke2fs 1.47.2 (1-Jan-2025) Creating filesystem with 262144 4k blocks and 65536 inodes Filesystem UUID: 76b2a207-1a29-44c7-a2af-11c848839dbe Superblock backups stored on blocks: 32768, 98304, 163840, 229376 Allocating group tables: done Writing inode tables: done Creating journal (8192 blocks): done Copying files into the device: done Writing superblocks and filesystem accounting information: done ~ $ ~ $ ~ $ file $HOME/storage/external-1/test-image7 /data/data/com.termux/files/home/storage/external-1/test-image7: Linux rev 1.0 ext4 filesystem data, UUID=76b2a207-1a29-44c7-a2af-11c848839dbe (extents) (64bit) (large files) (huge files) ~ $ ~ $ ~ $ fsck.ext4 $HOME/storage/external-1/test-image7 e2fsck 1.47.2 (1-Jan-2025) /data/data/com.termux/files/home/storage/external-1/test-image7: clean, 1503/65536 files, 76825/262144 blocks ~ $ ~ $ ~ $ debugfs $HOME/storage/external-1/test-image7 debugfs 1.47.2 (1-Jan-2025) debugfs: ls 2 (12) . 2 (12) .. 11 (20) lost+found 13 (12) etc 296 (20) directory9 301 (20) directory1 303 (20) directory2 305 (20) directory3 307 (20) directory4 309 (20) directory5 311 (20) directory6 313 (20) directory7 315 (20) directory8 316 (3848) bin debugfs: debugfs: ls etc 13 (12) . 2 (12) .. 14 (16) profile 15 (12) apt 29 (16) inputrc 30 (12) tls 34 (20) krb5.conf 35 (24) termux-login.sh 36 (16) unbound 38 (20) netconfig 39 (24) motd-playstore 40 (12) motd 41 (20) bash.bashrc 42 (20) profile.d 49 (20) alternatives 109 (16) nanorc 110 (20) resolv.conf 111 (20) pine.conf 112 (16) hosts 113 (16) apache2 132 (16) motd.sh 133 (24) motd.dpkg-dist 134 (16) termux 216 (16) lynx.cfg 217 (32) motd-playstore.dpkg- dist 218 (28) bash.bashrc.dpkg-old 219 (20) xattr.conf 220 (20) lftp.conf 221 (16) fonts 252 (20) neomuttrc 253 (16) pip.conf 254 (28) bash_completion.d 259 (16) lynx.lss 260 (16) Muttrc 261 (20) mke2fs.conf 262 (16) screenrc 263 (20) mime.types 264 (12) ssh 278 (16) wgetrc 279 (16) dbus-1 282 (12) xdg 287 (16) gtk-3.0 289 (16) puls e 294 (20) Muttrc.dist 295 (3292) bindresvport.blacklist debugfs: debugfs: ls directory3 305 (12) . 2 (12) .. 306 (4060) file3.txt debugfs: debugfs: ls directory9 296 (12) . 2 (12) .. 297 (40) alpine-virt-3.21.3-x86_64.iso 298 (44) alpine-virt-3.21.3-x86_64.iso.asc 299 (44) alpine-virt-3.21.3-x86_64.iso.sha256 300 (3932) alpine-virt-3.21.3-x86_64.iso.sha512 debugfs: debugfs: dump directory9/alpine-virt-3.21.3-x86_64.iso alpine-virt-3.21.3-x86_64.iso debugfs: quit ~ $ ~ $ sha512sum -c /storage/emulated/0/Download/directory9/alpine-virt-3.21.3-x86_64.iso.sha512 alpine-virt-3.21.3-x86_64.iso: OK ~ $ ``` -
NoteAfterNote revised this gist
Apr 7, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ <h3 align="center">NoteAfterNote-11<br>Using a tar archive with "mkfs.ext4 -d" to populate the ext4 filesystem<br>Published: April 7, 2025<br>Link: https://gist.github.com/NoteAfterNote/65a139ce70cbf27c4875aaaee0e779cc<p><br></p></h3> ### Here's the description for "-d root-directory|tarball" from the mkfs.ext4 man page: -
NoteAfterNote created this gist
Apr 7, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,617 @@ <h3 align="center">NoteAfterNote-11<br>Using a tar archive with "mkfs.ext4 -d" to populate the ext4 filesystem<br>Published: April 7, 2025<br>Link: ttps<p><br></p></h3> ### Here's the description for "-d root-directory|tarball" from the mkfs.ext4 man page: "Copy the contents of the given directory or tarball into the root directory of the file system. Tarball input is only available if mke2fs was compiled with libarchive support enabled and if the libarchive shared library is available at run-time. The special value "-" will read a tarball from standard input." ### Termux: Enable Wake-Lock * man mkfs.ext4 * man tar * man fsck.ext4 * man cryptsetup ### Smartphone-1-Is-Android-10: Configuration * Operating system (OS) is Android 10 * The Android 10 smartphone is not rooted and it has never been rooted * Eight cores/CPUs * Two (2) gigabytes of RAM * One USB-C (USB Type-C) 2.0 port * Adoptable storage is not available * External storage, a card is plugged inside the smartphone: /storage/NUMBER-REMOVED/Android/data/com.termux/files accessed as $HOME/storage/external-1 * Internal storage: /data/data/com.termux/files ``` ~ $ neofetch --stdout | grep OS OS: Android 10 armv8l ~ $ hwinfo --cpu | grep 'Platform' Platform: "Qualcomm Technologies, Inc SDM439" Platform: "Qualcomm Technologies, Inc SDM439" Platform: "Qualcomm Technologies, Inc SDM439" Platform: "Qualcomm Technologies, Inc SDM439" Platform: "Qualcomm Technologies, Inc SDM439" Platform: "Qualcomm Technologies, Inc SDM439" Platform: "Qualcomm Technologies, Inc SDM439" Platform: "Qualcomm Technologies, Inc SDM439" ~ $ inxi --machine Machine: Type: ARM System: Qualcomm SDM439 ~ $ lscpu Architecture: armv8l Byte Order: Little Endian CPU(s): 8 On-line CPU(s) list: 0-7 Vendor ID: ARM Model name: Cortex-A53 Model: 4 Thread(s) per core: 1 Core(s) per socket: 4 Socket(s): 2 Stepping: r0p4 CPU(s) scaling MHz: 60% CPU max MHz: 2016.0000 CPU min MHz: 768.0000 BogoMIPS: 38.40 Flags: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt lpae evtstrm aes pmull sha1 sha2 crc32 Caches (sum of all): L1d: 256 KiB (8 instances) L1i: 256 KiB (8 instances) L2: 1.5 MiB (2 instances) ~ $ apt info e2fsprogs cryptsetup manpages | grep -Ev 'Maintainer:|Installed-Size:|Breaks:|Replaces:|Download-Size:|APT-Sources:' WARNING: apt does not have a stable CLI interface. Use with caution in scripts. Package: e2fsprogs Version: 1.47.2-1 Depends: libarchive, libblkid, libuuid Homepage: https://e2fsprogs.sourceforge.net APT-Manual-Installed: yes Description: EXT 2/3/4 filesystem utilities Package: cryptsetup Version: 2.7.5 Depends: libpopt, libblkid, libuuid, libcryptsetup (= 2.7.5) Homepage: https://gitlab.com/cryptsetup/cryptsetup/ APT-Manual-Installed: yes Description: Userspace setup tool for transparent encryption of block devices using dm-crypt Package: manpages Version: 6.13 Provides: linux-man-pages Depends: man Conflicts: linux-man-pages Homepage: https://www.kernel.org/doc/man-pages/ APT-Manual-Installed: yes Description: Man pages for linux kernel and C library interfaces ~ $ termux-info | grep -E 'TERMUX_APK_RELEASE|TERMUX_VERSION' TERMUX_APK_RELEASE=GITHUB TERMUX_VERSION=0.118.0 ~ $ tar --version | head -1 tar (GNU tar) 1.35 ``` ### Using "mkfs.ext4 -d root-directory|tarball" ``` ~ $ cd $HOME ~ $ ~ $ mkdir directory1 directory2 directory3 ~ $ mkdir directory4 directory5 directory6 ~ $ touch directory4/file4.txt directory5/file5.txt ~ $ touch directory6/file6.txt ~ $ touch directory1/file1.txt directory2/file2.txt ~ $ touch directory3/file3.txt ~ $ tree directory* directory1 └── file1.txt directory2 └── file2.txt directory3 └── file3.txt directory4 └── file4.txt directory5 └── file5.txt directory6 └── file6.txt 6 directories, 6 files ~ $ ~ $ ~ $ ~ $ fallocate --verbose --length 100M test.image1 test.image1: 100 MiB (104857600 bytes) allocated. ~ $ ~ $ mkfs.ext4 -m 0 -d directory6 test.image1 mke2fs 1.47.2 (1-Jan-2025) Discarding device blocks: done Creating filesystem with 102400 1k blocks and 25584 inodes Filesystem UUID: e6668073-3fab-496b-b517-b8415a6a6ccd Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Allocating group tables: done Writing inode tables: done Creating journal (4096 blocks): done Copying files into the device: done Writing superblocks and filesystem accounting information: done ~ $ ~ $ debugfs test.image1 debugfs 1.47.2 (1-Jan-2025) debugfs: ls 2 (12) . 2 (12) .. 11 (20) lost+found 13 (968) file6.txt debugfs: quit ~ $ ~ $ ~ $ ~ $ tar --verbose -c -f test1.tar ./directory* ./directory1/ ./directory1/file1.txt ./directory2/ ./directory2/file2.txt ./directory3/ ./directory3/file3.txt ./directory4/ ./directory4/file4.txt ./directory5/ ./directory5/file5.txt ./directory6/ ./directory6/file6.txt ~ $ ~ $ file test1.tar test1.tar: POSIX tar archive (GNU) ~ $ ~ $ tar --verbose -c -f test2 ./directory1 ./directory2 ./directory3 ./directory4 ./directory5 ./directory6 ./directory1/ ./directory1/file1.txt ./directory2/ ./directory2/file2.txt ./directory3/ ./directory3/file3.txt ./directory4/ ./directory4/file4.txt ./directory5/ ./directory5/file5.txt ./directory6/ ./directory6/file6.txt ~ $ ~ $ ~ $ file test2 test2: POSIX tar archive (GNU) ~ $ ~ $ fallocate --verbose --length 100M test.image2 test.image2: 100 MiB (104857600 bytes) allocated. ~ $ ~ $ mkfs.ext4 -m 0 -d test1.tar test.image2 mke2fs 1.47.2 (1-Jan-2025) Discarding device blocks: done Creating filesystem with 102400 1k blocks and 25584 inodes Filesystem UUID: 23c51adf-2f0e-4a08-9608-18a3d4836123 Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Allocating group tables: done Writing inode tables: done Creating journal (4096 blocks): done Copying files into the device: done Writing superblocks and filesystem accounting information: done ~ $ ~ $ debugfs test.image2 debugfs 1.47.2 (1-Jan-2025) debugfs: ls 2 (12) . 2 (12) .. 11 (20) lost+found 13 (20) directory1 15 (20) directory2 17 (20) directory3 19 (20) directory4 21 (20) directory5 23 (868) directory6 debugfs: ls directory1 13 (12) . 2 (12) .. 14 (988) file1.txt debugfs: ls directory2 15 (12) . 2 (12) .. 16 (988) file2.txt debugfs: ls directory3 17 (12) . 2 (12) .. 18 (988) file3.txt debugfs: ls directory4 19 (12) . 2 (12) .. 20 (988) file4.txt debugfs: ls directory5 21 (12) . 2 (12) .. 22 (988) file5.txt debugfs: ls directory6 23 (12) . 2 (12) .. 24 (988) file6.txt debugfs: quit ~ $ ~ $ ~ $ ~ $ fallocate --verbose --length 100M test.image3 test.image3: 100 MiB (104857600 bytes) allocated. ~ $ ~ $ mkfs.ext4 -m 0 -d test2 test.image3 mke2fs 1.47.2 (1-Jan-2025) Discarding device blocks: done Creating filesystem with 102400 1k blocks and 25584 inodes Filesystem UUID: 432a65b6-01c2-4e24-a13e-99f5433e4565 Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Allocating group tables: done Writing inode tables: done Creating journal (4096 blocks): done Copying files into the device: done Writing superblocks and filesystem accounting information: done ~ $ ~ $ debugfs test.image3 debugfs 1.47.2 (1-Jan-2025) debugfs: ls 2 (12) . 2 (12) .. 11 (20) lost+found 13 (20) directory1 15 (20) directory2 17 (20) directory3 19 (20) directory4 21 (20) directory5 23 (868) directory6 debugfs: ls directory6 23 (12) . 2 (12) .. 24 (988) file6.txt debugfs: ls directory5 21 (12) . 2 (12) .. 22 (988) file5.txt debugfs: ls directory4 19 (12) . 2 (12) .. 20 (988) file4.txt debugfs: ls directory3 17 (12) . 2 (12) .. 18 (988) file3.txt debugfs: ls directory2 15 (12) . 2 (12) .. 16 (988) file2.txt debugfs: ls directory1 13 (12) . 2 (12) .. 14 (988) file1.txt debugfs: quit ~ $ ~ $ ~ $ ~ $ fallocate --verbose --length 100M test.image4 test.image4: 100 MiB (104857600 bytes) allocated. ~ $ ~ $ mkdir directory7 directory8 ~ $ touch directory7/file7.txt ~ $ ~ $ tar --verbose -c -f - ./directory7 ./directory8 | mkfs.ext4 -m 0 -d - test.image4 mke2fs 1.47.2 (1-Jan-2025) ./directory7/ ./directory7/file7.txt ./directory8/ Discarding device blocks: done Creating filesystem with 102400 1k blocks and 25584 inodes Filesystem UUID: 2684ed18-9841-4515-9267-d84fc6e65bb4 Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Allocating group tables: done Writing inode tables: done Creating journal (4096 blocks): done Copying files into the device: done Writing superblocks and filesystem accounting information: done ~ $ ~ $ debugfs test.image4 debugfs 1.47.2 (1-Jan-2025) debugfs: ls 2 (12) . 2 (12) .. 11 (20) lost+found 13 (20) directory7 15 (948) directory8 debugfs: ls directory7 13 (12) . 2 (12) .. 14 (988) file7.txt debugfs: ls directory8 15 (12) . 2 (1000) .. debugfs: quit ~ $ ~ $ tree directory* directory1 └── file1.txt directory2 └── file2.txt directory3 └── file3.txt directory4 └── file4.txt directory5 └── file5.txt directory6 └── file6.txt directory7 └── file7.txt directory8 7 directories, 7 files ~ $ ~ $ ~ $ # ~ $ # Note: "./directory7/" is not in FILE1234 ~ $ # ~ $ tar --verbose -c -f FILE1234 ./directory1 ./directory7/file7.txt ./directory1/ ./directory1/file1.txt ./directory7/file7.txt ~ $ ~ $ file FILE1234 FILE1234: POSIX tar archive (GNU) ~ $ ~ $ fallocate --verbose --length 100M test.image5 test.image5: 100 MiB (104857600 bytes) allocated. ~ $ ~ $ mkfs.ext4 -m 0 -d FILE1234 test.image5 mke2fs 1.47.2 (1-Jan-2025) Discarding device blocks: done Creating filesystem with 102400 1k blocks and 25584 inodes Filesystem UUID: 668a6fc9-454a-4f64-9528-42cd9f2cac77 Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Allocating group tables: done Writing inode tables: done Creating journal (4096 blocks): done Copying files into the device: __populate_fs_from_tar: File not found by ext2_lookup cannot find directory "./directory7" to create "file7.txt" mkfs.ext4: File not found by ext2_lookup while populating file system ~ $ ~ $ ~ $ ~ $ file test.image1 test.image1: Linux rev 1.0 ext4 filesystem data, UUID=e6668073-3fab-496b-b517-b8415a6a6ccd (extents) (64bit) (large files) (huge files) ~ $ ~ $ fsck.ext4 test.image1 e2fsck 1.47.2 (1-Jan-2025) test.image1: clean, 13/25584 files, 12113/102400 blocks ~ $ ~ $ ~ $ ~ $ file test.image2 test.image2: Linux rev 1.0 ext4 filesystem data, UUID=23c51adf-2f0e-4a08-9608-18a3d4836123 (extents) (64bit) (large files) (huge files) ~ $ ~ $ fsck.ext4 test.image2 e2fsck 1.47.2 (1-Jan-2025) test.image2: clean, 24/25584 files, 12119/102400 blocks ~ $ ~ $ ~ $ ~ $ file test.image3 test.image3: Linux rev 1.0 ext4 filesystem data, UUID=432a65b6-01c2-4e24-a13e-99f5433e4565 (extents) (64bit) (large files) (huge files) ~ $ ~ $ fsck.ext4 test.image3 e2fsck 1.47.2 (1-Jan-2025) test.image3: clean, 24/25584 files, 12119/102400 blocks ~ $ ~ $ ~ $ ~ $ file test.image4 test.image4: Linux rev 1.0 ext4 filesystem data, UUID=2684ed18-9841-4515-9267-d84fc6e65bb4 (extents) (64bit) (large files) (huge files) ~ $ ~ $ fsck.ext4 test.image4 e2fsck 1.47.2 (1-Jan-2025) test.image4: clean, 15/25584 files, 12115/102400 blocks ~ $ ~ $ ~ $ ~ $ file test.image5 test.image5: data ~ $ ~ $ fsck.ext4 test.image5 e2fsck 1.47.2 (1-Jan-2025) ext2fs_open2: Bad magic number in super-block fsck.ext4: Superblock invalid, trying backup blocks... fsck.ext4: Bad magic number in super-block while trying to open test.image5 The superblock could not be read or does not describe a valid ext2/ext3/ext4 filesystem. If the device is valid and it really contains an ext2/ext3/ext4 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock: e2fsck -b 8193 <device> or e2fsck -b 32768 <device> ~ $ ~ $ ~ $ ~ $ bc bc 1.08.1 Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2018, 2024 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. (5*1024*1024*1024+(32*1024*1024)) 5402263552 (5*1024*1024*1024+(32*1024*1024))/(1024*1024) 5152 5152*1024*1024 5402263552 ^C (interrupt) Exiting bc. ~ $ ~ $ ~ $ dd if=/dev/zero of=$HOME/storage/external-1/test-image6 bs=1M count=5152 5152+0 records in 5152+0 records out 5402263552 bytes (5.4 GB, 5.0 GiB) copied, 188.439 s, 28.7 MB/s ~ $ ~ $ ~ $ tar --verbose -c -f - directory* | mkfs.ext4 -m 0 -d - $HOME/storage/external-1/test-image6 5G mke2fs 1.47.2 (1-Jan-2025) directory1/ directory1/file1.txt directory2/ directory2/file2.txt directory3/ directory3/file3.txt directory4/ directory4/file4.txt directory5/ directory5/file5.txt directory6/ directory6/file6.txt directory7/ directory7/file7.txt directory8/ Creating filesystem with 1310720 4k blocks and 327680 inodes Filesystem UUID: 205ddcc8-7b64-42f8-a873-7b264865c4b3 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736 Allocating group tables: done Writing inode tables: done Creating journal (16384 blocks): done Copying files into the device: done Writing superblocks and filesystem accounting information: done ~ $ ~ $ ~ $ file $HOME/storage/external-1/test-image6 /data/data/com.termux/files/home/storage/external-1/test-image6: Linux rev 1.0 ext4 filesystem data, UUID=205ddcc8-7b64-42f8-a873-7b264865c4b3 (extents) (64bit) (large files) (huge files) ~ $ ~ $ ~ $ debugfs $HOME/storage/external-1/test-image6 debugfs 1.47.2 (1-Jan-2025) debugfs: ls 2 (12) . 2 (12) .. 11 (20) lost+found 13 (20) directory1 15 (20) directory2 17 (20) directory3 19 (20) directory4 21 (20) directory5 23 (20) directory6 25 (20) directory7 27 (3900) directory8 debugfs: ls directory1 13 (12) . 2 (12) .. 14 (4060) file1.txt debugfs: ls directory2 15 (12) . 2 (12) .. 16 (4060) file2.txt debugfs: ls directory3 17 (12) . 2 (12) .. 18 (4060) file3.txt debugfs: ls directory4 19 (12) . 2 (12) .. 20 (4060) file4.txt debugfs: ls directory5 21 (12) . 2 (12) .. 22 (4060) file5.txt debugfs: ls directory6 23 (12) . 2 (12) .. 24 (4060) file6.txt debugfs: ls lost+found 11 (12) . 2 (4072) .. 0 (4084) 0 (4084) 0 (4084) debugfs: quit ~ $ ~ $ ~ $ file $HOME/storage/external-1/test-image6 /data/data/com.termux/files/home/storage/external-1/test-image6: Linux rev 1.0 ext4 filesystem data, UUID=205ddcc8-7b64-42f8-a873-7b264865c4b3 (extents) (64bit) (large files) (huge files) ~ $ ~ $ ~ $ ~ $ cryptsetup reencrypt --verbose --type=luks2 --disable-keyring --disable-locks --reduce-device-size 32M --encrypt $HOME/storage/external-1/test-image6 WARNING! ======== This will overwrite data on LUKS2-temp-f46ca423-7944-4019-9f9c-ae44f60d2dcb.new irrevocably. Are you sure? (Type 'yes' in capital letters): YES Enter passphrase for LUKS2-temp-f46ca423-7944-4019-9f9c-ae44f60d2dcb.new: Verify passphrase: Key slot 0 created. Finished, time 05m11s, 5 GiB written, speed 16.5 MiB/s Command successful. ~ $ ~ $ ~ $ file $HOME/storage/external-1/test-image6 /data/data/com.termux/files/home/storage/external-1/test-image6: LUKS encrypted file, ver 2, header size 16384, ID 645, algo sha256, salt 0x74237f9e40e3601..., UUID: f46ca423-7944-4019-9f9c-ae44f60d2dcb, crc 0xc6f5d5ea71671d8f..., at 0x1000 {"keyslots":{"0":{"type":"luks2","key_size":64,"af":{"type":"luks1","stripes":4000,"hash":"sha256"},"area":{"type":"raw","offse ~ $ ~ $ ~ $ cryptsetup reencrypt --verbose --type=luks2 --disable-keyring --disable-locks --header $HOME/storage/external-1/luks-header-test-image6 --decrypt $HOME/storage/external-1/test-image6 WARNING! ======== Header file /data/data/com.termux/files/home/storage/external-1/luks-header-test-image6 does not exist. Do you want to initialize LUKS2 decryption of device /data/data/com.termux/files/home/storage/external-1/test-image6 and export LUKS2 header to file /data/data/com.termux/files/home/storage/external-1/luks-header-test-image6? Are you sure? (Type 'yes' in capital letters): YES Enter passphrase for /data/data/com.termux/files/home/storage/external-1/test-image6: Key slot 0 unlocked. Device /data/data/com.termux/files/home/storage/external-1/test-image6 is not a block device. WARNING! ======== Unable to decide if device /data/data/com.termux/files/home/storage/external-1/test-image6 is activated or not. Are you sure you want to proceed with reencryption in offline mode? It may lead to data corruption if the device is actually activated. To run reencryption in online mode, use --active-name parameter instead. Are you sure? (Type 'yes' in capital letters): YES Existing 'crypto_LUKS' superblock signature on device /data/data/com.termux/files/home/storage/external-1/test-image6 will be wiped. Existing 'crypto_LUKS' superblock signature on device /data/data/com.termux/files/home/storage/external-1/test-image6 will be wiped. Finished, time 05m00s, 5 GiB written, speed 17.1 MiB/s Command successful. ~ $ ~ $ ~ $ file $HOME/storage/external-1/test-image6 /data/data/com.termux/files/home/storage/external-1/test-image6: Linux rev 1.0 ext4 filesystem data, UUID=205ddcc8-7b64-42f8-a873-7b264865c4b3 (extents) (64bit) (large files) (huge files) ~ $ ~ $ fsck.ext4 $HOME/storage/external-1/test-image6 e2fsck 1.47.2 (1-Jan-2025) /data/data/com.termux/files/home/storage/external-1/test-image6: clean, 27/327680 files, 42406/1310720 blocks ~ $ ~ $ ~ $ debugfs $HOME/storage/external-1/test-image6 debugfs 1.47.2 (1-Jan-2025) debugfs: ls 2 (12) . 2 (12) .. 11 (20) lost+found 13 (20) directory1 15 (20) directory2 17 (20) directory3 19 (20) directory4 21 (20) directory5 23 (20) directory6 25 (20) directory7 27 (3900) directory8 debugfs: ls directory1 13 (12) . 2 (12) .. 14 (4060) file1.txt debugfs: ls directory2 15 (12) . 2 (12) .. 16 (4060) file2.txt debugfs: ls directory3 17 (12) . 2 (12) .. 18 (4060) file3.txt debugfs: ls directory4 19 (12) . 2 (12) .. 20 (4060) file4.txt debugfs: ls directory5 21 (12) . 2 (12) .. 22 (4060) file5.txt debugfs: ls directory6 23 (12) . 2 (12) .. 24 (4060) file6.txt debugfs: ls directory7 25 (12) . 2 (12) .. 26 (4060) file7.txt debugfs: ls directory8 27 (12) . 2 (4072) .. debugfs: ls lost+found 11 (12) . 2 (4072) .. 0 (4084) 0 (4084) 0 (4084) debugfs: quit ~ $ ~ $ ~ $ fsck.ext4 $HOME/storage/external-1/test-image6 e2fsck 1.47.2 (1-Jan-2025) /data/data/com.termux/files/home/storage/external-1/test-image6: clean, 27/327680 files, 42406/1310720 blocks ~ $ ``` ### Links * "GNU tar manual": https://www.gnu.org/software/tar/manual/ , https://www.gnu.org/software/tar/manual/tar.html * Ext2/3/4 file system utilities: https://github.com/tytso/e2fsprogs * NoteAfterNote-5, "Termux And The ext4 Filesystem, Part 5 Of 5: Reading And Writing With debugfs, No Root Required": https://gist.github.com/NoteAfterNote/854468164f8513bea764ac1668489f96 (NoteAfterNote, April 16, 2023) * "Using the "tarball" option in mkfs.ext4 returns "Copying files into the device: __populate_fs_from_tar: you need libarchive to be able to process tarballs" "mkfs.ext4: Operation not permitted while populating file system" #24127": ``https://github.com/termux/termux-packages/issues/24127`` (NoteAfterNote, April 3, 2025) , https://github.com/termux/termux-packages/issues/24127 * "Motorola moto g play 2024 Smartphone, Android 14 Operating System, Termux, And cryptsetup: Linux Unified Key Setup (LUKS) Encryption/Decryption And The ext4 Filesystem Without Using root Access, Without Using proot-distro, And Without Using QEMU": https://old.reddit.com/r/MotoG/comments/1jkl0f8/motorola_moto_g_play_2024_smartphone_android_14/ (throwaway16830261, March 26, 2025)