Log in or sign up


USER:
PASS:

 
 
Forums
BluFudge :: Forums :: Tutorials and Guides :: Other Tutorials and Guides
 
<< Previous thread | Next thread >>
How to add a BigBrother to your FreeNAS with chroot
Moderators: SETone, Fudge, Demented
Author Post
bubulein
Sat Mar 13 2010, 08:19am
Registered Member #114
Joined: Tue Feb 09 2010, 03:34am
Your location: Germany
Posts: 9
FreeNAS get's an BigBrother
bubulein@mail.com
primary location: http://www.blufudge.net


How to add a BigBrother to your FreeNAS with chroot

What is FreeNAS ...

FreeNAS is a free network-attached storage server, supporting: CIFS (Samba), FTP, NFS, rsync, AFP protocols, iSCSI, S.M.A.R.T., local user authentication, and software RAID (0,1,5), with a web-based configuration interface. FreeNAS takes less than 64 MB once installed on CompactFlash, hard drive or USB flash drive.[1] FreeNAS is currently distributed as an ISO image and in source form. It is possible to run FreeNAS from a Live CD, with the configuration files stored on an MS-DOS-formatted floppy disk or USB thumb drive.

source: http://en.wikipedia.org/wiki/Freenas

Homepage: http://www.freenas.org


Tested on


Version 0.7.1 Shere (revision 4997)
Built on Mon Jan 25 18:54:44 UTC 2010
OS Version FreeBSD 7.2-RELEASE-p6 (revision 199506)
Platform amd64-embedded on Intel(R) Atom(TM) CPU 330 @ 1.60GHz

Disk Layout



/dev/ad8p1 /mnt/home
ufs HOME
Home
read  write

/dev/ad12.elip1 /mnt/media
ufs / AES 128 encrypted
MEDIA
Audio, Video, Pictures
read only

/dev/ad13.elip1 /mnt/chroot
ufs / AES 128 encrypted
BigBrother
chroot - Home of the BigBrother
read write

/dev/da1.elip1 /mnt/BACKUP001
ufs / AES 128 encrypted
BACKUP001
externel USB-Backupdrive
read write


Setting up the chroot

Definition: chroot (jail): A UNIX feature that creates a limited sandbox allowing a process to view only a single subtree of the filesystem. The jail call in BSD is a more advanced version for creating the same sort of sandbox. Point: In order for it to work properly, some common programs and libraries (e.g. /bin/ sh, /usr/lib/libc.so.1, ...) need to be copied/linked to the appropriate locations in the new directory tree. Key point: A process running with root access can break out of a chrooted environment. Therefore, it should be used in conjunction with setuid.


dont know where i have stolen the definition ;)



copy & paste only if u know what you are doing


#!/bin/sh
# choose a directory to download the FreeBSD 7.2 ISO. If you are running i386 just replace amd64 with i386.

cd /mnt/home
fetch ftp:/ftp.freebsd.org/pub/FreeBSD/ISO-IMAGES-amd64/7.2/7.2-RELEASE-amd64-disc1.iso

# now we need to mount the downloaded ISO ( via WebUI or command line)

mkdir /mnt/7.2-Release
mdconfig -a -t vnode -f /mnt/home/7.2-RELEASE-amd64-disc1.iso -u 2
mount -t cd9660 /dev/md2 /mnt/7.2-Release/

# now we install our chroot

cd /mnt/7.2-Release/7.2-RELEASE/base/
cat base.?? | tar --unlink -xpzf - -C /mnt/chroot/

# now we change to our chroot dir and take at look what we have done


cd /mnt/chroot/
ls -la

# now we take a look how much space we use, not necesarry, but interesting

du -hc ./

#  152 mb total. later we clean up
#
# Now we need to mount /dev and /proc to get a working chroot

mount_nullfs /dev/ /mnt/chroot/dev/
mount_nullfs /proc/ /mnt/chroot/proc/

# copy your network settings from FreeNAS into the chroot

cp /etc/hosts /etc/resolv.conf /mnt/chroot/etc/

# now we have a simple FreeBSD running
# time to enter our chroot the first time

chroot /mnt/chroot
pwd

# now we see just a / , and we are inside our jail.

uname -a

# uname -a shows you that you still using the FreeNAS kernel,
# also you do not need more Memory or CPU resources ( ok, chroot need less then 1%)
#
# to exit the chroot just type

exit

Currently we do not have made any perisist changes to our FreeNAS installtion.
If your reboot your system /dev /proc are unmounted. And our chroot enviroment is just a directory on our FreeNAS.
If you never used freebsd before, this is the right moment to play around withit. Inside the jail you can do everything you whantwithout affecting your FreeNAS installation.
Also your stored data are uneffected by the chroot.
Even a "rm -rf /" wouldn't effect your FreeNAS.To make all your changes perisistent, do following.

Add

mount_nullfs /dev/ /mnt/chroot/dev/ && mount_nullfs /proc/ /mnt/chroot/proc/
to your FreeNAS configuration:

WebUI >  System > Advanced > Command scripts

Type "PostInit"


And now?

Well, now its time to get an overview about FreeBSD. A good starting point is the FreeBSD Handbook available in many languages.

FreeBSD Handbbok <> http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/

But, wait, lets play around with the chroot. Now we enter the chrootand download and "install" the hanbook and the manual pages.
First a good hint. If  you have questions feel free to emailme,  and if you use a forum or ask on the irc point them to the FreeNAShomepage and the origin location of this tutorial cause a chroot isntthe same like an full installed FreeBSD, do that just to avoid beeingmissunderstood.


Installing the Handbook and Manualpages
There are many ways to do this. If you never had direct contact toFreeBSD a good start is the "sysinstall" util. Its used to installFreeBSD and do changes,
Btw, keep in mind

THIS CHROOT ISN'T A DESKTOP, IT IS A SERVER

If you enter the sysinstall util now, perhaps its a goodidea that you read the dokumentation of an application before youinstall it. It dont make sense to setup a X-Desktop enviroment onyour  FreeNAS, but it isnt impossible.

Ok, i know, i talk too much let's enter the chroot and install the Handbook and Manualpages.


chroot /mnt/chroot
sysinstall

#
#
# The sysinstall tool is a simple, but powerfull tool. Watch your steps
#
# First i just whant you point to the steps to get the Dokumentation
#
#
# Go to

  • Configure
    • Options
      • move to Release Name
        • change 7.2-Release-p6 , select with SPACE
          • to 7.2-Release, cause -p6 is the patchlevel ( like updates)
            • If you dont change this "sysinstall"
            • cant find the download location on the serverpress ENTER, and ESC to leave the Menu
    • Media
      • Choose your installation Media. I suggest
      • FTP
      • Choose a Mirror next to you
    • Configure Network
      • Should be done during setup of the chroot ( FreeNAS  networksettings)
  •  Now you are on the Menue again
    • go to Distribution
      • doc
      • man
      • jump with TAB to OK and press ENTERNow sysinstall should download and extract the requested files
 
Ok, now you have the basic documentaion and the manualpages.
You can find the Handbook under


/usr/local/share/doc/freebsd/handbook

To find out how to use the manualpages just type


man man

#
# i suggest

man hier

# to see where you can find which files



I whant to expand this document every 2 days, so feel free to come back.

Question and commnts to the forum or  at the irc-net server: irc.blufudge.net channel #holodeck

yours,

bubulein©mail.com




[ Edited Sat Mar 13 2010, 08:33am ]
Back to top
 

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System