Aici veti gasi detalii tehnice despre cum se pot realiza configurari software+ hardware.
Here you can find tehnical details about software/hardware configuration.

miercuri, 23 iulie 2008

FreeBSD Raid 1

Configuring the Mirror/Duplex During the Install



If you're going to use RAID 1, make your life easy and purchase two identical disks (of the same model and size). You can complicate things by insisting on different disks with different sizes, but in the end you just end up with a harder configuration that wastes the extra disk space on the larger disk. Cable the identical drives so that one is the primary master and the other is the secondary master. Before installing the operating system, double-check that your CMOS recognizes both disks.



Using your favorite installation method, start a FreeBSD install of any version (5.3 or higher). When you get to the Select Drives menu, it should show ad0 and ad2. Select ad0, as you will be installing the operating system on the primary master.



Within the fdisk utility, remove any existing partitions and then select "Use entire disk." When asked about the boot menu, choose "Standard MBR."



In the disklabel editor, set up the partitions on ad0 according to your requirements. If in doubt, choose a for automatic. Then choose your install sets and your install media, and let the operating system install as usual.



When finished, go through the postinstall configurations and set your time zone, create a user account, set the root password, and so on.



However, don't reboot when you end up back at the sysinstall main menu. Instead, press Alt-F4, which will take you to a command prompt. The first command I type is csh so I can get a shell with history (the default shell is Bourne).



Creating a mirror/duplex is as simple as typing:



# gmirror label -v -b round-robin gm0 /dev/ad0


where gmirror label creates the mirror; -v enables verbose mode; -b round-robin chooses a balance algorithm (at the moment, round-robin is the algorithm with the best performance); gm0 is the name of mirror/duplex (this name represents the first GEOM mirror); and /dev/ad0 represents the disk containing the data to mirror.



However, you'll be disappointed if you try the command now:



# gmirror label -v -b round-robin gm0 /dev/ad0
Can't store metadata on /dev/ad0: Operation not permitted


This is a security feature that indicates that the disk is currently mounted for writing and therefore is unavailable. However, you can get around this chicken-and-egg problem and temporarily force gmirror to bypass this measure in order to create the mirror/duplex by setting a sysctl MIB:



# sysctl kern.geom.debugflags=16
kern.geom.debugflags: 0 -> 16


Don't worry; this MIB will return to 0 when you reboot (which I'll have you do in just a few minutes). Try again:



# gmirror label -v -b round-robin gm0 /dev/ad0
Metadata value stored on /dev/ad0


That's it; you now have a RAID 1 system.



It is, however, useful to tell the operating system to load it whenever you boot. This requires edits to two files. The first one is currently empty, so just echo over the required line:



# echo geom_mirror_load="YES" > /boot/loader.conf


However, /etc/fstab is not empty, so I recommend making a backup copy before editing it:



# cp /etc/fstab /etc/fstab.orig
# vi /etc/fstab


Change each ad to a gm, and insert a mirror after /dev. For example, /dev/ad0s1a becomes /dev/mirror/gm0s1a. Unless you've made extra partitions, you'll have ad0s1 devices ending in a, b, d, e, and f and will need to edit each of those lines.



When finished, triple-check your changes to both /etc/fstab and /boot/loader.conf. While it is fixable, it sucks not being able to boot into a new system because of a typo.



Note: some tutorials indicate you also need to add a swapoff option to /etc/rc.conf. This is no longer necessary, and neither is using shutdown -r now instead of reboot.



Once you're sure you don't have any typos, return to Alt-F1 and exit the installation menu after removing your installation media.




Pages: 1, 2



Next Pagearrow



Booting into the Mirror/Duplex



If you watch your boot-up messages, you should see this in bold white text right after the disks are probed:

















GEOM_MIRROR: Device gm0 created (id=2125638583).
GEOM_MIRROR: Device gm0: provider ad0 detected.
GEOM_MIRROR: Device gm0: provider ad0 activated.
GEOM_MIRROR: Device gm0: provider mirror/gm0 launched.
GEOM_MIRROR: Device gm0 already configured.
Mounting root from ufs:/dev/mirror/gm0s1a


