PFSense Adding Second Harddirve for /Cache directory

Discussion in 'PFsense M0n0wall IPcop & others PC based routers' started by Deeza, May 24, 2011.


  1. Deeza

    Deeza staff Staff Member




    adding second harddrive (ide/sata/etch.) to pfsense v.1.2.3 is very quick and easy :)

    purpose to doing this, is that squid can cache files to it's own drive.
    for my example:

    1.) I have now two SATA Drive 80GB for my system file and 500GB for my cache directory in my pfsensebox.
    First power off (of course) and install second drive to computer. (check the hdd jumpers on both drives if you are using ide, and ide cables are right.) Computer bios *must* identify both drives ok, before continue.

    2.) Power on computer. Connect to the PFSense from console.
    This is the hardest and trickiest part:
    Now you must format and slice the new drive, using fdisk, and newfs.

    *Good how-to is:
    http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/disks-adding.html
    or google how to take new harddisk to use in Freebsd.

    Take the copy of original fstab file "cp /etc/fstab /etc/fstab.backup" in case that something goes wrong.

    then edit the file /etc/fstab using vi.
    quick usage: edit the file, press esc, and type "w!" +enter, now your changes are saved.

    Here is mine:
    # cat /etc/fstab
    # Device Mountpoint FStype Options Dump Pass#
    /dev/ad4s1a / ufs rw 1 1
    /dev/ad4s1b none swap sw 0 0
    /dev/ad6s1 /cache ufs rw 1 1
    #

    as you can see, I've added the last line to fstab, and I'm using just one slice (partition) ad6. Now my cachedrive is /dev/ad6 and it is mounted to /cache

    ad6 comes from atadrive (ad/sata) / slavedisk (1).
    Masterdisk is ad4s?

    type:
    #mount -a

    when everything is doing right now, you should see:
    # df -h
    Filesystem Size Used Avail Capacity Mounted on
    /dev/ad4s1a 68G 1.9G 61G 3% /
    devfs 1.0K 1.0K 0B 100% /dev
    /dev/md0 3.6M 30K 3.3M 1% /var/run
    /dev/ad6s1 451G 20G 395G 5% /cache
    devfs 1.0K 1.0K 0B 100% /var/dhcpd/dev
    #

    ...or whatever your disks are.

    check
    #ls /cache

    Now, time to edit squid, go to webconfigurator, and go to squid tab. (services/proxy server/cache management) !!At this point you should have package "squid" added to PFSense.
    Edit the line "Hard disk cache location" and type /cache
    and "Hard disk cache size" to what ever you want, mine is 90000 (90GB of 500GB disk)
    Also edit and modify other setting you like.

    Now you should have working squid cache in it's own drive.

    You must also delete /var/squid/cache/*
    and restart squid to take effect new configuration.
    I'm sure I missing something here...but these instructions mainly are, how I got working second drive.

    You can monitor your cache size with command
    #du -h /cache
    or
    #df -h
     
    Darkanyons and christianhwnd like this.
  2. sa-joedy

    sa-joedy Member




    ^ thanks for this. napagana ko. nag add ako ng 1TB para sa cache

    :( kaya lang pag improper shutdown nag i-scan ang drive bago nya i-mount it takes 2~3 mins ang scan.
    pa fix naman idol. hehehe
     
  3. Deeza

    Deeza staff Staff Member




    ^:mad: 500GB na yung Masterdisk mo diba "sayang" sobra laki nyan para sa system files. ahh i-separate mo yung cache yung 1TB SATA para sa cache drive lang?

    OK, looking into this for now.
     
  4. Deeza

    Deeza staff Staff Member




    for some kind of fail over or improper shutdown other drive need to be scanned and mount.
    If cache0 is the cache_dir /cache0
    you need to edit the squid.sh (kung wala sa folder na to mag create ka /usr/local/sbin) gamit ka ng winscp.
    before doing that back-up mo muna yung file bago ang lahat baka magkamali.

    Code:
    #!/bin/sh
    # This file was automatically generated
    # by the pfSense service handler.
    rc_start() {
    if [ -z "`ps auxw | grep "[s]quid -D"|awk '{print $2}'`" ];then
            if [ ! -d "/cache0/00" ];then
                    if [ -z "`ps auxw | grep "fsck_ufs -y /cache0"`" ];then
                    fsck -y /cache0
                    fi
            mount -a
            fi
            /usr/local/sbin/squid -D
    fi
    
    }
    
    rc_stop() {
            /usr/local/sbin/squid -k shutdown
    # Just to be sure...
    sleep 5
    killall -9 squid 2>/dev/null
    killall pinger 2>/dev/null
    
    }
    
    case $1 in
            start)
                    rc_start
                    ;;
            stop)
                    rc_stop
                    ;;
            restart)
                    rc_stop
                    rc_start
                    ;;
    esac
    
    eto ss kung pano mag create ng new file using winscp.
    save as squid.sh and place into that folder /usr/local/sbin

    [​IMG]

    @sa-joedy
    post mo dito kung ano nangyari after reboot mo ng system.
     
  5. sa-joedy

    sa-joedy Member




    ^ nice good work.. :)

    hindi na nag i-scan mount agad yung second hardrive ko maski hindi na proper shutdown.

    thanks!
     
  6. oniemusha

    oniemusha Member




    another project i am looking forward to do. lakas ng hatak ng project ni chief deeza sa akin ah!
     
  7. Deeza

    Deeza staff Staff Member




    ^^ thanks

    hindi kasi ako kontento sa mga router(s) na nabibili lang dyan sa labas (plug n play. isalpak mo lang at konting configuration tatakbo na.). at-least dito marami ka matutunan fire-walling/ caching/ video-caching/ bandwidth throttling / ipcop/pfsense (wifi-access point) etch. etch..

    ipcop = linux
    pfsense = bsd/unix
     
  8. oniemusha

    oniemusha Member




    kaya nakahatak ka ng fans eh! :) chief, i still have some problems with my ipcop!
     
  9. Deeza

    Deeza staff Staff Member




    ^ ano po yun sir.

    pwede ba natin malaman heheh, baka may maitulong.
     
  10. oniemusha

    oniemusha Member




    still the same chief. am currently using ipcop. i followed ipcop with update accelerator with advance proxy add-on. change updatexlrator file (not the cgi). i deleted windows update and insert mbam code (as per your file). if i am using ipcop with update accelerator, i cannot connect to the internet. no update currently downloading. if i disable it, connection to the web is good. i even reinstalled it and tested again but unfortunately ganoon pa rin. hope you can help me. am currently testing it before ko ipasok sa shop.
     
  11. Deeza

    Deeza staff Staff Member




    ^ can you show me some screen shots of your advanced proxy and update accelerator addon

    here is my modified-file pwede mo gawin basehan
    you can download it here:

    updxlrator http://www.mediafire.com/?cj26cy3xz41pfw2
    updatexlrator.cgi http://www.mediafire.com/?ounrl4g27gdnwxd

    custom logo:
    avira http://www.mediafire.com/?2wkvwgut515hb69
    mbam http://www.mediafire.com/?832annhd1crpzyg
    cross fire http://www.mediafire.com/?9tuq44doqsl1ewa
    special force http://www.mediafire.com/?ahz099gnj88sazz

    *note tested iyan sa shop ni sa-joedy

    EDIT:
    teka pwede mo gamitin yan. :)
     
  12. oniemusha

    oniemusha Member




    chief, idol, amo :) salamat sa help mo ha. try ko ulit i-reinstall muna and tried once more with your modified file. baka somewhere in between the installation nagka problem ako. i'll be back.
     
  13. Deeza

    Deeza staff Staff Member




    ^ hindi ko ma post yung code dito masyado kasi mahaba. iyan ang mga link i-donload mo na lang working lahat yan.
    kindly post your advanced proxy and update accelerator screen shots.

    thanks.
     
  14. Deeza

    Deeza staff Staff Member




    ahahah wag naman...

    brod na lang.;)
     
  15. oniemusha

    oniemusha Member




    brod deeza :) eto na po yung screenshot ng ipcop ko. di ko na install yung advance proxy kasi di naman necessary sa update accelerator. fresh install pa po eto. wala pa rin ako change sa updatexlrator files. test ko muna then screenshots ko ulit pag nag error na. thanks ulit sir!
     

    Attached Files:

  16. Deeza

    Deeza staff Staff Member




    ^^ brod dito ka mag download ng addons stable
    http://www.advproxy.net/
    check mo young news:

    advanced proxy
    update accelerator
    url filter

    ok, try mo.
    pag hindi nag work update your proxy to advanced proxy 3.0.6
     
  17. oniemusha

    oniemusha Member




    thanks, chief deeza! dyan ko po din nadownload yung advanced proxy. di ko po natry isama yung url filter. needed ba? balak ko lang kasi sa updates gamitin and proxy syempre. other than that kasi, nasa opendns naka-filter na yung websites na bawal. so far, good pa naman yung evaluation. i'll update once ok na. thanks ulit!
     
  18. oniemusha

    oniemusha Member




    chief deeza! thanks, thanks! wala na problem! dagdag q na sa testing yung iba pa. thanks ulit!
     
  19. Deeza

    Deeza staff Staff Member




    ^^ nice sir..
    good to know working na.
    :)
     
  20. Deeza

    Deeza staff Staff Member




    ^^ ok yan sir pero sakin eto gamit ko.

    Google DNS
    8.8.8.8
    8.8.4.4

    tapos install na lang ako ng URL filter addon using Shalla Secure Service blacklist
    mas matindi kasi ang pang block nyan maski mga ilocano/tagalog na url ng porn block nyan agad. i.e iyottube ;)
     
                                 

Share This Page