Score:1

How to run fsck on encrypted (luks) disk from a bootable usb?

th flag

I have encrypted my disk using LUKS. After every boot up, my machine throws "DISK IS LIKELY TO FAIL SOON" message. To fix this, I am trying to run fsck on the root partition. I tried running fsck in recovery mode but it failed with the following message:

/lib/recovery-mode/recovery-menu: line 80: /etc/default/rcs: No such file or directory
fsck from utli-linux 2.37.2
/dev/mapper/vgubuntu-root is mounted. 
e2fsck: Cannot continue, aborting.

So, I tried booting up from a USB and running fsck from there. However, seems like it is not working because I get the following output and fsck terminates immediately:

fsck from util-linux 2.37.2
[/usr/sbin/fsck.ext4 (1) -- /dev/mapper/vgubuntu-root]
fsck.ext4 -y -C0 /dev/mapper/vgubuntu-root 
e2fsck 1.46.5 (30-Dec-2021)
/dev/mapper/vgubuntu-root: clean, 1254485/60784640 files, 52105495/243116032 block

Following is the output of lsblk:

NAME        FSTYPE FSVER     LABEL                    UUID                                   FSAVAIL FSUSE% MOUNTPOINTS
/dev/loop0  squash 4.0                                                                             0   100% /rofs
/dev/loop1  squash 4.0                                                                             0   100% /snap/bare/5
/dev/loop2  squash 4.0                                                                             0   100% /snap/firefox/1635
/dev/loop3  squash 4.0                                                                             0   100% /snap/gnome-3-38-2004/112
/dev/loop4  squash 4.0                                                                             0   100% /snap/gtk-common-themes/1535
/dev/loop5  squash 4.0                                                                             0   100% /snap/snapd/16292
/dev/loop6  squash 4.0                                                                             0   100% /snap/snap-store/582
/dev/loop7  squash 4.0                                                                             0   100% /snap/snapd-desktop-integration/14
/dev/loop8  squash 4.0                                                                             0   100% /snap/core20/1587
/dev/sda                                                                                                    
├─/dev/sda1 vfat   FAT32                              DFFE-1B40                                             
├─/dev/sda2 ext4   1.0                                b3b523d0-b935-40f1-9bea-f387cf4a4282                  
└─/dev/sda3 crypto 2                                  80422624-4c6b-4cbb-a969-eb110f60b15e                  
  └─/dev/mapper/luks-80422624-4c6b-4cbb-a969-eb110f60b15e
            LVM2_m LVM2 001                           iYBO3Z-pyDY-9Yd7-IqGA-CNaq-jFrU-BArfra                
    ├─/dev/mapper/vgubuntu-root
    │       ext4   1.0                                123ef630-60c6-45de-a2d2-da21d415b98d                  
    └─/dev/mapper/vgubuntu-swap_1
            swap   1                                  0bf6ba3c-a03a-4386-9d5a-c5b49765b8d6                  
/dev/sdb    iso966 Joliet Ex Ubuntu 22.04.1 LTS amd64 2022-08-10-16-21-45-00                                
├─/dev/sdb1 iso966 Joliet Ex Ubuntu 22.04.1 LTS amd64 2022-08-10-16-21-45-00                       0   100% /cdrom
├─/dev/sdb2 vfat   FAT12     ESP                      8D6C-A9F8                                             
├─/dev/sdb3                                                                                                 
└─/dev/sdb4 ext4   1.0       writable                 0498f4be-7be3-4d80-9ffa-53cb6e2797af     49.9G     0% /var/crash
                                                                                                            /var/log

Output of pvdisplay:

  --- Physical volume ---
  PV Name               /dev/mapper/luks-80422624-4c6b-4cbb-a969-eb110f60b15e
  VG Name               vgubuntu
  PV Size               <929.33 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              237907
  Free PE               0
  Allocated PE          237907
  PV UUID               iYBO3Z-pyDY-9Yd7-IqGA-CNaq-jFrU-BArfra

