Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: How to mount ramdisk upon startup

  1. #11
    Join Date
    Mar 2010
    Beans
    37

    Re: How to mount ramdisk upon startup

    K, but can you tell me how I can have the data moved into the ramdisk at boot, and taken out on shutdown?

  2. #12
    Join Date
    Jul 2010
    Location
    /run/shm
    Beans
    825
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: How to mount ramdisk upon startup

    Okay, to copy on the files on boot. You could set cron to auto copy the files on boot.
    Open a terminal and type the following
    Code:
    export EDITOR=nano
    crontab -e
    Now add this line
    Code:
    @reboot cp -rpf /home/user/temp /dev/shm
    (Correct me if I'm wrong but I think user crontabs work even when the user is not logged in)
    (@reboot works on boot as well, not just reboots)
    Now press Ctrl+O -> Enter -> Ctrl+X

    For the shutdown, this is a bit tricky and risky.
    As a AI known to some people would say:
    "Federal regulations require me to inform you that this next step is... looking pretty dangerous"
    So. This step is dangerous, might eat your cat, break your flowerpot, take all your money, point fingers at you and laugh.
    To minimize the risk we will edit a system file that is responsible for unattended upgrades.
    Type this
    Code:
    gksudo gedit /etc/rc0.d/S10unattended-upgrades
    Or if you really liked nano
    Code:
    sudo nano /etc/rc0.d/S10unattended-upgrades
    Add this line
    Code:
    cp -rpf /dev/shm/temp /home/user/
    right after the comments end (The ones with #) and the PATH, NAME and DESC lines. So it should look like this (Might be different since I'm on 11.04)
    PHP Code:
    #! /bin/sh
    #
    ### BEGIN INIT INFO
    # Required-Start:
    # Required-Stop:
    # Provides:          unattended-upgrade-shutdown-check
    # Default-Start:     
    # Default-Stop:      0 6
    # Short-Description: Check if unattended upgrades are being applied
    # Description:       Check if unattended upgrades are being applied
    #                    and wait for them to finish
    ### END INIT INFO


    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    NAME
    =unattended-upgrades
    DESC
    =unattended-upgrades

    cp 
    -rpf /dev/shm/temp /home/user/

    set -e

    case "$1" in
      start
    |stop)
            echo -
    "Checking for running $DESC: "
            
    python /usr/share/unattended-upgrades/unattended-upgrade-shutdown
            
    ;;
      
    restart|force-reload)
            
    # nothing
            
    ;;
      *)
        
    N=/etc/init.d/$NAME
        
    echo "Usage: $N {start|stop|restart|force-reload}" >&2
        
    exit 1
        
    ;;
    esac

    exit 
    Don't edit anything else. Save the file and now manually copy the temp folder to /dev/shm (Not contents, the folder)
    Last edited by Lisiano; September 22nd, 2011 at 08:25 PM.
    Quote Originally Posted by Linus Torvalds
    "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

  3. #13
    Join Date
    Aug 2009
    Location
    Under the stairs.
    Beans
    1,408
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How to mount ramdisk upon startup

    You would need to write a small copy/move script and place it in /etc/init.d/ directory and chmod +x to make it executable. I'm not sure where the reverse script would go for shutdown. I'm only guessing as that directory is the boot...
    Dell Inspiron 1764 Laptop, Intel CoreTM i5 520M), 4GB Shared Dual Channel DDR3 at 1066MHz, 512MB ATI Mobility RadeonTM HD4330 Integrated Intel HD.

  4. #14
    Join Date
    Jul 2010
    Location
    /run/shm
    Beans
    825
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: How to mount ramdisk upon startup

    Oh. Didn't notice about a init script, just add this at the beginning of the script instead of crontab
    Code:
    cp -rpf /home/user/temp /dev/shm
    Also you can just add this on the stop rule in the init script instead of editing /etc/rc0.d/S10unattended-upgrades
    Code:
    cp -rpf /dev/shm/temp /home/user/
    Last edited by Lisiano; September 22nd, 2011 at 08:31 PM.
    Quote Originally Posted by Linus Torvalds
    "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •