How to check and fix EXT4 filesystem?

Hello,

Today I was deleting some files from my NVME to increase freespace, but while deleting some of them the system stuck in the Plasma pop-up window for deleting the files but not completing the operation, so when I clicked on cancel, “all files was moved the trash folder” so I empty the trash folder but for my surprise there was no difference in the freespace. I deleted around 30GiB so I had the impression that maybe the filesystem got corrupted somehow and tried to check its integrity and fix issues with the command below:

sudo e2fsck -vf /dev/nvme2n1

Below you can see the result:

e2fsck 1.47.1 (20-May-2024)
ext2fs_open2: Bad magic number in super-block
e2fsck: Superblock invalid, trying backup blocks...
e2fsck: Bad magic number in super-block while trying to open /dev/nvme2n1

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>

/dev/nvme2n1 contains `DOS/MBR boot sector; partition 1 : ID=0xee, start-CHS (0x0,0,2), end-CHS (0x3ff,255,63), startsector 1, 3907029167 sectors, extended partition table (last)' data

The command don’t look able to properly fix the issue that was found. I tried some variations as included in -v, but no success. Is there any recommendation?

Note: The NVME assembled in a PCIe Card adapter, and the card is assembled on the motherboard.

System information:

System:
  Kernel: 6.11.2-4-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 14.2.1
    clocksource: tsc avail: hpet,acpi_pm
    parameters: BOOT_IMAGE=/@/boot/vmlinuz-6.11-x86_64
    root=UUID=84e0bfca-0d47-4324-b85a-614ea38dc5f9 rw rootflags=subvol=@ quiet
    splash udev.log_priority=3
  Desktop: KDE Plasma v: 6.1.5 tk: Qt v: N/A info: frameworks v: 6.6.0
    wm: kwin_wayland with: krunner vt: 1 dm: SDDM Distro: Manjaro
    base: Arch Linux
Machine:
  Type: Desktop Mobo: MACHINIST model: E5-MR9A v: V1.0
    serial: <superuser required> uuid: <superuser required>
    UEFI: American Megatrends v: 5.11 date: 10/25/2022
Battery:
  Message: No system battery data found. Is one present?
Memory:
  System RAM: total: 32 GiB available: 31.19 GiB used: 5.5 GiB (17.6%)
  Message: For most reliable report, use superuser + dmidecode.
  Array-1: capacity: 256 GiB note: check slots: 4 modules: 4
    EC: Multi-bit ECC max-module-size: 64 GiB note: est.
  Device-1: DIMM_A1 type: DDR4 detail: synchronous size: 8 GiB
    speed: 2400 MT/s volts: curr: 1 min: 1.14 max: 1.26 width (bits): data: 72
    total: 72 manufacturer: Hynix Semiconductor part-no: HMA41GR7AFR4N-UH
    serial: <filter>
  Device-2: DIMM_B1 type: DDR4 detail: synchronous size: 8 GiB
    speed: 2400 MT/s volts: curr: 1 min: 1.14 max: 1.26 width (bits): data: 72
    total: 72 manufacturer: Hynix Semiconductor part-no: HMA41GR7AFR4N-UH
    serial: <filter>
  Device-3: DIMM_C1 type: DDR4 detail: synchronous size: 8 GiB
    speed: 2400 MT/s volts: curr: 1 min: 1.14 max: 1.26 width (bits): data: 72
    total: 72 manufacturer: Hynix Semiconductor part-no: HMA41GR7AFR4N-UH
    serial: <filter>
  Device-4: DIMM_D1 type: DDR4 detail: synchronous size: 8 GiB
    speed: 2400 MT/s volts: curr: 1 min: 1.14 max: 1.26 width (bits): data: 72
    total: 72 manufacturer: Hynix Semiconductor part-no: HMA41GR7AFR4N-UH
    serial: <filter>
CPU:
  Info: model: Intel Xeon E5-2667 v4 bits: 64 type: MT MCP arch: Broadwell
    level: v3 note: check built: 2015-18 process: Intel 14nm family: 6
    model-id: 0x4F (79) stepping: 1 microcode: 0xB000040
  Topology: cpus: 1x dies: 1 clusters: 8 cores: 8 threads: 16 tpc: 2
    smt: enabled cache: L1: 512 KiB desc: d-8x32 KiB; i-8x32 KiB L2: 2 MiB
    desc: 8x256 KiB L3: 25 MiB desc: 1x25 MiB
  Speed (MHz): avg: 1200 min/max: 1200/3600 scaling: driver: intel_cpufreq
    governor: schedutil cores: 1: 1200 2: 1200 3: 1200 4: 1200 5: 1200 6: 1200
    7: 1200 8: 1200 9: 1200 10: 1200 11: 1200 12: 1200 13: 1200 14: 1200
    15: 1200 16: 1200 bogomips: 102220
  Flags: 3dnowprefetch abm acpi adx aes aperfmperf apic arat arch_perfmon
    avx avx2 bmi1 bmi2 bts cat_l3 cdp_l3 clflush cmov constant_tsc cpuid
    cpuid_fault cqm cqm_llc cqm_mbm_local cqm_mbm_total cqm_occup_llc cx16 cx8
    dca de ds_cpl dtes64 dtherm dts epb ept ept_ad erms est f16c flexpriority
    flush_l1d fma fpu fsgsbase fxsr hle ht ibpb ibrs ida intel_ppin intel_pt
    invpcid lahf_lm lm mca mce md_clear mmx monitor movbe msr mtrr nonstop_tsc
    nopl nx pae pat pbe pcid pclmulqdq pdcm pdpe1gb pebs pge pln pni popcnt
    pse pse36 pti pts rdrand rdseed rdt_a rdtscp rep_good rtm sdbg sep smap
    smep smx ss ssbd sse sse2 sse4_1 sse4_2 ssse3 stibp syscall tm tm2
    tpr_shadow tsc tsc_adjust tsc_deadline_timer vme vmx vnmi vpid x2apic
    xsave xsaveopt xtopology xtpr
  Vulnerabilities:
  Type: gather_data_sampling status: Not affected
  Type: itlb_multihit status: KVM: VMX disabled
  Type: l1tf mitigation: PTE Inversion; VMX: conditional cache flushes, SMT
    vulnerable
  Type: mds mitigation: Clear CPU buffers; SMT vulnerable
  Type: meltdown mitigation: PTI
  Type: mmio_stale_data mitigation: Clear CPU buffers; SMT vulnerable
  Type: reg_file_data_sampling status: Not affected
  Type: retbleed status: Not affected
  Type: spec_rstack_overflow status: Not affected
  Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via
    prctl
  Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer
    sanitization
  Type: spectre_v2 mitigation: Retpolines; IBPB: conditional; IBRS_FW;
    STIBP: conditional; RSB filling; PBRSB-eIBRS: Not affected; BHI: Not
    affected
  Type: srbds status: Not affected
  Type: tsx_async_abort mitigation: Clear CPU buffers; SMT vulnerable
Graphics:
  Device-1: Advanced Micro Devices [AMD/ATI] Navi 10 [Radeon RX 5600 OEM/5600
    XT / 5700/5700 XT] vendor: Micro-Star MSI driver: amdgpu v: kernel
    arch: RDNA-1 code: Navi-1x process: TSMC n7 (7nm) built: 2019-20 pcie:
    gen: 4 speed: 16 GT/s lanes: 16 ports: active: DP-2
    empty: DP-1,DP-3,HDMI-A-1 bus-ID: 05:00.0 chip-ID: 1002:731f class-ID: 0300
  Display: wayland server: X.org v: 1.21.1.13 with: Xwayland v: 24.1.2
    compositor: kwin_wayland driver: X: loaded: amdgpu
    unloaded: modesetting,radeon alternate: fbdev,vesa dri: radeonsi
    gpu: amdgpu display-ID: 0
  Monitor-1: DP-2 res: 2560x1440 size: N/A modes: N/A
  API: EGL v: 1.5 hw: drv: amd radeonsi platforms: device: 0 drv: radeonsi
    device: 1 drv: swrast gbm: drv: kms_swrast surfaceless: drv: radeonsi
    wayland: drv: radeonsi x11: drv: radeonsi
  API: OpenGL v: 4.6 compat-v: 4.5 vendor: amd mesa v: 24.2.4-arch1.0.1
    glx-v: 1.4 direct-render: yes renderer: AMD Radeon RX 5700 XT (radeonsi
    navi10 LLVM 18.1.8 DRM 3.59 6.11.2-4-MANJARO) device-ID: 1002:731f
    memory: 7.81 GiB unified: no display-ID: :1.0
  API: Vulkan v: 1.3.295 layers: 6 device: 0 type: discrete-gpu name: AMD
    Radeon RX 5700 XT (RADV NAVI10) driver: mesa radv v: 24.2.4-arch1.0.1
    device-ID: 1002:731f surfaces: xcb,xlib,wayland
Audio:
  Device-1: Intel 8 Series/C220 Series High Definition Audio
    driver: snd_hda_intel v: kernel bus-ID: 00:1b.0 chip-ID: 8086:8c20
    class-ID: 0403
  Device-2: Advanced Micro Devices [AMD/ATI] Navi 10 HDMI Audio
    driver: snd_hda_intel v: kernel pcie: gen: 4 speed: 16 GT/s lanes: 16
    bus-ID: 05:00.1 chip-ID: 1002:ab38 class-ID: 0403
  API: ALSA v: k6.11.2-4-MANJARO status: kernel-api with: aoss
    type: oss-emulator tools: alsactl,alsamixer,amixer
  Server-1: sndiod v: N/A status: off tools: aucat,midicat,sndioctl
  Server-2: JACK v: 1.9.22 status: off tools: N/A
  Server-3: PipeWire v: 1.2.5 status: off with: wireplumber status: active
    tools: pw-cli,wpctl
  Server-4: PulseAudio v: 17.0 status: active with: pulseaudio-alsa
    type: plugin tools: pacat,pactl
Network:
  Device-1: Realtek RTL8111/8168/8211/8411 PCI Express Gigabit Ethernet
    driver: r8169 v: kernel pcie: gen: 1 speed: 2.5 GT/s lanes: 1 port: d000
    bus-ID: 08:00.0 chip-ID: 10ec:8168 class-ID: 0200
  IF: enp8s0 state: up speed: 100 Mbps duplex: full mac: <filter>
  IP v4: <filter> type: dynamic noprefixroute scope: global
    broadcast: <filter>
  IP v6: <filter> type: noprefixroute scope: global
  IP v6: <filter> type: noprefixroute scope: link
  IF-ID-1: virbr0 state: down mac: <filter>
  IP v4: <filter> scope: global broadcast: <filter>
  Info: services: NetworkManager
  WAN IP: <filter>
Bluetooth:
  Message: No bluetooth data found.
Logical:
  Message: No logical block device data found.
RAID:
  Message: No RAID data found.
Drives:
  Local Storage: total: 2.73 TiB used: 1.69 TiB (61.9%)
  SMART Message: Unable to run smartctl. Root privileges required.
  ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Western Digital
    model: WD Blue SN570 500GB size: 465.76 GiB block-size: physical: 512 B
    logical: 512 B speed: 31.6 Gb/s lanes: 4 tech: SSD serial: <filter>
    fw-rev: 234100WD temp: 31.9 C scheme: GPT
  ID-2: /dev/nvme1n1 maj-min: 259:4 vendor: A-Data model: LEGEND 850 Lite
    size: 465.76 GiB block-size: physical: 512 B logical: 512 B speed: 63.2 Gb/s
    lanes: 4 tech: SSD serial: <filter> fw-rev: V0922A0 temp: 30.9 C
    scheme: GPT
  ID-3: /dev/nvme2n1 maj-min: 259:2 model: X16 Plus SSD 2TB size: 1.82 TiB
    block-size: physical: 512 B logical: 512 B speed: 63.2 Gb/s lanes: 4
    tech: SSD serial: <filter> fw-rev: SN11273 temp: 40.9 C scheme: GPT
  Message: No optical or floppy data found.
Partition:
  ID-1: / raw-size: 465.46 GiB size: 465.46 GiB (100.00%)
    used: 102.46 GiB (22.0%) fs: btrfs dev: /dev/nvme1n1p2 maj-min: 259:6
    label: N/A uuid: 84e0bfca-0d47-4324-b85a-614ea38dc5f9
  ID-2: /boot/efi raw-size: 300 MiB size: 299.4 MiB (99.80%)
    used: 576 KiB (0.2%) fs: vfat dev: /dev/nvme1n1p1 maj-min: 259:5 label: N/A
    uuid: 21D8-DE05
  ID-3: /home raw-size: 465.46 GiB size: 465.46 GiB (100.00%)
    used: 102.46 GiB (22.0%) fs: btrfs dev: /dev/nvme1n1p2 maj-min: 259:6
    label: N/A uuid: 84e0bfca-0d47-4324-b85a-614ea38dc5f9
  ID-4: /home/<filter>/Games raw-size: 465.76 GiB size: 457.38 GiB (98.20%)
    used: 142.01 GiB (31.0%) fs: ext4 dev: /dev/nvme0n1p1 maj-min: 259:1
    label: GAMES uuid: b5780269-0438-4193-9b38-7df4aaf9b229
  ID-5: /home/<filter>/HDD-2TB raw-size: 1.82 TiB size: 1.79 TiB (98.37%)
    used: 1.45 TiB (81.1%) fs: ext4 dev: /dev/nvme2n1p1 maj-min: 259:7
    label: NVME-2TB uuid: ec1ddfe0-4768-4618-93f3-bfbbafeb12a4
  ID-6: /swap raw-size: 465.46 GiB size: 465.46 GiB (100.00%)
    used: 102.46 GiB (22.0%) fs: btrfs dev: /dev/nvme1n1p2 maj-min: 259:6
    label: N/A uuid: 84e0bfca-0d47-4324-b85a-614ea38dc5f9
  ID-7: /var/cache raw-size: 465.46 GiB size: 465.46 GiB (100.00%)
    used: 102.46 GiB (22.0%) fs: btrfs dev: /dev/nvme1n1p2 maj-min: 259:6
    label: N/A uuid: 84e0bfca-0d47-4324-b85a-614ea38dc5f9
  ID-8: /var/log raw-size: 465.46 GiB size: 465.46 GiB (100.00%)
    used: 102.46 GiB (22.0%) fs: btrfs dev: /dev/nvme1n1p2 maj-min: 259:6
    label: N/A uuid: 84e0bfca-0d47-4324-b85a-614ea38dc5f9
Swap:
  Kernel: swappiness: 60 (default) cache-pressure: 100 (default) zswap: yes
    compressor: zstd max-pool: 20%
  ID-1: swap-1 type: file size: 512 MiB used: 512 MiB (100.0%) priority: -2
    file: /swap/swapfile
Unmounted:
  Message: No unmounted partitions found.
USB:
  Hub-1: 1-0:1 info: full speed or root hub ports: 2 rev: 2.0
    speed: 480 Mb/s (57.2 MiB/s) lanes: 1 mode: 2.0 chip-ID: 1d6b:0002
    class-ID: 0900
  Hub-2: 1-1:2 info: Intel Integrated Rate Matching Hub ports: 6 rev: 2.0
    speed: 480 Mb/s (57.2 MiB/s) lanes: 1 mode: 2.0 chip-ID: 8087:8008
    class-ID: 0900
  Hub-3: 2-0:1 info: full speed or root hub ports: 2 rev: 2.0
    speed: 480 Mb/s (57.2 MiB/s) lanes: 1 mode: 2.0 chip-ID: 1d6b:0002
    class-ID: 0900
  Hub-4: 2-1:2 info: Intel Integrated Rate Matching Hub ports: 8 rev: 2.0
    speed: 480 Mb/s (57.2 MiB/s) lanes: 1 mode: 2.0 chip-ID: 8087:8000
    class-ID: 0900
  Hub-5: 3-0:1 info: hi-speed hub with single TT ports: 15 rev: 2.0
    speed: 480 Mb/s (57.2 MiB/s) lanes: 1 mode: 2.0 chip-ID: 1d6b:0002
    class-ID: 0900
  Device-1: 3-1:2 info: SINO WEALTH Gaming KB type: keyboard,HID
    driver: hid-generic,usbhid interfaces: 2 rev: 1.1 speed: 12 Mb/s (1.4 MiB/s)
    lanes: 1 mode: 1.1 power: 500mA chip-ID: 258a:002a class-ID: 0300
  Device-2: 3-2:3 info: [Maxxter] USB GAMING MOUSE type: mouse,keyboard
    driver: hid-generic,usbhid interfaces: 2 rev: 1.1 speed: 1.5 Mb/s (183 KiB/s)
    lanes: 1 mode: 1.0 power: 100mA chip-ID: 18f8:0fc0 class-ID: 0301
  Hub-6: 4-0:1 info: super-speed hub ports: 6 rev: 3.0
    speed: 5 Gb/s (596.0 MiB/s) lanes: 1 mode: 3.2 gen-1x1 chip-ID: 1d6b:0003
    class-ID: 0900
Sensors:
  System Temperatures: cpu: 26.0 C mobo: N/A gpu: amdgpu temp: 37.0 C
    mem: 38.0 C
  Fan Speeds (rpm): N/A gpu: amdgpu fan: 839
Info:
  Processes: 358 Power: uptime: 2h 39m states: freeze,mem,disk suspend: deep
    avail: s2idle wakeups: 0 hibernate: platform avail: shutdown, reboot,
    suspend, test_resume image: 12.46 GiB services: org_kde_powerdevil,
    power-profiles-daemon, upowerd Init: systemd v: 256 default: graphical
    tool: systemctl
  Packages: 1553 pm: pacman pkgs: 1503 libs: 452 tools: pamac pm: flatpak
    pkgs: 50 Compilers: clang: 18.1.8 gcc: 14.2.1 Shell: Zsh v: 5.9 default: Bash
    v: 5.2.37 running-in: konsole inxi: 3.3.36

It appears that the file system that you use is NOT ext4
but BTRFS instead.

It has got it’s own tool set to do these tasks.
(I know literally nothing about it - that’s why I don’t use it)

e2fsck is definitely the wrong thing™, the wrong tool!
Do not force it!
You’ll destroy your system / your data if you do.

ps:

/home/username/Games
and
/home/username/HDD-2TB
are ext4 file systems - but not the rest, not /home itself

1 Like

You are right here, and I was deleting file only from this NVME that is mounted in this folder. This is for personal files and the only NVME that I do back-up cloning it.

Games NVME is also Ext4 for game performance.

Only root is BTRFS, in order to use snapshots.

You tried to run it on a namespace. You’re meant to run it on a filesystem, so a partition such as nvme2n1p1.

1 Like
  1. Never run an fsck on a mounted filesystem.

  2. For btrfs, use “btrfs check” — see the man page.

  3. btrfs may need periodic balance’ing to redistribute the extents and free up space. This is due to how btrfs allocates free space. Again, see the man page(s).

1 Like

I unmount the NVME before running the command.

The interest is only to check and fix EXT4, no BTRFS.

Thank you, that was the reason, So, I was trying to run the command for the full NVME while I should run it for specific partition.

1 Like

free tip:

sudo tune2fs -m 0 /dev/nvme2n1p1
sudo tune2fs -m 0 /dev/nvme0n1p1

to make quite a few gigabytes more available to you


with ext2/3/4, upon file system creation, 5% are reserved for the root user exclusively

since these two ext4 partitions are pretty large and mounted under /home anyway
root does not need to have spare space there

-m 0 sets the reserved for root space to zero

This command can be done while the file system is mounted.

4 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.