[HOWTO] Create a persistent xbmc ramdisk in ubuntu (xbmclive)
#1
EDIT: WARNING The sync method is not safe. Not sure how the creator made it work with /var.
The problem is that xbmc will start loading before the sync is ready if you have more than a small library.
I am sure this is the problem because if I put a delay in runXBMC it works.
Changing to sudo update-rc.d xbmcramdisk.sh defaults 00 99 helps but not enough.

I will keep the setup for now but the only way to make it work better is to lock the xbmc loading until sync is ready.

I can see two possible solution:
1) Load the ram disk from the runXBMC script. This will work perfect but an upgrade could ruin your system you need to make sure to have a backup of the .disk.
2) have the ramdisk script remote runXBMC from rc and start and stop xbmc from the ramdisk script instead.
Not sure of the exact consequences of this.

It would be nice if runXBMC supported "run before" and "run after" scripts.


----------------------
I have a performance isse with my htpc due to heavy non-xbmc load and I though I would give ram disk ago.
Can't say that I am very impressed so far. Perhaps I have to move the skin to get a better result.


This is how I did it.
WARNING!! Make a system backup before you try this and you do it on your own risk of course.

Quote:A note about RAMDISK
(http://www.cyberciti.biz/faq/howto-creat...filesystem)
tmpfs is supported by the Linux kernel from version 2.4+.
tmpfs (also known as shmfs) is a little different from the Linux ramdisk.
It allocate memory dynamically and by allowing less-used pages to be moved onto swap space.
ramfs, in contrast, does not make use of swap which can be an advantage or disadvantage in many cases.
See how to use tmpfs under Linux.

We assume
user = xbmc

1) Create Ram disk.
This skip could be skipped. Ubuntu and Debian mounts a dynamic ramdisk into /dev/shm/ by default.
I prefer a dedicated space with a max space set.

Code:
sudo mkdir /dev/xbmcramdisk

Code:
sudo nano /etc/fstab
add
Code:
###XBMC RAMDISK
none    /dev/xbmcramdisk    tmpfs    defaults,size=700m    0    0

We could use ramfs instead to ensure it is not swapped.

Mount and set permissions
Code:
sudo mount -a
sudo chown -R xbmc:xbmc /dev/xbmcramdisk
sudo chmod -R 755 /dev/xbmcramdisk

2) Make the ramdisk persistant

http://forum.xbmc.org/showpost.php?p=374567&postcount=8
gkornato
http://famvdploeg.com/blog/2008/03/putting-var-in-ram/
Wytze

Code:
mkdir /home/xbmc/.xbmcramdisk.disk
sudo nano /etc/init.d/xbmcramdisk.sh
add:
Code:
#! /bin/sh
# /etc/init.d/xbmcramdisk.sh
#

case "$1" in
  start)
    echo "Copying files to xbmcRamdisk"
    rsync -av /home/xbmc/.xbmcramdisk.disk/ /dev/xbmcramdisk/
    #echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched from HD >> /var/log/xbmcramdisk_sync.log
    ;;
  sync)
    echo "Synching files from xbmcRamdisk to Harddisk"
    #echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched to HD >> /var/log/xbmcramdisk_sync.log
    rsync -av --delete --recursive --force /dev/xbmcramdisk/ /home/xbmc/.xbmcramdisk.disk/
    ;;
  stop)
    echo "Synching logfiles from xbmcRamdisk to Harddisk"
    #echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched to HD >> /var/log/xbmcramdisk_sync.log
    rsync -av --delete --recursive --force /dev/xbmcramdisk/ /home/xbmc/.xbmcramdisk.disk/
    ;;
  *)
    echo "Usage: /etc/init.d/xbmcramdisk.sh {start|stop|sync}"
    exit 1
    ;;
esac

exit 0


Code:
sudo chmod +x /etc/init.d/xbmcramdisk.sh
test
Code:
sudo /etc/init.d/xbmcramdisk.sh sync

add to rc
Code:
sudo update-rc.d xbmcramdisk.sh defaults 00 99


Now everything you add to /dev/xbmcramdisk should be back after a reboot!
I am not good with cron but could be a good idea to sync it every 5min or something.

3)
Move .xbmc/userdata to ramdisk
I wanted to move all of .xbmc but the skins takes 760M x2 including the zip files in packages.

Code:
sudo service xbmc-live stop

copy .xbmc/userdata to ram
mkdir /dev/xbmcramdisk/.xbmc
cp -a /home/xbmc/.xbmc/userdata /dev/xbmcramdisk/.xbmc

mv /home/xbmc/.xbmc/userdata /home/xbmc/.xbmc/userdata_org

ln -s /dev/xbmcramdisk/.xbmc/userdata /home/xbmc/.xbmc/userdata

sudo /etc/init.d/xbmcramdisk.sh sync

sudo service xbmc-live start



9) Bonus
Mount /tmp in ram
Not sure how much it does for performance but it reduces tear if you are running on flash disk.

Code:
sudo nano /etc/fstab
add
Code:
##/tmp RAMDISK##
none /tmp tmpfs defaults 0 0
Reply
#2
The sync method is not safe. Not sure how the creator made it work with /var.
The problem is that xbmc will start loading before the sync is ready if you have more than a small library.
I am sure this is the problem because if I put a delay in runXBMC it works.
Changing to sudo update-rc.d xbmcramdisk.sh defaults 00 99 also helps but not enough.
I will keep the setup for now but the only way to make it work better is to lock the xbmc loading until sync is ready.
I have no clue if the is possible with rc or a hack in runXBMC is needed.

EDIT: OK, the quick fix is of course to start xbmc from the sync .sh or the other way around. Doesnt feel good though.
Reply

Logout Mark Read Team Forum Stats Members Help
[HOWTO] Create a persistent xbmc ramdisk in ubuntu (xbmclive)0