diff --git a/storage/filesystem.md b/storage/filesystem.md new file mode 100644 index 0000000..4a96dcb --- /dev/null +++ b/storage/filesystem.md @@ -0,0 +1,111 @@ +# Notes +We have 3 drives: +* `sda` - SIZE:931.5G, MODEL:ST1000DM003-1ER1, SERIAL:Z4Y2HMTE (1 part: /mnt/storage1) +* `sdb` - SIZE:931.5G, MODEL:ST1000DM010-2EP1, SERIAL:Z9AD9PSB (1 part: /mnt/storage2) +* `nvme0n1` - SIZE:931.5G, MODEL:CT1000P3SSD8, SERIAL:2336431AEC05 (2 part: /boot/efi, /) + +## Health checks +### Install tools + +```bash +sudo apt update && sudo apt install -y smartmontools nvme-cli +``` + +### NVMe SSD Health +Run: +```bash +sudo nvme smart-log /dev/nvme0n1 +``` +critical_warning: 0 +percentage_used: 1% +media_errors: 0 + +This is good. + +### HDDs Health +Run: +```bash +sudo smartctl -H /dev/sda +sudo smartctl -i /dev/sda +sudo smartctl -H /dev/sdb +sudo smartctl -i /dev/sdb +``` + +All passed. + +## Setup +Considering the different drives I have, just as I thought, the NVMe SSD will be used for application and databases which require higher I/O throughputs and the HDDs will be used for media storage. In the following setup, the SSD will remain untouched and I'll focus on the HDDs. Because I have fairly limited storage for my media, I will not be using any kind of RAID (like SnapRAID). To make the setup just a bit simpler and not manage 2 file systems in both HDDs I'll use MergerFS to pool both drives into a single mount point. + +### Partitioning +Now because I just installed the OS and haven't touched the HDDs yet they don't need to be repartitioned and formatted but I'll still include the process to do so. + +First, make sure to identify the drives properly with: +```bash +lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINTS +``` +We initiliase a new GPT (GUID partition table) on our /dev/sda drive and make it span the entire disk with: +```bash +sudo parted /dev/sda --script mklabel gpt mkpart primary ext4 0% 100% +``` +and create the ext4 partition called "storage1" that is /dev/sda1: +```bash +sudo mkfs.ext4 -L "storage1" /dev/sda1 +``` + +Similarly, for our 2nd drive /dev/sdb: +```bash +sudo parted /dev/sdb --script mklabel gpt mkpart primary ext4 0% 100% +sudo mkfs.ext4 -L "storage2" /dev/sdb1 +``` + +Next we create the mount folders for the drives and the merged pool: +```bash +sudo mkdir -p /mnt/storage1 /mnt/storage2 /mnt/storage +``` + +and get the UUIDs of the partitions for later: +```bash +sudo blkid +``` +in our case: +``` +/dev/sda1: UUID="711aed59-492f-4978-b8e5-899eb1e7479c" +/dev/sdb1: UUID="1addcd31-341d-447a-8026-8d1c2e64d086" +``` + +### MergerFS +Now to pool the drives together, we need MergerFS and FUSE (to create the pooled drive filesystem): +```bash +sudo apt update && sudo apt install -y mergerfs fuse3 +``` +and we allow non-root users (and Docker) to read our FUSE mounts: +```bash +sudo sed -i 's/#user_allow_other/user_allow_other/' /etc/fuse.conf +``` + +Last, we want the merged pool to be persistent so we edit `/etc/fstab`: +```bash +sudo nano /etc/fstab +``` +and add the drives and MergerFS pool by adding the following to `/etc/fstab`: +``` +# --- Physical HDDs --- +UUID=711aed59-492f-4978-b8e5-899eb1e7479c /mnt/storage1 ext4 defaults,noatime,nofail 0 2 +UUID=1addcd31-341d-447a-8026-8d1c2e64d086 /mnt/storage2 ext4 defaults,noatime,nofail 0 2 + +# --- MergerFS Unified Storage Pool --- +/mnt/storage1:/mnt/storage2 /mnt/storage fuse.mergerfs defaults,allow_other,use_ino,category.create=mfs,minfreespace=10G,fsname=mergerfs 0 0 +``` +After saving the file, mount all filesystems: +```bash +sudo mount -a +``` +and verify that the pool is of the pool capacity: +```bash +df -h /mnt/storage +``` + +Now one of the major choices here was the lack of RAID or backup system (for now). +The reason is that it would substantially reduce our available storage space. +That being said if one of the HDDs were to fail then the other would still be safe and operational. +However, if files are deleted from any drives there is no coming back. \ No newline at end of file