{"id":27,"date":"2020-04-10T19:15:55","date_gmt":"2020-04-10T18:15:55","guid":{"rendered":"https:\/\/blog.thomarite.uk\/?p=27"},"modified":"2020-05-11T23:54:05","modified_gmt":"2020-05-11T22:54:05","slug":"forensics-101-linux-disk-encryption","status":"publish","type":"post","link":"https:\/\/blog.thomarite.uk\/index.php\/2020\/04\/10\/forensics-101-linux-disk-encryption\/","title":{"rendered":"LVM 101 + Linux disk encryption"},"content":{"rendered":"\n<p>Once more post from Cloudflare. I think most Linux distributions already offer by default transparent disk encryption.  As far as I can see in my Debian, I have encryption with LVM. I need to write a post about LVM as I have always to google most basic command. &#8220;Logic Volume Manager&#8221; (LVM) is an abstraction layer for managing storage (maybe too basic explanation but that is how I understand it). When I built my laptop, I had the option (I think it was by default) to choose LVM + encryption (dm_crypt module). So I took that.<\/p>\n\n\n\n<p>So first, how I check my LVM? Well, df -h, will give the first clues<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code># df -hT\nFilesystem Type Size Used Avail Use% Mounted on\nudev devtmpfs 3.9G 0 3.9G 0% \/dev\ntmpfs tmpfs 794M 2.7M 791M 1% \/run\n\/dev\/mapper\/laptop--vg-root ext4 24G 17G 6.3G 73% \/\ntmpfs tmpfs 3.9G 414M 3.5G 11% \/dev\/shm\ntmpfs tmpfs 5.0M 8.0K 5.0M 1% \/run\/lock\ntmpfs tmpfs 3.9G 0 3.9G 0% \/sys\/fs\/cgroup\n\/dev\/sda2 ext2 237M 155M 70M 69% \/boot\n\/dev\/sda1 vfat 496M 60M 437M 13% \/boot\/efi\n\/dev\/mapper\/laptop--vg-home ext4 20G 9.9G 8.7G 54% \/home\ntmpfs tmpfs 794M 24K 794M 1% \/run\/user\/1000<\/code><\/pre>\n\n\n\n<p>You see thing with &#8220;\/dev\/mapper&#8221; and &#8220;vg&#8221; (volume group). So you have LVM running.<\/p>\n\n\n\n<p>Some basic LVM notes:<\/p>\n\n\n\n<p># pvs &#8211;&gt; it will show the physical disks, partitions, etc used in your LVM  setup and the &#8220;vgs&#8221; they belong to. PVS stands for &#8220;physical volume system&#8221;. In my case only the partition sda3 from my physical disk is part of LVM. Physical volumes are used to create Volume groups.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code># pvs<br>PV VG Fmt Attr PSize PFree<br>\/dev\/mapper\/sda3_crypt laptop-vg lvm2 a-- 237.73g &lt;2.62g<\/code><\/pre>\n\n\n\n<p># vgs &#8211;&gt; it will show you the volumes  in your system, the number of PV they are using and the number of LV they are providing. VGS stands for &#8220;volume group system&#8221;. In my case, I have just one VG, that is use 1 PV and is providing 4 LV.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code># vgs<br>VG #PV #LV #SN Attr VSize VFree<br>laptop-vg 1 4 0 wz--n- 237.73g &lt;2.62g<\/code><\/pre>\n\n\n\n<p>#lvs &#8211;&gt; it will show the &#8220;logical volumes&#8221; you have created from a VG. In my case,  I have four LV.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code># lvs<br>LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert<br>home laptop-vg -wi-ao---- 22.00g<br>root laptop-vg -wi-ao---- 24.31g<br>storage laptop-vg -wi-ao---- 182.00g<br>swap_1 laptop-vg -wi-ao---- 6.80g<\/code><\/pre>\n\n\n\n<p>BTW, how I can see all the partitions in my machine, &#8220;fdisk -l&#8221;<\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<pre class=\"wp-block-preformatted\"><code>root@athens:\/boot# fdisk -l\nDisk \/dev\/sda: 238.49 GaiB, 256060514304 bytes, 500118192 sectors\nDisk model: NISU SSD ALLI\nUnits: sectors of 1 * 512 = 512 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisklabel type: gpt\nDisk identifier: TRALARI-TRALARI-TRALARI-TRALARI<\/code>\n<code>Device Start End Sectors Size Type\n\/dev\/sda1 2048 1050623 1048576 512M EFI System\n\/dev\/sda2 1050624 1550335 499712 244M Linux filesystem\n\/dev\/sda3 1550336 500117503 498567168 237.8G Linux filesystem<\/code><\/pre>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<p>So based on our &#8220;pvs&#8221; we know &#8220;dev\/sda3&#8221; is part of LVM. How the encryption is happening? The type of partition will tell us<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code># blkid \/dev\/sda3<br>\/dev\/sda3: UUID=\"f6263aee-3966-4c23-a4ef-b4d9916f1a07\" TYPE=\"crypto_LUKS\" PARTUUID=\"b224eb49-1e71-4570-8b62-fb38df801170\"<br>#<\/code><\/pre>\n\n\n\n<p>So, &#8220;crypto_LUKS&#8221; is key. Our LVM is running over a partition that is encrypted.<\/p>\n\n\n\n<p>So after this detour, lets go back to Cloudflare post about Linux disk encryption. <\/p>\n\n\n\n<p>I really enjoyed the kind of forensic work trying to discover when and why the changes in the Linux kernel code (!) were happening  and how affected the speed. BTW, I crashed my laptop when trying to run their tests!<\/p>\n\n\n\n<p><a href=\"https:\/\/blog.cloudflare.com\/speeding-up-linux-disk-encryption\">https:\/\/blog.cloudflare.com\/speeding-up-linux-disk-encryption<\/a><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Once more post from Cloudflare. I think most Linux distributions already offer by default transparent disk encryption. As far as I can see in my Debian, I have encryption with LVM. I need to write a post about LVM as I have always to google most basic command. &#8220;Logic Volume Manager&#8221; (LVM) is an abstraction &hellip; <a href=\"https:\/\/blog.thomarite.uk\/index.php\/2020\/04\/10\/forensics-101-linux-disk-encryption\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;LVM 101 + Linux disk encryption&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[],"class_list":["post-27","post","type-post","status-publish","format-standard","hentry","category-unix","category-security"],"_links":{"self":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts\/27","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/comments?post=27"}],"version-history":[{"count":3,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts\/27\/revisions"}],"predecessor-version":[{"id":140,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts\/27\/revisions\/140"}],"wp:attachment":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/media?parent=27"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/categories?post=27"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/tags?post=27"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}