Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using two SSDs as cache for two HDDs with LVM #814

Open
xiro-codes opened this issue Oct 7, 2024 · 3 comments
Open

Using two SSDs as cache for two HDDs with LVM #814

xiro-codes opened this issue Oct 7, 2024 · 3 comments
Labels
question Not a bug or issue, but a question asking for help or information

Comments

@xiro-codes
Copy link

xiro-codes commented Oct 7, 2024

sorry this is the llm prompt and response, tldr i need to add a line to lvm.conf how to do go about that with disko

>>> could i combine 2x250gb ssd and 2x1tb hdd to use the ssd as a cache for the hdd in linux

Yes, you can combine two 250GB SSDs and two 1TB HDDs to create a storage solution that uses the SSDs
as a cache for the HDDs in Linux. This is known as a "hybrid" storage configuration, where the 
faster SSDs are used as a cache for the slower HDDs.

To set this up in Linux, you can use a tool called LVM (Logical Volume Manager) to create a single 
logical volume that spans both the SSDs and the HDDs. You can then configure LVM to use the SSDs as 
a cache for the HDDs by setting up a "write-through" policy, which writes data to both the SSDs and 
the HDDs simultaneously.

Here's an example of how you might set this up using LVM:

1. First, create a physical volume (PV) for each disk. In this example, we'll use /dev/sda and 
/dev/sdb for the SSDs, and /dev/sdc and /dev/sdd for the HDDs.

sudo pvcreate /dev/sda
sudo pvcreate /dev/sdb
sudo pvcreate /dev/sdc
sudo pvcreate /dev/sdd

2. Next, create a volume group (VG) that spans both the SSD and HDD PVs. In this example, we'll call
it "hybrid-storage".

sudo vgcreate hybrid-storage /dev/sda /dev/sdb /dev/sdc /dev/sdd

3. Now, create a logical volume (LV) that spans the entire VG. In this example, we'll call it 
"root".

sudo lvcreate hybrid-storage -n root

4. Finally, format the LV as ext4 and mount it to /mnt/hybrid-storage.

sudo mkfs.ext4 /dev/mapper/hybrid--storage-root
sudo mount /dev/mapper/hybrid--storage-root /mnt/hybrid-storage

5. To configure the write-through policy, you can use the lvm.conf file. Add the following line to 
the "volume_groups" section of the file:

hybrid-storage {
# ... other configuration options here ...
cache = writethrough

@iFreilicht
Copy link
Contributor

iFreilicht commented Oct 7, 2024

Be more precise. (The original post just said "how" with no additional information)

@iFreilicht iFreilicht added the question Not a bug or issue, but a question asking for help or information label Oct 7, 2024
@xiro-codes
Copy link
Author

Simpler info i just want to do the stuff described here https://man.archlinux.org/man/lvmcache.7

@iFreilicht
Copy link
Contributor

iFreilicht commented Oct 14, 2024

First off, please do additional research on your own instead of just blindly trusting an LLM to make a good decision for you. Instead of using LVM and putting an ext4 filesystem on top of it, using ZFS or btrfs which implement caching directly might be the better option.

If you're sure that you want to use LVM for this, I'd say your best starting point is this example. Take a look at the lvm_pv and lvm_vg types to see what your options are. You might have to call lvconvert semi-manually by setting postCreateHook, we don't have a way to do this sort of thing yet, see #421

@iFreilicht iFreilicht changed the title configuring write-through policy Using two SSDs as cache for two HDDs with LVM Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Not a bug or issue, but a question asking for help or information
Projects
None yet
Development

No branches or pull requests

2 participants