How to check an encrypted disk for errors

8,930

I first unlocked my encrypted partition with the following command (no elevated privileges required)

udisksctl unlock -b /dev/sdb5

After being prompted, I entered the encryption passphrase na I got the Unlocked /dev/sdb5 as /dev/dm-0 message that indicated success.

And finally, I went on to do the file system check:

sudo fsck /dev/mapper/ubuntu--vg-root

And that was it! :-)

Appendix: disk setup and tips

To give some more context, here's the relevant part of the output of the lsblk /dev/sdb command: I've got a single disk, used exclusively for Ubuntu, and the encrypted partition is on /dev/sdb5. Also notice that:

  • The fdisk command does not seem to support encrypted partitions, so running th traditional sudo fdisk -l command will warn you about invalid partition tables. You can ignore those messages. Or even better:
    • Use the lsblk /dev/sdb command or sudo parted /dev/sdb print to list the partitions for the given disk (in my particular case, the disk is /dev/sdb)

Output from lsblk

$ lsblk /dev/sdb
NAME                                                 MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sdb                                                    8:128  0 111,8G  0 disk  
├─sdb1                                                 8:129  0   243M  0 part  
├─sdb2                                                 8:130  0     1K  0 part  
└─sdb5                                                 8:133  0 111,6G  0 part  
  └─luks-9cf37a83-e84a-4b85-9bba-7bcbaba8058e (dm-0) 252:0    0 111,6G  0 crypt 
    ├─ubuntu-root (dm-1)                             252:1    0 103,7G  0 lvm   
    └─ubuntu-swap_1 (dm-2)                           252:2    0   7,9G  0 lvm  

Output from parted

$ sudo parted /dev/sdi print
Model: ATA OCZ-AGILITY3 (scsi)
Disk /dev/sdi: 120GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End    Size   Type      File system  Flags
 1      1049kB  256MB  255MB  primary   ext2         boot
 2      257MB   120GB  120GB  extended
 5      257MB   120GB  120GB  logical
Share:
8,930

Related videos on Youtube

David Planella
Author by

David Planella

I work at GitLab as Director of Community Relations. Before, I worked for Canonical as the former Ubuntu Community Team Manager. As an Open Source contributor, I am mostly involved in app development and localization: I'm the developer of Qreator, former lead the Ubuntu Catalan Translators team and also a GNOME translator. In the past I've contributed to other projects, such as Debian or Mozilla. Blog Google+ Twitter

Updated on September 18, 2022

Comments

  • David Planella
    David Planella over 1 year

    During the last installation of Ubuntu I set up full disk encryption using the option on the installer. My disk seems to now have become corrupt, and I'd like to check it for errors.

    GNOME Disks on Ubuntu 12.10 doesn't seem to be able to handle encrypted partitions yet (and Nautilus sees the disk also, but fails to mount it), so I'm looking for a way to do it on the command line.

    How can I unlock my encrypted partition and check the filesystem within for errors?