Find the answer to your Linux question:
Results 1 to 2 of 2
I'm trying to mount /var, /tmp and /home into RAM at startup, and then copying their contents to a backup folder at shutdown. My fstab has lines like this: Code: ...
  1. #1
    Just Joined!
    Join Date
    Feb 2007
    Location
    Winnipeg, MB
    Posts
    14

    Mount /var /home and /tmp into RAM

    I'm trying to mount /var, /tmp and /home into RAM at startup, and then copying their contents to a backup folder at shutdown. My fstab has lines like this:

    Code:
    tmpfs           /tmp            tmpfs   defaults,noexec,nosuid 0 0
    tmpfs           /home/myrdos    tmpfs   defaults        0       0
    tmpfs           /var            tmpfs   defaults        0       0
    I made a script to copy their contents at startup and shutdown:

    Code:
    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides:          telebotram
    # Required-Start:    $local_fs
    # Required-Stop:     $local_fs
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: Telebot Ram Drive
    # Description:       Load /home and /tmp into RAM
    ### END INIT INFO
    
    # Carry out specific functions when asked to by the system
    case "$1" in
      start)
        echo "Started start_bot.sh"
    
        echo "Copying /home/myrdos_backup to RAM..."
        rsync -a /home/myrdos_backup/ /home/myrdos
    
        echo "Copying /var_backup to RAM..."
        rsync -a /var_backup/ /var
        #read -n 1 -s
        ;;
      stop)
        echo "Stopping script start_bot.sh"
        echo "Saving home/myrdos to home/myrdos_backup"
        rsync -a --delete /home/myrdos/ /home/myrdos_backup
    
        echo "Saving var to var_backup"
        rsync -a --delete /var/ /var_backup
        read -n 1 -s
        ;;
      *)
        echo "Usage: /etc/init.d/start_bot.sh {start|stop}"
        exit 1
        ;;
    esac
    
    exit 0
    My script is in /etc/init.d/start_bot.sh
    I run "sudo update-rc.d start_bot.sh defaults" to get it to run.

    However, the script is not being run at shutdown, which is my main problem. Also, I would like to copy stuff to the /var directory before anything else runs to avoid unexpected behaviour, and shut it down just before the drives are unmounted. I'm not sure if this is happening.

    Any help is appreciated!

  2. #2
    Just Joined!
    Join Date
    Feb 2007
    Location
    Winnipeg, MB
    Posts
    14
    Well, it looks like I've gotten a lot of views, but no one knows what the answer might be...

    I wonder, does Linux automatically do wear-leveling on flash drives? If so, this might be unnecessary. The file system is fat32.

Posting Permissions

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