and the system will continue to boot. However, if you have a typo in /etc/fstab, the boot will stop at this point and wait for you to type something meaningful. In this example, I forgot to insert mirror when I edited /etc/fstab, meaning /dev/gm0s1a should have been /dev/mirror/gm0s1a so that FreeBSD could find my root filesystem:



Mounting root from ufs:/dev/gm0s1a
setrootbyname failed
ffs_mountroot: can't find rootvp
Root mount failed: 6

Manual root filesystem specification:
<fstype>:<device> Mount <device> using filesystem <fstype>
e.g. ufs:da0s1a
? List valid disk boot devices
<empty line> Abort manual input

mountroot>


Fortunately, that's not as scary as it looks. Start by listing your valid disk boot devices:



mountroot> ?

List of GEOM managed disk devices:
mirror/gm0s1f mirror/gm0s1e mirror/gm0s1d mirror/gm0s1c mirror/gm0s1b
mirror/gm0s1a mirror/gm0s1 ad2s1 mirror/gm0 ad0s1 ad2 acd0 ad0 fd0


If you type in the correct location of the / filesystem, the system will continue to reboot:








mountroot> ufs:/dev/mirror/gm0s1a
Mounting root from /dev/mirror/gm0s1a


After logging in, be sure to edit the offending line in /etc/fstab and try rebooting again. When you can boot up and log in successfully, verify that each partition on the mirror mounted successfully with:



% df -h

Filesystem Size Used Avail Capacity Mounted on
/dev/mirror/gm0s1a 248M 35M 193M 15% /
devfs 1.0K 1.0K 0B 100% /dev
/dev/mirror/gm0s1e 248M 12K 228M 0% /tmp
/dev/mirror/gm0s1f 7.3G 99M 6.7G 1% /usr
/dev/mirror/gm0s1d 248M 196K 228M 0% /var


df won't show your swap partition; you can verify it with:



% swapinfo
Device 1K-blocks Used Avail Capacity
/dev/mirror/gm0s1b 629544 0 629544 0%


Synchronizing the Mirror/Duplex



The only thing left to do is to synchronize the data on both hard drives. This will happen automatically as soon as you issue the command to insert the second drive into the mirror:



# gmirror insert gm0 /dev/ad2
GEOM_MIRROR: Device gm0: provider ad2 detected.
GEOM_MIRROR: Device gm0: rebuilding provider ad2.


To see what's happening:



# gmirror list | more
Geom name: gm0
State: DEGRADED
Components: 2
Balance: round-robin
Slice: 4096
Flags: NONE
GenID: 0
SyncID: 1
ID: 2125638583
Providers:
1. Name: mirror/gm0
Mediasize: 10262568448 (9.6G)
Sectorsize: 512
Mode: r6w5e2
Consumers:
1. Name: ad0
Mediasize: 10262568448 (9.6G)
Sectorsize: 512
Mode: r1w1e1
State: ACTIVE
Priority: 0
Flags: DIRTY
GenID: 0
SyncID: 1
ID: 3986018406
2. Name: ad2
Mediasize: 10262568448 (9.6G)
Sectorsize: 512
Mode: r1w1e1
State: SYNCHRONIZING
Priority: 0
Flags: DIRTY, SYNCHRONIZING
GenID: 0
SyncID: 1
Synchronized: 1%
ID: 1946262342


Note the SYNCHRONIZING on the Flags line. It will take a while for these two drives to synchronize, as it is currently at 1 percent. I've seen times ranging from about 30 minutes for a 10GB drive to about two and a half hours for a 75GB drive. If you're curious, check the progress with:



# gmirror status
Name Status Components
mirror/gm0 DEGRADED ad0
ad2 (2%)


You'll see a status message in bold white text when the synchronization finishes:



GEOM_MIRROR: Device gm0: rebuilding provider ad2 finished.
GEOM_MIRROR: Device gm0: provider ad2 activated.


