Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security, Veeam & DevOps

  • Home
  • About
  • Advertise With US
  • Reviews
  • Contact
  • Toggle search form

How to encrypt a partition with Cryptsetup

Posted on 16/09/202003/09/2026 Christian By Christian No Comments on How to encrypt a partition with Cryptsetup
  1. Home
  2. Linux
  3. How to encrypt a partition with Cryptsetup
Graphic depicting disk encryption, featuring a floppy disk icon and a padlock symbol, with the text 'Disk Encryption' on a light blue background.

Cryptsetup is a utility used to conveniently set up disk encryption based on the DMCrypt kernel module. These include plain dm-crypt volumes, LUKS volumes, loop-AES, TrueCrypt (including VeraCrypt extension), and BitLocker formats. LUKS is the standard for Linux hard disk encryption. Here are some interesting articles: How to add a new partition to an existing Linux server, ESXI 6.7 ALARM: Seat disk exhaustion on 10, and how to setup up WatchGuard Log and Report Server in a VM.

By providing a standard on-disk-format, it does not only facilitate compatibility among distributions but also provides secure management of multiple user passwords. LUKS stores all necessary setup information in the partition header, enabling to transport or migrate data seamlessly.

Cryptsetup utility aids in configuring encrypted filesystems. To begin, you must have the cryptsetup-luks package installed. You can use the fdisk –l or blkid command to get a list of available partitions. For the purpose of this tutorial, I created a new partition called loop2. I will now encrypt our loop2 partition with Cryptsetup.

get the list of the available partitions

Before we encrypt a partition with Cryptsetup, ensure you have backed up essential data on that partition. Furthermore, encryption will overwrite any existing data on the partition.

cryptsetup --verbose --verify-passphrase luksFormat /dev/partition-name

To proceed, type YES in block letters. (Pay attention to the warning.) Afterward, you will need to input a password.

type in YES
cryptsetup luksOpen /dev/partition-name partition-name

This command will prompt you for the password you used for the encryption

Eneter your encryption passphrase

Once it is opened, the already encrypted partition is automatically mapped out to dev/mapper/partition-name and a quick delve into the fdisk –l command will confirm just that.

Encrypted partition has been mapped out

To start using this partition, you will need to format the partition with a filesystem of your choice and then mount it. I used the mkfs command in my own case

mkfs.ext4 /dev/mapper/partition-name
Format the partition filesystem and then mount it

Thats how to encrypt a partition with Cryptsetup. I hope you found this blog post helpful. So, if you have any questions, please let me know in the comment session.

Thank you for reading this post. Kindly share it with others.

  • Share on X (Opens in new window) X
  • Share on Reddit (Opens in new window) Reddit
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Facebook (Opens in new window) Facebook
  • Share on Pinterest (Opens in new window) Pinterest
  • Share on Tumblr (Opens in new window) Tumblr
  • Share on Telegram (Opens in new window) Telegram
  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Mastodon (Opens in new window) Mastodon
  • Share on Bluesky (Opens in new window) Bluesky
Linux Tags:disk, encrytp

Post navigation

Previous Post: Error 0x80070002: When trying to mount an image file
Next Post: How to stop Microsoft Edge from remembering your email ID

Related Posts

  • Screenshot 2024 02 28 at 11.17.41 PM
    GitHub Pages Deployment Guide Linux
  • Feature Image DNF vs APT
    What are the differences between dnf and apt package managers? Linux
  • elasticsearch error feature
    Elasticsearch: How to stop systemd service start operation from timing out Linux
  • linuxnethero
    Adding a subnetwork interface to an existing network interface Linux
  • FEATURE IMAGE IMAGE
    Install and configure Prometheus for Monitoring on a Linux Linux
  • linux w640 h400
    How to install and configure Ubuntu Linux on VirtualBox Linux

More Related Articles

HAProxy Deploying a load balancer from scratch and adding backend servers Linux
Screenshot 2022 02 25 at 02.06.20 How to install SAMBA file shares for Servers and Clients Linux
featuredpkg How to solve /var/lib/dpkg/lock Error in Ubuntu Linux Linux
Jenkins How to Install Jenkins Automation Server on Ubuntu 20.04 LTS Linux
Linux Shell Scripting 1 Write a Shell Script that Count Lines and Words in a File Linux
517443 637084112713220326 16x9 1 How can I tell if a password is set for a user account on Linux Linux

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

vexpert-badge-stars-5

Virtual Background

VEEAMLEGEND

Categories

Top 30 Sysadmin blog

veeaam100

Veeam Vanguard

  • Install FileZilla Client
    FileZilla Client on Mac: How to Transfer Files to WordPress via SFTP Mac
  • remote desktop connection 5 1280x720 1
    How to view and remove Remote Desktop connection history Windows
  • BitBucket Repo
    How to create Bitbucket Repository Version Control System
  • Different Class IP Address
    Classes of IP Address: Understanding IP Address Classification Network | Monitoring
  • How to Enable or Disable Inherited Permissions for Files and Folders in Windows
    How to Enable or Disable Inherited Permissions for Files and Folders in Windows Windows
  • Screenshot 2020 06 30 at 18.04.49
    How to install and configure Jitsi video conferencing server on Ubuntu Linux
  • unnamed
    How to start an application automatically on Mac Mac
  • ansible logo600 591x296 1
    Ansible_user=UNREACHABLE {Failed to connect to the host via SSH: SSH: Could not resolve hostname (Name or service not known, unreachable true) Configuration Management Tool

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,747 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Contact
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon
  • Bsky

Tags

Active Directory Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Deployment Services Windows Server 2016

Copyright © 2026 TechDirectArchive

Loading Comments...

You must be logged in to post a comment.