{"id":1033,"date":"2026-09-21T16:44:29","date_gmt":"2026-09-21T14:44:29","guid":{"rendered":"https:\/\/members.loria.fr\/AScheuer\/?p=1033"},"modified":"2026-09-21T16:44:29","modified_gmt":"2026-09-21T14:44:29","slug":"splitting-ubuntu-encrypted-partition","status":"publish","type":"post","link":"https:\/\/members.loria.fr\/AScheuer\/system\/splitting-ubuntu-encrypted-partition\/","title":{"rendered":"Splitting an Ubuntu encrypted partition"},"content":{"rendered":"<h1>Context<\/h1>\n<p>When using a laptop, having an encrypted partition is now a security requirement. The simplest way to have one under Ubuntu is to ask for it during the installation. However, the default LVM + encrypted installation only creates one partition, containing both <code>\/<\/code> and <code>\/home<\/code>.<\/p>\n<h1>Objective<\/h1>\n<p>Having two partitions allows to separate the system (in <code>\/<\/code>) from the configurations and data (in <code>\/home<\/code>). In that situation, any system modification (e.g., an update or an upgrade) operates in a separate partition of the disk, and has nearly no risk to modify your configurations and data.<\/p>\n<p>It does not mean you don&rsquo;t have to save them, it just limits the risks of system operations.<\/p>\n<h1>Process<\/h1>\n<p>Splitting the partition in two has two drawbacks: you cannot do it on your system (you need to run an external one, e.g. on a USB key, as a mounted <code>ext4<\/code> partition cannot be shrank), and it uses some line commands (I did not find any GUI &#8211; as e.g. <code>gparted<\/code> &#8211; able to do it) which are rarely used.<\/p>\n<p>As I did not find any help on that process online, I did some mistakes and had to reinstall my system from scratch twice. Reading this page should help you to avoid that!<\/p>\n<p>Once your system is installed (on an encrypted partition with a single LVM logical volume), you will have to:<\/p>\n<ol>\n<li>Start your laptop on an external system, using for example the USB key used to install your system.<br \/>\nThis may require some change in the BIOS (which can prevent a boot on USB).<\/li>\n<li>Unlock your encrypted partition (<span style=\"color: #ff0000\"><strong>but do not decrypt it<\/strong><\/span>, as re-encryption is not possible without data loss), using\n<p align=\"center\"><code><a href=\"https:\/\/www.man7.org\/linux\/man-pages\/man8\/sudo.8.html\">sudo<\/a> <a href=\"https:\/\/www.man7.org\/linux\/man-pages\/man8\/cryptsetup-open.8.html\">cryptsetup open<\/a><\/code> &lt;partition_device&gt; &lt;partition_name&gt;<\/p>\n<p>where &lt;partition_device&gt; is your partition device (<code>\/dev\/<\/code>&#8230;, which can be found either using <code>gparted<\/code> or with <code><a href=\"https:\/\/www.man7.org\/linux\/man-pages\/man8\/lsblk.8.html\">lsblk<\/a><\/code>), and &lt;partition_name&gt; is the name you choose for the decrypted device. The command will ask for your passphrase.<\/li>\n<li>Shrink the logical volume containing your system, using\n<p align=\"center\"><code>sudo <a href=\"https:\/\/www.man7.org\/linux\/man-pages\/man8\/lvresize.8.html\">lvresize<\/a> -r -L<\/code> &lt;size&gt; &lt;LV system name&gt;<\/p>\n<p>where &lt;size&gt; is the desired size of your system logical volume (e.g. <code>128G<\/code> for 128 GB) and &lt;LV system name&gt; is the name of this logical volume, which can be found using <code><a href=\"https:\/\/www.man7.org\/linux\/man-pages\/man8\/lvs.8.html\">lvs<\/a><\/code>, and is of the form &lt;VG name&gt;<code>\/<\/code>&lt;LV name&gt;, i.e. is composed of the name of the volume group and the name of the logical volume in it.<\/p>\n<p><strong>This is the action which requires to be on an external system<\/strong>, as the <code>-r<\/code> argument will also ask <code><a href=\"https:\/\/www.man7.org\/linux\/man-pages\/man8\/fsadm.8.html\">fsadm<\/a><\/code> to shrink the contained <code>ext4<\/code> partition using <code><a href=\"https:\/\/www.man7.org\/linux\/man-pages\/man8\/resize2fs.8.html\">resize2fs<\/a><\/code>, which cannot be done on a mounted partition.<\/li>\n<li>Create the additional logical volume,\u00a0using\n<p align=\"center\"><code>sudo <a href=\"https:\/\/www.man7.org\/linux\/man-pages\/man8\/lvcreate.8.html\">lvcreate<\/a> -l 100%FREE -n<\/code> &lt;LV data name&gt; &lt;VG name&gt;<\/p>\n<p>where &lt;VG name&gt; is the name of the volume group containing your system logical volume (in which you add the new logical volume) and &lt;LV data name&gt; is the name of this new logical volume.<\/p>\n<p>You also have to format this logical volume to add an <code>ext4<\/code> partition, using<\/p>\n<p align=\"center\"><code>sudo <a href=\"https:\/\/www.man7.org\/linux\/man-pages\/man8\/mkfs.8.html\">mkfs<\/a> -t ext4 \/dev\/mapper\/<\/code>&lt;VG name&gt;<code>-<\/code>&lt;LV data name&gt;<\/p>\n<\/li>\n<li>Mount the two partitions (<code>\/<\/code> and <code>\/home<\/code>) and move your data from the <code>home<\/code> directory of the <code>\/<\/code> partition to the <code>\/home<\/code> partition : using two\u00a0<code>tar<\/code>\u00a0allows to keep any special file (as, e.g., symbolic links).<\/li>\n<li>Update the file system table (<code>etc\/fstab<\/code> in <code>\/<\/code>) to mount the two partitions : you can use <code>\/dev\/disk\/by-id\/dm-name-<\/code>&lt;VG name&gt;<code>-<\/code>&lt;LV data name&gt; as first parameter, to identify your partitions ; last parameter is 1 for\u00a0<code>\/<\/code> partition and 2 for the <code>\/home<\/code> partition.<\/li>\n<\/ol>\n<p>You can then restart your computer normally, and check with <code>df -h \/ \/home<\/code> that system and data are separated.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Context<\/p>\n<p>When using a laptop, having an encrypted partition is now a security requirement. The simplest way to have one under Ubuntu is to ask for it during the installation. However, the default LVM + encrypted installation only creates one partition, containing both \/ and \/home.<\/p>\n<p>Objective<\/p>\n<p>Having two partitions allows to separate the system (in \/) from the configurations and data (in \/home). In that situation, any system modification (e.g., an update or an upgrade) operates in a separate partition of the disk, and has nearly no risk to modify your configurations and data.<\/p>\n<p>It does not mean you don&rsquo;t have to save them,<\/p>\n","protected":false},"author":105,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-1033","post","type-post","status-publish","format-standard","hentry","category-system"],"_links":{"self":[{"href":"https:\/\/members.loria.fr\/AScheuer\/wp-json\/wp\/v2\/posts\/1033","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/members.loria.fr\/AScheuer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/members.loria.fr\/AScheuer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/members.loria.fr\/AScheuer\/wp-json\/wp\/v2\/users\/105"}],"replies":[{"embeddable":true,"href":"https:\/\/members.loria.fr\/AScheuer\/wp-json\/wp\/v2\/comments?post=1033"}],"version-history":[{"count":12,"href":"https:\/\/members.loria.fr\/AScheuer\/wp-json\/wp\/v2\/posts\/1033\/revisions"}],"predecessor-version":[{"id":1045,"href":"https:\/\/members.loria.fr\/AScheuer\/wp-json\/wp\/v2\/posts\/1033\/revisions\/1045"}],"wp:attachment":[{"href":"https:\/\/members.loria.fr\/AScheuer\/wp-json\/wp\/v2\/media?parent=1033"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/members.loria.fr\/AScheuer\/wp-json\/wp\/v2\/categories?post=1033"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/members.loria.fr\/AScheuer\/wp-json\/wp\/v2\/tags?post=1033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}