Menu

Linux Kalıcı ramdisk tmpfs nasıl oluşturulur?

mkdir /mnt/ramfs_postgres
mkdir /mnt/ramfs_postgres_bck

mount -t tmpfs -o rw,size=20G tmpfs /mnt/ramfs_postgres

echo "tmpfs /mnt/ramfs_postgres tmpfs rw,size=20G 0 0" >> /etc/fstab


cat < /lib/systemd/system/ramfs_postgres.service
[Unit]
Before=umount.target
[Service]
Type=oneshot
User=root
ExecStartPre=/bin/chown -Rf root /mnt/ramfs_postgres/
ExecStart=/usr/bin/rsync -ar /mnt/ramfs_postgres_bck/ /mnt/ramfs_postgres/
ExecStop=/usr/bin/rsync -ar /mnt/ramfs_postgres/ /mnt/ramfs_postgres_bck/
ExecStopPost=/bin/chown -Rf root /mnt/ramfs_postgres_bck/
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
EOT


systemctl enable ramfs_postgres
systemctl restart ramfs_postgres
systemctl status ramfs_postgres


#ls /mnt/ramfs_postgres{,_bck}





#########################
#systemctl disable ramfs_postgres
#rm /lib/systemd/system/ramfs_postgres.service
#systemctl daemon-reload
#umount /mnt/ramfs_postgres
#rm -rf /mnt/ramfs_postgres
#rm -rf /mnt/ramfs_postgres_bck
#sed -i '/ramfs_postgres/d' /etc/fstab
ramfs_postgres_bck

Faydalı Olması Dileği İle

SunucuPARK Destek