Archive for July, 2009

SBDavid

Adding user/group in a FreeBSD server

Adding user/group in a FreeBSD server

How do I add a user and group to the FreeBSD Server?:

The ‘pw’ command can be used to add a user and or group to the FreeBSD System. The ‘pw’ command is a program that will allow any user with superuser privileges to edit and or add users and groups on FreeBSD with ease. It also allows a way to standardize modification of adding and removing users and groups.

pw groupadd anewgroup

This would create the group ‘anewgroup’ to the machine.

Now to add a users ‘ben’ to the ‘anewgroup’ using pw, issue the following command.

pw useradd ben -s /bin/csh -g anewgroup

This command would create the user ben, with a shell of /bin/csh and add it to the anewgroup group. The user would also have his home directory under /home/ben.

Now say, if the user needs to have the home directory on a different partition, for example /mnt/test/home issue the following command.

pw useradd ben -d /mnt/test/home/ben -s /bin/csh/ -g anewgroup

If the user ‘ben’ is to be added to a secondary group on the system, say a group that has been created already called ‘oldgroup’, then execute the following.

pw usermod ben -G oldgroup
SBDavid

Steps to upgrade MySQL in FreeBSD

Steps to upgrade MySQL in FreeBSD

Steps to upgrade MySQL version 4 to 5 in the FreeBSD :

1. Backup the existing MySQL database.

$ cd /var/db/
$ tar cvfz mysql.tar.gz mysql

2. Stop the MySQL service.

$ /usr/local/etc/rc.d/mysql-server.sh stop

3.Remove the existing MySQL Server .

pkg_delete mysql-server-4.*.*
pkg_delete mysql-client-4.*.*
Replace the ‘*’ with the version that is the server.

4. For installing the new MySQL Server, execute the following step.

$ cd /usr/ports/databases/mysql50-server && make install clean

5.Start MySQL 5.0 in the server and run the upgrade script.

$ /usr/local/etc/rc.d/mysql-server.sh start
$ /usr/local/bin/mysql_upgrade -u root -p –datadir=/var/db/mysql

You will be prompted for the new MySQL password where you can provide it.

Recompiling the FreeBSD kernel with PAE support

Please follow the steps to recompile the Freebsd with PAE support.

1. Edit the file named after the hostname in /usr/src/sys/i386/conf and remove “include GENERIC” and put “include PAE”

2. Rebuild/install it by going to /usr/src and typing “make buildkernel KERNCONF=whatever that file is called && make installkernel KERNCONF=whatever that file is called” ( substituting for the actual filename)

3 Reboot the server to make effect.

In Freebsd we are using the utility “sysinstall” for this purpose. Sysinstall is used for installation and configuration in the Freebsd. It’s GUI based tool in console. We can invoke the tool by typing sysinstall in the shell.

$ sysinstall

Freebsd uses the term “slice” for partitions. Before going to partitioning the disk let us be familiar with the disk device codes used in Freebsd. For ATAPI (IDE) disk the code “ad” is used and for SCSI disk we use the code “da”.

For example,

first IDE disk ———- ad0
second IDE disk ———- ad1

first SCSI disk ———- da0
second SCSI disk ———- da1

Each disk is divided into slices and each slice in further divided into partitions. The naming convention of slice is s1, s2, s3…. etc.. We are using letters a to h to designate partitions in the slice.

All together, we refer a partition by listing the disk code followed by slice number followed by partition letter.

For example,

ad1s3d — The forth partition in the third slice in the second IDE disk.

After invoking the sysinstall move to Configure >> Fdisk in the menu.

sysinstall >> Configure >> Fdisk

Once we get in to to the fdisk we are provided with a menu from where we can select the available disks in the system. We can use the navigate keys and tab to move through the options , space bar and return key for selecting the options. Select the new disk and click OK to continue. We then get into fdisk editor where we type A for selecting the entire disk for using with the freebsd.Then type W for writing the changes we are made. Type q to quit from the fdisk. We may get a Boot manager menu, where we choose “none” and select OK.

After selecting the disk we need to partition it. For this we need to invoke the “FreeBSD Disk Label Editor” via sysinstall >> Configure >> label in the menu.

sysinstall >> Configure >> label

Once we get into into label menu we need to create partition by typing C after selecting the appropriate slice. We then get a dialog box where we can specify the size of the partition. After specifying the size, a prompt, asking whether the partition to contain a file system or a swap space, will appear. We select the file system and press enter. Then a prompt for mount point will appear, where we specify the mount point. Type W to write the partition information in the disk and then type Q to quit from the Disk label editor.

We need to edit the /etc/fstab and issue “mount -a” to mount the newly partitioned disk

SBDavid

Installing Ports in FreeBSD

Installing Ports in FreeBSD

You can follow the steps below to install Ports on a FreeBSD 6.1 version.

1) Login to server as root.

2) Check if you have the binary /usr/local/bin/cvsup installed on the server. If not installed,

# fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/6.0-RELEASE/packages/net/
cvsup-without-gui-16.1h_2.tbz
cvsup-without-gui-16.1h_2.tbz 100% of 754 kB 37 kBps 00m00s
# pkg_add cvsup-without-gui-16.1h_2.tbz

3) Create a file /usr/src/cvs-supfile to upgrade lastest update of FreeBSD 6.0. This is my cvs-supfile add the entries below

#For complete list of cvsupd see CVSup Sites on FreeBSD handbook.
*default host=cvsup12.freebsd.org
*default base=/usr
*default prefix=/usr
*default release=cvs
*default delete use-rel-suffix
*default tag=RELENG_6_0

*default compress
src-all
ports-all tag=.

4) Run cvsup ,It will take a while to fetch both src and ports tree.

# /usr/local/bin/cvsup -L2 /usr/src/cvs-supfile

« Prev - Next »