{"id":287,"date":"2022-05-07T14:26:25","date_gmt":"2022-05-07T12:26:25","guid":{"rendered":"https:\/\/linowebserver.org\/?page_id=287"},"modified":"2022-05-09T13:46:17","modified_gmt":"2022-05-09T11:46:17","slug":"how-to-debian-indestructable-with-btrfs","status":"publish","type":"page","link":"https:\/\/linowebserver.org\/index.php\/how-to\/how-to-debian-indestructable-with-btrfs\/","title":{"rendered":"How to: Debian indestructable with btrfs"},"content":{"rendered":"\n<p>in this How to i will describe how u can harden ur Sytem with snapshots.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1 Start your installer  <\/h2>\n\n\n\n<p>You need an install boot medium ( CD \/ USB-Stick) and you have to boot from them (check your settings in Bios or access the boot menu).<\/p>\n\n\n\n<p>Once the installer comes up select &#8222;expert installation&#8220; and follow the installation instructions until the  partitioner comes up<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Partition your drive<\/h3>\n\n\n\n<p> if needed, delete your selected drive and partitions and create a new &#8222;gpt&#8220; drive <\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>create from beginning a 1GB efi partition -&gt; save<\/li><li>create from beginning a 1-4 (maybe more)GB swap partition -&gt; save<\/li><li>create from beginning to the end a btrfs partition -&gt;<\/li><li>write partition table to disk and exit.   <\/li><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Change to the console <\/h3>\n\n\n\n<p>now we have to switch over in console by press the keys &#8222;ALT&#8220; and F2 together. The console comes up. Hit enter to enter the console. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">console commands<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/first we have to unmount \nunmount \/target\/boot\/efi\nunmount \/target\n\n\/\/we need to mount your disk (sdX) with the rootfs. In my case it's sda3\nmount \/dev\/sda3 \/mnt\n\n\/\/change dir to \/mnt\/ to create the subvolumes \ncd \/mnt\n\n\/\/create subvolumes in my case its (snapshots,home,var\/lib,usr\/share) \nbtrfs subvolume create @snapshots\nbtrfs subvolume create @home\nbtrfs subvolume create @var@lib\nbtrfs subvolume create @usr@local\n\n\/\/ now we need to list our volumes, so we need the IDs for future steps\n\/\/ keep an eye on the point \".\"\nbtrfs subvolume list .\n\n\/\/ Output:\nID 256 gen 13742 top level 5 path @rootfs\nID 258 gen 13670 top level 5 path @snapshots\nID 259 gen 13070 top level 5 path @home\nID 260 gen 13742 top level 5 path @var@lib\nID 261 gen 13548 top level 5 path @usr@local\n\n\/\/mount the rootfs subvolume first\nmount -o rw,noatime,compress=lzo,space_cache,subvolid=256 \/dev\/sda3 \/target\n\/\/create folders\nmkdir -p \/target\/boot\/efi\nmkdir -p \/target\/.snapshots\nmkdir -p \/target\/home\nmkdir -p \/target\/var\/lib\nmkdir -p \/target\/usr\/local\n\n\/\/mount the other subvolumes keep an eye to the right ID \nmount -o rw,noatime,compress=lzo,space_cache,subvolid=258 \/dev\/sda3 \/target\/.snapshots\nmount -o rw,noatime,compress=lzo,space_cache,subvolid=259 \/dev\/sda3 \/target\/home\nmount -o rw,noatime,compress=lzo,space_cache,subvolid=260 \/dev\/sda3 \/target\/var\/lib\nmount -o rw,noatime,compress=lzo,space_cache,subvolid=261 \/dev\/sda3 \/target\/usr\/local\n\n\/\/Mount the efi Disk partition to target\nmount \/dev\/sda1 \/target\/boot\/efi\n\n\/\/ edit targets fstab file vim is not aviable but nano\nnano \/target\/etc\/fstab\n\n\/\/You have to change this UUID here to yours so keep an eye before copy and paste\n\/\/ we have now to add the subvolumes and mount points inside the fstab. the easyest way ist to copy ur first line with UUID and paste it for each subvolume\n\/\/ u have to change the subvolid to the right id from the output above \n\/\/ here an excample how ur fstabs looks a like after modification:\n\nUUID=f547b62e-3832-4ab8-a38e-1960cd9c15b1 \/               btrfs   rw,noatime,compress=lzo,space_cache,subvolid=256 0       0\nUUID=f547b62e-3832-4ab8-a38e-1960cd9c15b1 \/.snapshots               btrfs   rw,noatime,compress=lzo,space_cache,subvolid=258 0       0\nUUID=f547b62e-3832-4ab8-a38e-1960cd9c15b1 \/home               btrfs   rw,noatime,compress=lzo,space_cache,subvolid=259 0       0\nUUID=f547b62e-3832-4ab8-a38e-1960cd9c15b1 \/var\/lib               btrfs   rw,noatime,compress=lzo,space_cache,subvolid=260 0       0\nUUID=f547b62e-3832-4ab8-a38e-1960cd9c15b1 \/usr\/local               btrfs   rw,noatime,compress=lzo,space_cache,subvolid=261 0       0\n\n\/\/with \"strg &amp; x\" write and quit nano\n\/\/ now woe are at the end of the console work so we exit the console and return to the installer \nexit\n\n\/\/to return to the installer Press the keys \"ALT &amp;F1\"\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Back on installer<\/h3>\n\n\n\n<p>now  follow all instructions on the installer. or just hit enter until reboot. i dont select any additional packages and install Debian with the xfce Desktop-enviroment.<br><br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">After the 1. reboot<\/h2>\n\n\n\n<p>the installation is complete, the first reboot is done, so far so good. But now we have to do some more steps.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install necessary <\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update &amp;&amp; sudo apt install btrfs-progs snapper snapper-gui git make cmake mlocate\n\n\/\/we need the gurb-btrfs package from git \ngit clone https:\/\/github.com\/Antynea\/grub-btrfs.git\n\/\/install grup-btrfs\ncd grub-btrfs\nmake install\nsystemctl enable grub-btrfs.path\n\n\/\/ Create the snapper configuration for the root filesystem \"\/\"\nsudo cp \/etc\/snapper\/config-templates\/default \/etc\/snapper\/configs\/root\nsudo sed -i 's\/^SNAPPER_CONFIGS=\\\"\\\"\/SNAPPER_CONFIGS=\\\"root\\\"\/' \/etc\/default\/snapper\n\n\/\/ Prevent \"updatedb\" from indexing the snapshots, which would slow down the system\nsudo sed -i '\/# PRUNENAMES=\/ a PRUNENAMES = \".snapshots\"' \/etc\/updatedb.conf\n\n\/\/ Reconfigure lightdm to allow booting into readn-only snapshots\nsudo sed -i 's\/^#user-authority-in-system-dir=false\/user-authority-in-system-dir=true\/' \/etc\/lightdm\/lightdm.conf\n\n# Reboot for the changes to take effect\nsudo reboot<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">2. reboot<\/h2>\n\n\n\n<p>on the Grub Boot option is one new entry &#8222;Debian GNU\/Linux snapshots&#8220; if not so you have to build a new grub &#8211; entry just boot into debian. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/open Terminal and type\nsudo update-grup2 \nsudo reboot <\/code><\/pre>\n\n\n\n<p>Now u can see the new entry on Grub Loader<\/p>\n\n\n\n<p>#debian #btrfs #installation #snapshot<\/p>\n","protected":false},"excerpt":{"rendered":"<p>in this How to i will describe how u can harden ur Sytem with snapshots. Step 1 Start your installer You need an install boot medium ( CD \/ USB-Stick) and you have to boot from them (check your settings in Bios or access the boot menu). Once the installer comes up select &#8222;expert installation&#8220; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":58,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-287","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/linowebserver.org\/index.php\/wp-json\/wp\/v2\/pages\/287","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linowebserver.org\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/linowebserver.org\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/linowebserver.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linowebserver.org\/index.php\/wp-json\/wp\/v2\/comments?post=287"}],"version-history":[{"count":4,"href":"https:\/\/linowebserver.org\/index.php\/wp-json\/wp\/v2\/pages\/287\/revisions"}],"predecessor-version":[{"id":293,"href":"https:\/\/linowebserver.org\/index.php\/wp-json\/wp\/v2\/pages\/287\/revisions\/293"}],"up":[{"embeddable":true,"href":"https:\/\/linowebserver.org\/index.php\/wp-json\/wp\/v2\/pages\/58"}],"wp:attachment":[{"href":"https:\/\/linowebserver.org\/index.php\/wp-json\/wp\/v2\/media?parent=287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}