```shell
# 1. 安装 PostgreSQL 和 pgbench

sudo apt-get update
sudo apt-get install -y postgresql postgresql-contrib

# 2. 找到 postgresql.conf（Ubuntu 通常在这个目录）

ls /etc/postgresql/*/main/postgresql.conf

# 3. 配置禁用 mmap（编辑 postgresql.conf）

shared_memory_type = sysv
dynamic_shared_memory_type = sysv

# 4. 重启 PostgreSQL

sudo systemctl stop postgresql
rm -rf /home/lian/pg/pgdata
rm -rf /zvfs/pg_ts_bench

sudo chown -R postgres:postgres /home/lian/pg
sudo -u postgres mkdir -p /home/lian/pg/pgdata
sudo chown -R postgres:postgres /home/lian/pg/pgdata

sudo -u postgres env LD_PRELOAD=/home/lian/try/zvfs/src/libzvfs.so \
    /usr/lib/postgresql/12/bin/initdb -D /home/lian/pg/pgdata

cp  ./postgresql.conf /home/lian/pg/pgdata/

sudo -u postgres env LD_PRELOAD=/home/lian/try/zvfs/src/libzvfs.so \
    /usr/lib/postgresql/12/bin/pg_ctl -D /home/lian/pg/pgdata -l /tmp/pg.log start

sudo -u postgres env LD_PRELOAD=/home/lian/try/zvfs/src/libzvfs.so \
    /usr/lib/postgresql/12/bin/psql 

sudo -u postgres env LD_PRELOAD=/home/lian/try/zvfs/src/libzvfs.so \
    /usr/lib/postgresql/12/bin/pg_ctl -D /home/lian/pg/pgdata -l /tmp/pg.log restart

# 创建测试环境
sudo -u postgres mkdir -p /zvfs/pg_ts_bench
sudo chown -R postgres:postgres /zvfs/pg_ts_bench
sudo chmod 700 /zvfs/pg_ts_bench

CREATE TABLESPACE zvfs_ts LOCATION '/zvfs/pg_ts_bench';
DROP DATABASE IF EXISTS benchdb;
CREATE DATABASE benchdb TABLESPACE zvfs_ts;

DROP TABLE IF EXISTS hook_probe;
CREATE TABLE hook_probe(id int) TABLESPACE zvfs_ts;
INSERT INTO hook_probe VALUES (1);
INSERT INTO hook_probe VALUES (2);
INSERT INTO hook_probe VALUES (3);
INSERT INTO hook_probe VALUES (4);
SELECT * FROM hook_probe;
DELETE FROM hook_probe WHERE id = 1;
UPDATE hook_probe SET id = 11 WHERE id = 2;
SELECT * FROM hook_probe;


# 5. 验证配置生效
pid=$(pgrep -u postgres -xo postgres) 
echo "pid=$pid"
sudo grep libzvfs /proc/$pid/maps

sudo -u postgres psql -p 5432 -c "show data_directory;"
sudo -u postgres psql -c "SHOW shared_memory_type;"
sudo -u postgres psql -c "SHOW dynamic_shared_memory_type;"

# 6. 创建测试库（如未创建）

sudo -u postgres createdb benchdb

# 7. 运行你的 bench 脚本

bash /home/lian/try/zvfs/scripts/run_pgbench_no_mmap.sh
```