If you repeat gmirror list, you'll note that the State has changed from DEGRADED to COMPLETE and the Synchronized line is now gone. Don't worry if you see DIRTY on the Flags line, as it simply indicates that the system has written new data to the disk but hasn't mirrored it yet. If you were to wait a few seconds on a quiet disk, you would see the Flags line change to NONE.



For the final test, reboot the system.



This time your startup messages should include:



GEOM_MIRROR: Device gm0 created (id=2125638583).
GEOM_MIRROR: Device gm0: provider ad0 detected.
GEOM_MIRROR: Device gm0: provider ad2 detected.
GEOM_MIRROR: Device gm0: provider ad0 activated.
GEOM_MIRROR: Device gm0: provider ad2 activated.
GEOM_MIRROR: Device gm0: provider mirror/gm0 launched.
Mounting root from ufs:/dev/mirror/gm0s1a


Final Notes



GEOM utilities are works in progress, and the developers constantly add new features and updates to the man pages. It's well worth your while to keep your favorite version of FreeBSD up-to-date using cvsup or to choose a newer release when deciding which version of FreeBSD to install.



If you wish to gather performance statistics on your mirror/duplex, try gstat(8). A good read through gmirror(8) is also in order, especially if you want an overview of the procedure for replacing a failed disk.


Dru Lavigne is a network and systems administrator, IT instructor, author and international speaker. She has over a decade of experience administering and teaching Netware, Microsoft, Cisco, Checkpoint, SCO, Solaris, Linux, and BSD systems. A prolific author, she pens the popular FreeBSD Basics column for O'Reilly and is author of BSD Hacks and The Best of FreeBSD Basics.

miercuri, 16 iulie 2008

FreeBSD recovery root password

Step # 1: Start FreeBSD server/workstation



Step # 2: Press Enter key at boot loader


At Welcome to FreeBSD! boot menu press spacebar key to pause default booting


Type number 4 key (type 4 number) to boot into single user mode


(click to enlarge)


Next you will see following prompt from system:

When prompted Enter full pathname of shell or RETURN for /bin/sh:


Press Enter key to boot into single user mode. Next, you will be immediately dropped into a single user mode without a root password.



You need to remount / (root) file system in read and write mode with mount command, type following two commands:

# mount -u /

# mount -a


Setup a new password with passwd command:

# passwd


Next type exit command to boot FreeBSD into multi-user mode environment:

# exit

OR You can just reboot the system:

OPenBSD Recovery root password

Procedure to reset root password


At boot> prompt type boot -s to boot into single user mode:

boot> boot -s


Next you will see a message as follows:


Enter pathname of shell or RETURN for sh:

Just hit [Enter] key to load sh shell.

Next mount / and /usr file system in read-write mode:

# mount -uw /

# mount /usr


Finally set or change the password for root user, enter:

# passwd

Press CTRL+D to boot into multiuser mode or just reboot server:


# reboot

duminică, 6 iulie 2008

FreeBSD Upgrade

