omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Installer shrinks an existing Linux partition but never shrinks its filesystem, destroying the other OS

Open iandol opened this issue 3 weeks ago • 4 comments

System details

Omarchy 4.5.0-3, kernel 7.2.15-1-omarchy, x86_64, UEFI, Secure Boot disabled - Hardware: GMKtec M6 Ultra, AMD Ryzen 5 7640HS (Radeon 760M), Disk: NVMe 476.9 GiB, GPT

What's wrong?

Summary

This was my first attempt to install omarchy. My system had Ubuntu occupying a 500GB disk, and while I would normally use parted, omarchy installer offered a partition editor and I tried that. r to resize than then I assumed W to write. Installing Omarchy alongside an existing Ubuntu install resized Ubuntu's root partition from 476 GiB down to 350 GiB, but never shrank the ext4 filesystem inside it. The ext4 still claims the old, larger size, so the kernel refuses to mount it at all:

EXT4-fs (nvme0n1p2): bad geometry: block count 124751104 exceeds size of device (91750400 blocks)

Because a large block region of that filesystem now sits outside the partition, its inode tables are physically gone, and Ubuntu's /etc, /home and /snap are unrecoverable. The install cannot be booted or repaired in place: the only remedy is to reinstall the other OS.

Expected behaviour

Any one of these would avoid the data loss:

  • Run an offline resize2fs on the existing filesystem before (or as part of) shrinking its partition, or
  • refuse to shrink a partition that contains a filesystem, explaining that the other OS must be shrunk first, or
  • at minimum, after resizing, verify that the filesystem's block count fits the new partition and abort with a clear message instead of proceeding.

Actual behaviour

Only the partition table was changed. The filesystem was left 125.9 GiB larger than its partition, which makes it unmountable by design, and its trailing metadata (block bitmaps, inode tables for groups past the new boundary) is outside the partition, so neither e2fsck nor resize2fs can repair it:

# resize2fs -f /dev/nvme0n1p2
resize2fs: Can't read a block bitmap while trying to resize /dev/nvme0n1p2
Please run 'e2fsck -fy /dev/nvme0n1p2' to fix the filesystem
after the aborted resize operation.

# e2fsck -fy /dev/nvme0n1p2
Error reading block 124751036 (Invalid argument).  Ignore error? no
...
e2fsck: aborted

Steps to reproduce

  1. Install Ubuntu on a bare NVMe disk with its ext4 root spanning the whole disk (476.9 GiB device, ext4 sized to fill it), UEFI, Secure Boot off.
  2. Boot the Omarchy installer and install alongside, letting it shrink the existing partition to make room.
  3. Boot Omarchy and try to access the Ubuntu partition (mount /dev/nvme0n1p2 /mnt).

Result: the mount fails immediately with the geometry error above.

Evidence

Partition table (after the Omarchy install):

$ sfdisk -d /dev/nvme0n1
/dev/nvme0n1p1 : start=     2048, size=   2201600, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B
/dev/nvme0n1p2 : start=  2203648, size= 734003200, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4
/dev/nvme0n1p3 : start=736206848, size=   4194304, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, name="OMARCHY_EFI"
/dev/nvme0n1p4 : start=740403200, size= 259811328, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, name="OMARCHY_ROOT"

Partition 2 is 734003200 sectors x 512 = 375,809,638,400 bytes = 91,750,400 x 4096-byte blocks.

The filesystem inside it:

$ tune2fs -l /dev/nvme0n1p2
Filesystem features:      has_journal ext_attr resize_inode dir_index orphan_file filetype extent 64bit flex_bg metadata_csum_seed sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
Filesystem state:         clean
Block count:              124751104
Block size:               4096

124,751,104 x 4096 = 510,980,521,984 bytes, i.e. the whole 476.9 GiB device. The superblock is healthy and clean; nothing is corrupt, the size is simply stale. Surplus: 33,000,704 blocks = 125.9 GiB, which is exactly the region the installer reclaimed.

The superblock is clean and the journal inode is intact, so this is not filesystem corruption — it is a bookkeeping mismatch created by the installer.

Read-only inspection of the damaged filesystem (partition mapped together with a sparse hole so the size claim can be satisfied) shows what actually survived:

$ ls /mnt/ub-salvage
drwxr-xr-x  4 root root 4096 Nov 11 14:28 boot        <- intact, kernel + initrd present
d?????????  ? ?    ?         ?  dev                <- unreachable
d?????????  ? ?    ?         ?  etc                <- unreachable
d?????????  ? ?    ?         ?  home               <- unreachable
drwx------  2 root root 16384 Nov 11 12:53 lost+found
drwxr-xr-x  3 root root  4096 Nov 11 15:13 opt         <- intact
drwx------  6 root root  4096 Nov 12 10:41 root        <- intact
d?????????  ? ?    ?         ?  snap               <- unreachable

$ df -h /mnt/ub-salvage
/dev/mapper/ubuntu-view  468G   23G  422G   5% /mnt/ub-salvage
EXT4-fs error (device dm-1): ext4_lookup:1787: inode #25952257: iget: checksum invalid
EXT4-fs error (device dm-1): ext4_lookup:1787: inode #26476545: iget: checksum invalid
EXT4-fs error (device dm-1): htree_dirblock_to_tree:1051: inode #2885372: Directory block failed checksum

