Skip to content

Commit

Permalink
Merge pull request #68 from matteotenca/cache_mode
Browse files Browse the repository at this point in the history
Small update to initrd scripts to support writeback mode
  • Loading branch information
pkoutoupis authored Dec 12, 2021
2 parents 3a44e02 + 2bf6e15 commit d5b9ee3
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 91 deletions.
13 changes: 13 additions & 0 deletions misc/rapiddisk-rootdev/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

### Version 0.1.0

Released 2021-12-12

* Added --cache-mode parameter
* Added sanity checks in Ubuntu initrd scripts
* Added many debug messages in Ubuntu initrd scripts
* Added a workaround to Ubuntu boot script in case the first ramdisk can't be attached
* Now initrd scripts are placed in /usr dir under Ubuntu
* The dm-writecache module is added to the initrd file only when needed under Ubuntu
* Fixed Centos script to report dependencies correctly
20 changes: 15 additions & 5 deletions misc/rapiddisk-rootdev/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## install_initrd.sh
#### A simple bash script to add rapiddisk cache to your root volume

###### Author: Matteo Tenca (<[email protected]>)
###### Author: Matteo Tenca (<https://github.com/matteotenca/>)

Warning: this is experimental - use at your own risk and only if you
know what you're doing.
Expand Down Expand Up @@ -43,7 +43,8 @@ This script alters this approach: the rule set remains system-wide, but allows t
### 1) Usage when installing (`--install`)
```
sudo ./install_initrd.sh --install --root=<root_partition>
--size=<ramdisk_size> --kernel=<kernel_version> [--force]
--size=<ramdisk_size> --kernel=<kernel_version>
--cache-mode=<mode> [--force]
```

The installation process (`--install` switch) can be performed several times. The options you provide will affect only
Expand All @@ -55,7 +56,7 @@ The installation process (`--install` switch) can be performed several times. Th


#### --root=<root_partition>
<root_partition> must be be equal to the root device where `/` is
<root_partition> must be equal to the root device where `/` is
mounted, for example `/dev/sda1`. You can find it this way:

```
Expand All @@ -76,6 +77,11 @@ proposal.
<ramdisk_size> indicates the number of megabyte rapiddisk will use as
cache for your root device. For example `--size=1000` means your cache will be 1 GB big.

#### --cache-mode=<cache_mode>

<cache_mode> indicates the caching behavoiur, must be `wt`, `wa` or `wb`.
See `rapiddisk`'s documentation for more.

#### --kernel=<kernel_version>

Instructs the script about which initrd file to update. On many linux
Expand All @@ -101,7 +107,7 @@ And go.
#### --force

This forces the script to reinstall the needed things and redo the jobs,
even if all seems to be already installed. If you force the reinstall
even if all seems to be already installed. If you force the reinstallation
with a different `--root`, only the last one you specified will be
cached.

Expand Down Expand Up @@ -135,7 +141,11 @@ sudo ./install_initrd.sh --global-uninstall
```

This operation removes everything the script could have installed, and rebuilds ALL the initrd files. A complete
uninstall is performed.
uninstallation is performed.

## Notes

* Under Centos 8, using xfs as the root filesystem, rapiddisk may not work if write-back mode is selected.

## Tips

Expand Down
16 changes: 9 additions & 7 deletions misc/rapiddisk-rootdev/centos/96rapiddisk/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,39 @@ check() {
for i in $moddir/*
do
if [ "${moddir}/${kernel}" = "$i" ] ; then
size="$(cat "$i" | head -n 1)"
device="$(cat "$i" | tail -n 1)"
size="$(head -n 1 "$i")"
device="$(head -n 2 "$i" | tail -n 1)"
cache_mode="$(tail -n 1 "$i")"
cp -f "$moddir/run_rapiddisk.sh.orig" "$moddir/run_rapiddisk.sh"
sed -i 's,RAMDISKSIZE,'$size',' "$moddir/run_rapiddisk.sh"
sed -i 's,BOOTDEVICE,'$device',' "$moddir/run_rapiddisk.sh"
sed -i 's,RAMDISKSIZE,'"$size"',g' "$moddir/run_rapiddisk.sh"
sed -i 's,BOOTDEVICE,'"$device"',g' "$moddir/run_rapiddisk.sh"
sed -i 's,CACHEMODE,'"$cache_mode"',g' "$moddir/run_rapiddisk.sh"
chmod +x "$moddir/run_rapiddisk.sh"
return 0
fi
done

return 255

}

depends() {

echo dm
return 0

}

installkernel() {

hostonly='' instmods rapiddisk rapiddisk-cache
hostonly='' instmods rapiddisk rapiddisk-cache dm-writecache dm-mod
return 0

}

install() {

inst /sbin/rapiddisk
inst_hook pre-mount 00 "$moddir/run_rapiddisk.sh"
inst_hook pre-mount 50 "$moddir/run_rapiddisk.sh"
inst "$moddir/run_rapiddisk.sh" "/sbin/run_rapiddisk.sh"
rm -f "$moddir/run_rapiddisk.sh"
return 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash

modprobe rapiddisk
modprobe rapiddisk-cache
modprobe -q dm-mod
modprobe -q dm-writecache
modprobe -q rapiddisk
modprobe -q rapiddisk-cache

rapiddisk -a RAMDISKSIZE
rapiddisk -m rd0 -b BOOTDEVICE -p wa
rapiddisk -m rd0 -b BOOTDEVICE -p CACHEMODE
Loading

0 comments on commit d5b9ee3

Please sign in to comment.