FreeBSD install portsnap (for older system version <6 .0="" h2="">
On FreeBSD 6.0+, portsnap is contained in the FreeBSD base (core) system. You only need to to install portsanp as follows for older FreeBSD system:

# cd /usr/ports/ports-mgmt/portsnap


# make install clean

FreeBSD install portmanager


Simply type the following command:

# cd /usr/ports/ports-mgmt/portmanager

# make install clean


Upgrade FreeBSD ports collection


Run portsnap as follows:

# portsnap fetch extract

OR


# portsnap fetch

# portsnap extract


Output:

Looking up portsnap.FreeBSD.org mirrors... 4 mirrors found.
Fetching public key from portsnap3.FreeBSD.org... done.
Fetching snapshot tag from portsnap3.FreeBSD.org... done.
Fetching snapshot metadata... done.
Fetching snapshot generated at Sun Aug  5 19:38:18 CDT 2007:
b73e908500446b6593a4f763b8b2128490e733547cdaa7100% of   49 MB  195 kBps 00m00s
Extracting snapshot... done.
Verifying snapshot integrity... done.
Fetching snapshot tag from portsnap3.FreeBSD.org... done.
Fetching snapshot metadata... done.
Updating from Sun Aug  5 19:38:18 CDT 2007 to Mon Aug  6 05:58:34 CDT 2007.
Fetching 4 metadata patches... done.
Applying metadata patches... done.
Fetching 0 metadata files... done.
Fetching 18 patches.....10.... done.
Applying patches... done.
Fetching 0 new ports or files... done.
....
..
...

Display outdated ports list


You can list outdated ports list with pkg_version command:

# pkg_version -vIL=

OR

# pkg_version -vIL'<'


Output:

bash-3.1.17                         <   needs updating (index has 3.2.17_2)
gettext-0.14.5_2                    <   needs updating (index has 0.16.1_3)
libtool-1.5.22_2                    <   needs updating (index has 1.5.22_4)
linux_base-fc-4_9                   <   needs updating (index has 4_10)
....
......
.

Where,


  • v : Enable verbose output.

  • I : Use only the index file for determining if a package is out of date (faster result)


  • L= : Limit the output to those packages whose status flag does not match = (the installed version of the package is current.)

  • L'<' : Limit the output to those packages whose status flag does not match < (the installed version of the package is older than the current version.)

Update FreeBSD packages / software


Now run portmanager to upgrade installed ports:

# portmanager -u


It will updates ports in the correct order based on their dependencies. If a port fails to "make" during update it is marked as ignored. Portmanager will continue updating any ports not marked as "ignored" so long as they are not dependent on the ignored port. Also note that it may take some time if you have large number of application installed.

If you need to upgrade all installed ports with logging, enter:

# portmanager -u -l

How do I upgrade a single software only?


portmanager allows you to update a single port and all of its dependencies. For example update port called bash i.e. bash shell (shells/bash), enter:

# portmanager shells/bash -l -u -f

How do I apply update again?


In order to update system again just type the following command:

# portsnap fetch


# portsnap update

# portmanager -u -l


How do I apply binary security updates for FreeBSD?


Latest version includes a tool called freebsd-update (thanks to Bok for pointing out this tool). The freebsd-update tool is used to fetch, install, and rollback binary updates to the FreeBSD base system.

Fetch updates


Use fetch option to get all available binary updates:

# freebsd-update fetch

Output:

Looking up update.FreeBSD.org mirrors... 1 mirrors found.
Fetching public key from update1.FreeBSD.org... done.
Fetching metadata signature from update1.FreeBSD.org... done.
Fetching metadata index... done.
Fetching 2 metadata files... done.
Inspecting system... done.
Preparing to download files... done.
Fetching 18 patches.....10.... done.
Applying patches... done.

The following files will be updated as part of updating to 6.2-RELEASE-p7:
/boot/kernel/kernel
/etc/rc.d/jail
....
.....
/usr/lib/libmagic.so.2
/usr/sbin/dnssec-signzone
/usr/sbin/freebsd-update
/usr/sbin/lwresd
/usr/sbin/named
/usr/sbin/named-checkconf
/usr/sbin/named-checkzone
/usr/sbin/tcpdump

WARNING: FreeBSD 6.2-RELEASE is approaching its End-of-Life date.
It is strongly recommended that you upgrade to a newer
release within the next 5 months.


Install updates


Install the most recently fetched updates:

# freebsd-update install

Output:

Installing updates... done.

Rollback updates


Optional: You can uninstall most recently installed updates:

# freebsd-update  rollback  


Reboot system


You must reboot FreeBSD to take advntage of newly patched kernel:

$ uname -a

Output:

FreeBSD vip-1.freebsd.nixcraft.com 6.2-RELEASE FreeBSD 6.2-RELEASE #0: Fri Jan 12 10:40:27 UTC 2007
root@dessler.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

$ sudo reboot

After reboot verify system:

$ uname -a

Output:


FreeBSD vip-1.freebsd.nixcraft.com 6.2-RELEASE-p4 FreeBSD 6.2-RELEASE-p4 #0: Thu Apr 26 17:40:53 UTC 2007     root@i386-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  i386
 
 
To repair package database run ' pkgdb -F'. 
 

Map


Visitor Map