Output of vgdisplay:

  --- Volume group ---
  VG Name               vgubuntu
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               929.32 GiB
  PE Size               4.00 MiB
  Total PE              237907
  Alloc PE / Size       237907 / 929.32 GiB
  Free  PE / Size       0 / 0   
  VG UUID               zUsuN2-Juyn-1l1V-hyRN-VHbf-dtOh-lyByGZ

Output of lvdisplay:

  --- Logical volume ---
  LV Path                /dev/vgubuntu/root
  LV Name                root
  VG Name                vgubuntu
  LV UUID                2Iwd2Y-VcsI-fhf6-atcw-ijVb-lcsN-Rw3ZS3
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2022-09-16 09:46:16 +0000
  LV Status              available
  # open                 0
  LV Size                927.41 GiB
  Current LE             237418
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
   
  --- Logical volume ---
  LV Path                /dev/vgubuntu/swap_1
  LV Name                swap_1
  VG Name                vgubuntu
  LV UUID                YtYA2H-aKVB-f3bT-Fvi3-m46S-upM1-vWMRwR
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2022-09-16 09:46:17 +0000
  LV Status              available
  # open                 0
  LV Size                1.91 GiB
  Current LE             489
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

I have unlocked the disk before running the fsck command.

Why is fsck not running correctly on my machine? What am I missing here?

uname -a output:

Linux ubuntu 5.15.0-43-generic #46-Ubuntu SMP Tue Jul 12 10:30:17 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

lsb_release -a output:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy
ar flag
Welcome to Ask Ubuntu. Please don't post screenshots of the Terminal. Always copy the text from the terminal and directly paste the copied output and error messages in the terminal into your question. Then format those output as `code` using the {_} icon above the [edit question window](https://askubuntu.com/posts/1438598/edit),
oldfred avatar
cn flag
Do you have good backups? Espeically with encryption, you must have regular good backups as any data recovery is difficult or impossible with encryption. And when (not if) drive fails, you must have backup to reinstall to new drive. You may be just getting that fsck looks at file system and internally is says it is ok. See: `man e2fsck` and you may need -f parameter to force full e2fsck. And run on all ext4 partitions.
prime_mover avatar
th flag
@oldfred, Do I have to use e2fsck? Won't fsck work? Also, do I have to run the repair on entire ```/dev/sda3``` (from ```lsblk``` output above) which has fs-type ```crypto``` or ```/dev/mapper/vgubuntu-root``` which is ```ext4``` or ```/dev/mapper/luks-80422624-4c6b-4cbb-a969-eb110f60b15e``` which has type ```LVM2_m```? I am confused.
prime_mover avatar
th flag
Running ```sudo e2fsck -f -v -y /dev/mapper/vgubuntu-root``` doesn't seem to work. This command is just throwing following error continuously: ```Error reading block 2630109 (Input/output error). Ignore error? yes Force rewrite? yes Error reading block 2621760 (Input/output error) while getting next inode from scan. Ignore error? yes Force rewrite? yes```
oldfred avatar
cn flag
Did you mount & decrypt your volume(s)? fsck on encrypted LUKS http://serverfault.com/questions/375090/using-fsck-to-check-and-repair-luks-encrypted-disk For mounting encrypted see first few lines: https://askubuntu.com/questions/262211/how-do-i-resize-an-encrypted-lvm-to-install-another-copy-of-ubuntu Then you can run the fsck or e2fsck.
prime_mover avatar
th flag
@oldfred, Thank you! The instructions in the second link helped in running the check successfully. However, it didn't solve my disk problems. So i had to format the entire disk and do a clean install. But now, seems like the issue has returned again. I am not sure if it is because I restored my backed data from external disk.
oldfred avatar
cn flag
What does drive show. https://help.ubuntu.com/community/Smartmontools Or In Disks alias gnome-disks you can click on icon in upper right corner and see Smart Status https://www.smartmontools.org/wiki/Howto_ReadSmartctlReports_ATA_542.1
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.