{"id":764,"date":"2021-10-31T01:15:55","date_gmt":"2021-10-31T01:15:55","guid":{"rendered":"https:\/\/blog.thomarite.uk\/?p=764"},"modified":"2021-10-31T01:15:55","modified_gmt":"2021-10-31T00:15:55","slug":"use-zfs","status":"publish","type":"post","link":"https:\/\/blog.thomarite.uk\/index.php\/2021\/10\/31\/use-zfs\/","title":{"rendered":"Use ZFS"},"content":{"rendered":"\n<p>As part of my reinstallation, I had to create a ZFS partition that I used to use for personal storage. Debian Installation process doesnt provide this option, so I have to do it manually. To be honest, it is good to remember\/refresh these &#8220;basic&#8221; things, you never know when you are going to need them (urgently very likely).<\/p>\n\n\n\n<p>As the installation process gave most of the space to the &#8220;home&#8221; partition, that&#8217;s the one I need to take space for creating my ZFS partition. I chose LVM during installation so I dont really have to deal with physical partition, it is mainly logical volumes aka &#8220;lv&#8221;.<\/p>\n\n\n\n<p>So I rebooted in single-mode as I wanted to be sure that I didnt damage anything and I had to umount the &#8220;home&#8221; lv.  So as root:<\/p>\n\n\n\n<p> <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Check mounted partitions\n# df -hT\n\nChecks LV summary\n# lvs\n\nUmount \/home\n# umount \/home\/\n\nCheck \"home\" is not munted\n# df -hT\n\nCheck VolgumeGroup summary\n# vgs\n\nPerform filesystem check before making any change\n# e2fsck -fy \/dev\/mapper\/athens--vg-home\n\nResize filesystem to 22G\n# resize2fs \/dev\/mapper\/athens--vg-home 22G\n\nCheck LV hasnt changed\n# lvs\n\nReduce LV for home to 22G\n# lvreduce -L 22G \/dev\/mapper\/athens--vg-home\n\nCheck LV home is reduced\n# lvs\n  LV      VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert\n  home    athens-vg -wi-ao----  22.00g                                                    \n  root    athens-vg -wi-ao---- &lt;27.94g                                                    \n  swap_1  athens-vg -wi-ao---- 976.00m                                                    \n# \n\nCheck you have free space in the VG\n# vgs\n  VG        #PV #LV #SN Attr   VSize   VFree   \n  athens-vg   1   3   0 wz--n- 237.48g &lt;186.59g\n# \n\nReboot to be sure everything is fine\n# reboot\n\nCheck all partitions are mounted and \"home\" is just 22G\n$ df -hT\nFilesystem                  Type      Size  Used Avail Use% Mounted on\nudev                        devtmpfs  3.9G     0  3.9G   0% \/dev\ntmpfs                       tmpfs     786M  1.6M  785M   1% \/run\n\/dev\/mapper\/athens--vg-root ext4       28G  6.7G   20G  26% \/\ntmpfs                       tmpfs     3.9G   87M  3.8G   3% \/dev\/shm\ntmpfs                       tmpfs     5.0M  8.0K  5.0M   1% \/run\/lock\n\/dev\/sda2                   ext2      456M   72M  360M  17% \/boot\n\/dev\/mapper\/athens--vg-home ext4       21G  3.0G   17G  16% \/home\n\/dev\/sda1                   vfat      496M   64M  433M  13% \/boot\/efi\ntmpfs                       tmpfs     786M   40K  786M   1% \/run\/user\/1000\n$\n\nCreate new LV \"storage\" using the spare space in the VG\n# lvcreate -L 186G -n storage athens-vg\n  Logical volume \"storage\" created.\n# \n\nCheck VG space has reduced\n# vgs\n  VG        #PV #LV #SN Attr   VSize   VFree  \n  athens-vg   1   4   0 wz--n- 237.48g 604.00m\n#\n\nCheck we have a new LV storage of 186G\n# lvs\n  LV      VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert\n  home    athens-vg -wi-ao----  22.00g                                                    \n  root    athens-vg -wi-ao---- &lt;27.94g                                                    \n  storage athens-vg -wi-a----- 186.00g                                                    \n  swap_1  athens-vg -wi-ao---- 976.00m                                                    \n#\n\nCreate our Zpool storage using the LV storage.\n# zpool create storage \/dev\/mapper\/athens--vg-storage \n\nCheck Zpool status\n# zpool status\n  pool: storage\n state: ONLINE\nconfig:\n\n\tNAME                  STATE     READ WRITE CKSUM\n\tstorage               ONLINE       0     0     0\n\t  athens--vg-storage  ONLINE       0     0     0\n\nerrors: No known data errors\n#\n\nCheck mount point for ZFS pool\n# zfs get mountpoint storage\nNAME     PROPERTY    VALUE       SOURCE\nstorage  mountpoint  \/storage    default\n# \n\nChange Zpool storage mount point to a point in my home dir\n# zfs set mountpoint=\/home\/tomas\/storage storage\n\nCheck ZFS list\n# zfs list\nNAME      USED  AVAIL     REFER  MOUNTPOINT\nstorage   165K   179G       24K  \/home\/yo\/storage\n# \n\nCheck all partitions\n$ df -hT\nFilesystem                  Type      Size  Used Avail Use% Mounted on\nudev                        devtmpfs  3.9G     0  3.9G   0% \/dev\ntmpfs                       tmpfs     786M  1.6M  785M   1% \/run\n\/dev\/mapper\/athens--vg-root ext4       28G  6.7G   20G  26% \/\ntmpfs                       tmpfs     3.9G   87M  3.8G   3% \/dev\/shm\ntmpfs                       tmpfs     5.0M  8.0K  5.0M   1% \/run\/lock\n\/dev\/sda2                   ext2      456M   72M  360M  17% \/boot\n\/dev\/mapper\/athens--vg-home ext4       21G  3.0G   17G  16% \/home\n\/dev\/sda1                   vfat      496M   64M  433M  13% \/boot\/efi\ntmpfs                       tmpfs     786M   40K  786M   1% \/run\/user\/1000\nstorage                     zfs       180G  128K  180G   1% \/home\/y\/storage\n$ \n<\/pre>\n\n\n\n<p>I have used these links to refresh myself:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>lvs resize: https:\/\/www.rootusers.com\/lvm-resize-how-to-decrease-an-lvm-partition\/<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li>create lv: https:\/\/www.thegeekstuff.com\/2010\/08\/how-to-create-lvm\/<br><\/li><li>create zfs pool: https:\/\/ubuntu.com\/tutorials\/setup-zfs-storage-pool#3-creating-a-zfs-pool<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li>change zfs mount point: https:\/\/docs.oracle.com\/cd\/E19253-01\/819-5461\/gaztn\/index.html<\/li><\/ul>\n\n\n\n<p>To be honest, I thought I was going to struggle much more but it has been quick.<\/p>\n\n\n\n<p>Step by step getting back to my normal environment (and trying to improve it). I said it before, I should be able to reinstall my laptop easily, like a production server&#8230;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As part of my reinstallation, I had to create a ZFS partition that I used to use for personal storage. Debian Installation process doesnt provide this option, so I have to do it manually. To be honest, it is good to remember\/refresh these &#8220;basic&#8221; things, you never know when you are going to need them &hellip; <a href=\"https:\/\/blog.thomarite.uk\/index.php\/2021\/10\/31\/use-zfs\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Use ZFS&#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],"tags":[],"class_list":["post-764","post","type-post","status-publish","format-standard","hentry","category-unix"],"_links":{"self":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts\/764","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=764"}],"version-history":[{"count":1,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts\/764\/revisions"}],"predecessor-version":[{"id":765,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts\/764\/revisions\/765"}],"wp:attachment":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/media?parent=764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/categories?post=764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/tags?post=764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}