Recently, I installed Ubuntu 26.04 on my old MacBook Pro (Mid 2015) and shared a step by step installation guide. Soon after, a strange apt error appeared, then the machine stopped booting, and later it kept flipping its root filesystem to read-only. This post covers the error messages I hit, what the logs showed, and what finally fixed it.
It started with an apt error
When I tried to run an apt command in Ubuntu, it threw this error:
update-initramfs: Generating /boot/initrd.img-7.0.0-38-generic
sync: error syncing '/boot/initrd.img-7.0.0-38-generic': Input/output error
dpkg: error processing package dracut (--configure):
old dracut package postinst maintainer script subprocess failed with exit status 1
Errors were encountered while processing:
dracutThen the boot failed too
After running some commands to fix it, the boot failed as well. It dropped into a dracut emergency shell because the root filesystem failed its check:
[FAILED] Failed to start systemd-fsck-root.service - File System Check on /dev/disk/by-uuid/
[DEPEND] Dependency failed for sysroot.mount - /sysroot.
[DEPEND] Dependency failed for initrd-root-fs.target - Initrd Root File System.
Entering emergency mode. Exit the shell to continue.
sulogin: failed to execute /bin/bash: No such file or directoryThe sulogin ... /bin/bash line is harmless. The minimal initramfs only ships sh, and I was already at a # prompt. Some tools were missing there too (tail: not found).
What the filesystem check said
Running journalctl -u systemd-fsck-root at the emergency prompt showed the real reason:
/dev/sda2: Unattached inode 3277399
/dev/sda2: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
(i.e., without -a or -p options)
fsck failed with exit status 4.blkid showed that /dev/sda2 is the ext4 root partition and /dev/sda1 is the vfat EFI partition. Exit status 4 means the errors were left uncorrected. The boot-time check runs in automatic ("preen") mode and refuses to make this kind of repair on its own.
Back in the system, but the disk was read-only
Once I got back into the system, I tried to install smartmontools to check the drive:
sudo apt install smartmontools
Problem renaming the file /var/cache/apt/pkgcache.bin ... Read-only file systemIt looked like a corrupted package cache, but it was not. The kernel had remounted / read-only, which ext4 does on purpose (errors=remount-ro) when it hits filesystem errors. I stopped trying to fix apt and went to the kernel log instead.
The clue in dmesg
I ran sudo dmesg | grep -iE 'i/o error|ata|blk_update|failed command|exception' and found this:
ata1.00: exception Emask 0x20 SAct 0x100000 SErr 0x0 action 0x6 frozen
ata1.00: irq_stat 0x20000000, host bus error
ata1.00: failed command: WRITE FPDMA QUEUED
ata1.00: cmd 61/e0:a0:80:73:de/19:00:1b:00:00/40 tag 20 ncq dma 3391488 out
ata1: hard resetting link
ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
ata1.00: failed command: READ FPDMA QUEUEDThree details stood out:
ncq dma 3391488is a single write of about 3.2 MiB (3312 KB), far above the usual 1280 KB request size.host bus errorwithSErr 0x0points at the controller or DMA path, not at damaged flash cells.- The first failure came about 53 seconds after boot, once real write traffic started.
The max_sectors_kb idea
Around then I read that on Ubuntu 26 the disk can turn read-only when max_sectors_kb is set too high, and that a temporary workaround is to set it to 1280. That setting is the largest single I/O request the block layer will send to a disk, and the kernel default is typically 1280 KB. I checked mine:
cat /sys/block/sda/queue/max_sectors_kb
4096That fit the 3312 KB write that failed. My theory of what happened:
- A large write (up to 4096 KB) reached the SATA controller.
- The controller or DMA path failed the command. The kernel froze the port and reset the link.
- ext4 saw failed writes, aborted its journal and remounted the filesystem read-only.
- Metadata that was in flight was left half-written, which is where the unattached inode came from.
- On the next boot, the automatic fsck refused to repair it and dropped me into emergency mode.
So the corruption was a consequence, not the cause. That is why repairing the filesystem alone would not have been enough.
How I fixed it
Replace sda and sda2 with your own device names if they differ. lsblk -f shows them.
1. Lower the limit right away
echo 1280 | sudo tee /sys/block/sda/queue/max_sectors_kbWriting to sysfs works even while the root filesystem is read-only. This setting is temporary and resets at reboot.
2. Boot a live USB
I booted an Ubuntu Live USB which I prepared at installation time [Read full post here]. On a Mac, hold Option (⌥) at startup and pick the USB drive (usually the orange "EFI Boot" entry), then choose "Try Ubuntu" and open a terminal. If you can, copy your important files to an external drive first, because e2fsck -y answers yes to every question and can occasionally discard data.
The live session has its own default, so I set the limit again before touching the disk:
echo 1280 | sudo tee /sys/block/sda/queue/max_sectors_kb3. Stop the auto-mounter and repair
These three commands, run from the live USB before opening any file manager, worked for me:
echo 1280 | sudo tee /sys/block/sda/queue/max_sectors_kb
sudo systemctl stop udisks2
sudo e2fsck -f -y /dev/sda2Stopping udisks2 keeps the desktop auto-mounter from grabbing the partition. The result was a clean check:
e2fsck 1.47.2 (1-Jan-2025)
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
/dev/sda2: 213770/15253504 files (0.2% non-contiguous), 4250209/61003520 blocksIf you see I/O errors during the repair, stop and copy your files off before doing anything else.
4. Make the fix persistent
The echo only lasts until reboot, so I added a udev rule to the installed system, straight from the live USB:
sudo mount /dev/sda2 /mnt
echo 'ACTION=="add|change", SUBSYSTEM=="block", KERNEL=="sda", ATTR{queue/max_sectors_kb}="1280"' | sudo tee /mnt/etc/udev/rules.d/99-max-sectors.rules
cat /mnt/etc/udev/rules.d/99-max-sectors.rules
sudo umount /mnt5. Reboot and verify
After rebooting into the installed system I checked that the rule had been applied:
cat /sys/block/sda/queue/max_sectors_kb
mount | grep ' / '
sudo dmesg | grep -iE 'ata1|i/o error|ext4-fs'The value stayed at 1280, and the issue appears to be resolved. What you want to see is 1280, a root mount showing rw, and no ata1.00: exception lines. Copying a few large files while sudo dmesg -w runs in another terminal is a good stress test.
6. Check the SSD's health
A clean fsck rules out leftover corruption but says nothing about the drive itself:
sudo apt install smartmontools
sudo smartctl -a /dev/sdaLook at Reallocated_Sector_Ct, Current_Pending_Sector, Offline_Uncorrectable, UDMA_CRC_Error_Count and the overall health result. Non-zero reallocated or pending sectors mean the drive is wearing out and should be replaced.
Once the storage problem has been resolved and the filesystem is healthy, you can repair package configuration with:
sudo dpkg --configure -a
sudo apt --fix-broken installIf it does not work for you
- The value goes back to 4096 after a reboot. The udev rule did not load. Check the file for typos, then run
sudo udevadm control --reloadandsudo udevadm trigger --subsystem-match=block --action=change. - The rule hits the wrong device. It matches
sdaby name, so a USB drive that takes thesdaname at some boot would get the setting instead. Find the model withudevadm info -q property /dev/sda | grep ID_MODELand useENV{ID_MODEL}==""in place ofKERNEL=="sda". - Errors continue even at 1280. Try 512 or 256 as a diagnostic. If errors persist at small sizes, suspect the SSD or the controller, and use the SMART output to confirm.
- Do not run
mount -o remount,rw /or try to repair the apt cache while the disk is in this state. Writing to a filesystem that is already unhappy only adds damage.
Key takeaways
- An
Input/output errorfromaptis a disk problem, not a package problem. Readdmesgbefore running fix-it commands. - A boot that stops with
fsck failed with exit status 4needs a manuale2fsckfrom a live USB, with the partition unmounted. - A sudden read-only root filesystem is the kernel protecting itself.
- Repairing the filesystem fixes the damage, and capping
max_sectors_kbat 1280 removes the likely trigger. I needed both. - Finish with a SMART check, so you know the drive itself is healthy.