I just went through the install process specifying "do something else," then picked my partition to use as an encrypted container, and finally used that container to be formatted with a filesystem. I didn't see an option to use the cipher of my choosing and noted that the default appears to be sha256.

Is there a way to tell it what I want to use?

Edit: this was using the 16.10 desktop iso.

Edit2: given AlexP's example table below, I thought I'd list the actual defaults after going through the Ubuntu installer as described above.

Edit3: supplementing with what I think shows that Arch's recommendations and the Ubuntu defaults perhaps don't differ at all.

The only thing that stands out is the payload offset and anecdotally I perceive that the ubuntu drive opens faster. I think this may be because of it's option for --iter-time. The default is 2000 (milliseconds) and I would have specified 5000 manually. This is how long it churns before arriving at the final hash if I understand correctly. Every time you unlock, you have to do this again to get the right password hash (correct if wrong). Other than that, things are identical.

### ubuntu default
$ sudo cryptsetup luksDump

Version:        1
Cipher name:    aes
Cipher mode:    xts-plain64
Hash spec:      sha256
Payload offset: 4096
MK bits:        512

### arch recommendation
$ sudo cryptsetup luksDump

Version:        1
Cipher name:    aes
Cipher mode:    xts-plain64
Hash spec:      sha256
Payload offset: 65535
MK bits:        512

### ubuntu default
$ sudo cryptsetup status /dev/mapper/ubuntu

  type:    LUKS1
  cipher:  aes-xts-plain64
  keysize: 512 bits
  device:  /dev/sdb2
  offset:  4096 sectors
  size:    487393280 sectors
  mode:    read/write

### arch recommendation
$ sudo cryptsetup status /dev/mapper/arch

  type:    LUKS1
  cipher:  aes-xts-plain64
  keysize: 512 bits
  device:  /dev/sda2
  offset:  65535 sectors
  size:    233262018 sectors

The default cipher is aes-xts-plain64 with 256-bit key and SHA-1 checksums. This is a good default. A very good default. Unless you are a qualified cryptographer you should leave it as is. Knowledgeable people have chosen this default after spending a lot of time and effort.

To find out what cipher is used for your encrypted container you can use the command sudo cryptsetup status and sudo cryptsetup luksDump. For example:

$ sudo lsblk
sda                     8:0    0   40G  0 disk  
├─sda1                  8:1    0  284M  0 part  /boot
└─sda2                  8:2    0 39.7G  0 part  
  └─Machinia          252:0    0 39.7G  0 crypt 
    ├─Machinia-Swap   252:1    0  1.2G  0 lvm   [SWAP]
    ├─Machinia-Home   252:2    0  9.5G  0 lvm   /home
    ├─Machinia-System 252:3    0   20G  0 lvm   /
    └─Machinia-Srv    252:4    0    6G  0 lvm   /srv
sr0                    11:0    1 1024M  0 rom   

$ sudo cryptsetup status Machinia
/dev/mapper/Machinia is active and is in use.
  type:    LUKS1
  cipher:  aes-xts-plain64
  keysize: 256 bits
  device:  /dev/sda2
  offset:  4096 sectors
  size:    83298304 sectors
  mode:    read/write
  flags:   discards

$ sudo cryptsetup luksDump /dev/sda2
LUKS header information for /dev/sda2

Version:        1
Cipher name:    aes
Cipher mode:    xts-plain64
Hash spec:      sha1
Payload offset: 4096