Inode 25952257 belongs to block group 3168 (8192 inodes/group), whose inode table lives past block 91,750,400 — i.e. outside the partition. Those inodes do not exist any more anywhere on the disk, which is why /etc and /home cannot be reattached by any fsck.

Impact

  • The other Linux installation becomes permanently unbootable.
  • All configuration and user data in /etc and /home of that installation is lost with no in-place recovery path; only signature-based carving remains.
  • Diagnosis is hard to reach: the symptom the user sees is the other OS failing to boot, which looks like a bootloader problem, not a partitioning one.

Workaround

None for that installation. Recovery is to reinstall the other OS, formatting its partition at the new size so the filesystem is created to fit.

Environment

  • Omarchy 4.5.0-3, kernel 7.2.15-1-omarchy, x86_64, UEFI, Secure Boot disabled
  • Hardware: GMKtec M6 Ultra, AMD Ryzen 5 7640HS (Radeon 760M), BIOS M6 Ultra 1.06
  • Disk: NVMe 476.9 GiB, GPT
  • Other OS: Ubuntu, ext4 root on nvme0n1p2, installed 2026-11-11 (one day before the Omarchy install), kernel 7.0.0-43-generic
  • Omarchy's own root is on nvme0n1p4 (LUKS + btrfs); Omarchy itself is unaffected

Related, separate issue (lower priority)

Omarchy's Limine configuration ships with timeout: 1 and quiet: yes. Per Limine's documentation, with quiet on the menu is not drawn at all during the countdown — a keypress within that single second is required to see it. On a dual-boot machine this makes it look as though there is no boot menu, which compounds the bug above. Worth considering a longer default timeout and drawing the menu when more than one entry exists.

iandol avatar Nov 12 '26 05:11 iandol

Hey, before you write Ubuntu off: I don't think the data is actually gone yet, but it might be after Monday.

Your salvage mount filled the cut-off tail of the filesystem with zeros, so everything past the new partition end looked missing. The real sectors are still there underneath Omarchy's ESP and LUKS partitions. The installer skips the whole-disk TRIM (mkfs.btrfs -K) and only writes what it needs, so most of Ubuntu's tail, /etc and /home included, is probably still intact.

The catch is that Omarchy keeps fstrim.timer enabled with discards passed through LUKS, so the weekly trim on Monday will wipe all of it for good. So:

  1. Don't boot Omarchy from that disk. Use a live USB, or run sudo systemctl disable --now fstrim.timer first.
  2. Map the original filesystem straight from the disk, read-only: sudo losetup -r -f --show -o 1128267776 --sizelimit 510980521984 /dev/nvme0n1
  3. Copy your stuff off to an external drive: sudo debugfs -c -R "rdump /home /mnt/external/" /dev/loopN sudo debugfs -c -R "rdump /etc /mnt/external/" /dev/loopN

Some files will be damaged where Omarchy wrote over them, but most should come back.

Also, this is the same bug as #7903 and #8954. The installer opens cfdisk, whose Resize only changes the partition table, not the filesystem. There's a fix in omacom/omarchy-iso#122, but it's been sitting since August.

Edward-cmyk avatar Nov 12 '26 05:11 Edward-cmyk

Thank you for your advice! As it was a fresh ubuntu with no user data yet, I'll just reinstall as a simpler solution, and I hope that pull gets merged (and the issues can then be closed) as this seems a pretty epic data loss issue...

iandol avatar Nov 12 '26 06:11 iandol

I read your report and the comments, compared the related reports in #7903 and #8954, and checked the status of ISO PR #122. I assessed this as a bug report, but the classification remains incomplete because the configured second classifier, deepseek-v4p1-flash, returned no answer.

This was GPT-6 High in Codex’s review alone; no substantive second review or reproduction ran. Further triage is waiting on classification review. This issue remains open.

omarchybot avatar Nov 19 '26 03:11 omarchybot

Classification is now agreed as a bug. I checked the current ISO partition-tool path, its English guidance, and the free-space partitioning helpers. The tool opens cfdisk, then continues without checking whether an existing partition shrank. It does not shrink the filesystem. The subsequent install creates and formats new partitions in the space that the table now calls free. Your quoted ext4 and partition sizes agree with the geometry error: the filesystem claims about 125.9 GiB beyond the shortened partition.

This is the same partition-shrink mechanism reported in #7903. ISO PR #122 remains open and proposes a guard for existing partitions regardless of filesystem type; I have not tested it. The missing guard is confirmed by reading current source, with no installer reproduction or code execution in this run. The zero-filled salvage mapping does not establish which original sectors were overwritten or which files remained recoverable.

Reviewed by GPT-6 in Codex (driver reasoning effort not exposed), Opus 5.5 High, and muse-wonder via pi with high thinking. The second opinions agreed on the source mechanism; reviewer independence is not guaranteed. They differed on closing the whole report as a duplicate because it also carries the separate Limine menu/defaults question. The issue remains open, waiting on the maintainer's decision about the existing ISO proposal and how to handle that separate note.

omarchybot avatar Nov 23 '26 11:11 omarchybot