Those being said, it you absolutely want to specify another cipher, you can. The basic process is well described by the good folks at ArchLinux in Encrypting an entire system. Do it as follows:

  1. Boot from the installation medium.

  2. Choose "Try Ubuntu".

  3. Open a terminal.

  4. Using fdisk, parted or the graphical Gparted, create your /boot partition manually. (This assumes that you are using an MBR-partitioned disk. If you are using a GPT-formatted disk, you must also create an EFI System partition.)

  5. Create your partition to be encrypted manually. Let's say that this is /dev/sda2.

  6. Format it as a LUKS container. This is where you specify the cipher:

    sudo cryptsetup luksFormat /dev/sda2 --cipher=<cipherspec> --keysize=<size>

    For example,

    sudo crypsetup luksFormat /dev/sda2 --cipher=aes-cbc-essiv:sha256 --keysize=512

    Let me repeat that unless you have professional cryptographic knowledge you shouldn't do this. But let's continue.

  7. Open your encrypted partition and give it a container name:

    sudo cryptsetup luksOpen /dev/sda2 <name>

    For a "pet" computer system, a good choice is to use the host name with an initial capital. For example, if you plan to use the host name machinia,

    sudo cryptsetup luksOpen /dev/sda2 Machinia
  8. Format /dev/mapper/Machinia (or whatever name you chose at step 7) as a LVM physical volume:

    sudo pvcreate /dev/mapper/Machinia # Use the name chosen in step 7
  9. Create a LVM volume group on the physical volume:

    sudo vgcreate Machinia /dev/mapper/Machinia # Use the name chosen in step 7
  10. Create logical volumes for /, /home, /srv, /var, swap etc. in the LVM volume group. You must create at least one logical volume for /. A separate volume for /home is optional but recommended. Creating separate volumes for /var, swap and so on is optional and depends on your plans.

    sudo lvcreate -L 20g -n System Machinia # /
    sudo lvcreate -L 3g  -n Swap   Machinia # swap
    sudo lvcreate -L 10g -n Home   Machinia # /home

    You may want to leave some space unallocated, in order to be able to use LVM snapshots. Your choice.

  11. Now run the installer and install Ubuntu choosing "Something else" and selecting /dev/sda1 (or whatever) for /boot, /dev/mapper/Machinia-System (using your chosen names, of course) for /, /dev/mapper/Machinia-Swap for swap space, /dev/mapper/Machinia-Home for /home.

    Use the partition made in step 4 for /boot, and the logical volumes created in step 10 for /, swap, /home etc.

    If you are using an MBR-partitioned disk double-check and make sure that GRUB is to be installed on the physical disk, /dev/sda (or whatever is right for your system.)

  12. Let the installer proceed to the end. When it finishes, choose "Continue testing" and go back to your terminal.

  13. Mount your future root volume on /target, mount special directories, then chroot into /target:

    sudo mount /dev/mapper/Machinia-System /target
    for d in dev proc run sys; do sudo mount --bind /$d /target/$d; done
    chroot /target
  14. You are now root in your future root volume. Go to /etc and edit /etc/crypttab:

    cd /etc
    echo Machinia UUID=$(cryptsetup luksUUID /dev/sda2) none luks,discard >crypttab

    /etc/crypttab should look like this:

    # cat /etc/crypttab
    Machinia UUID=016193a0-8a79-416c-95f3-c94bd3745c5c none luks,discard

    (With your chosen name instead of Machinia, and the UUID returned by cryptsetup luksUUID.)

  15. Update the initial root file system and GRUB:

  16. Exit from the chroot:

  17. Unmount what you mounted in step 13:

    for d in dev proc run sys; do sudo umount /target/$d; done
    umount /target
  18. Reboot and hope for the best.

  • Wow. This is awesomely thorough, but also assumes a lot! For example, I don't want to use LVM or swap. This is super helpful, though, as I've not had anyone actually specify that one can "try ubuntu" to open the crypto device and then install with it mounted somewhere! – Hendy Feb 11 '17 at 15:21
  • As to you recommending Arch as a good reference... that's exactly what distro I use and why I asked this question. I typically just follow what they say an in their table they have sha512, not sha256. I made an "oops" above and wanted the specify the hash, not the cipher. Sorry if that caused confusion, but the gist is the same (manually apply cryptsetup). – Hendy Feb 11 '17 at 15:27
  • @Hendy: The question was how to specify the cipher when installing Ubuntu; this sketchy procedure results in a setup very similar to what the installer makes by default when the user choses to encrypt the system, that is, LVM on LUKS. Advanced users can of course choose other schemes. – AlexP Feb 11 '17 at 18:17
  • Maybe, though I didn't get LVM and all of those volumes when I chose "do something else" and picked to encrypt /dev/sdb2 as an encrypted container and then sdb2_crypto (or whatever the name) for the filesystem. The default may change depending on how the user chooses to encrypt, then? Also, see my updated question which suggests sha256 is the default at least in xenial, not sha-1. – Hendy Feb 11 '17 at 18:28
  • cryptsetup has indeed reasonable defaults... You can check it nicely on Arch wiki as mentioned by @Hendy. The only thing I would change is larger key size (512 bits, so that aes256 is used and not aes128). E.g. KDE Partition Manager specifically specified -s 512 when creating LUKS volumes but leaves everything else default. – Andrius Štikonas Feb 13 '17 at 0:41

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.