Pages

Showing posts with label BSD-UNIX. Show all posts
Showing posts with label BSD-UNIX. Show all posts

Wednesday, August 7, 2013

CCD - FreeBSD - CCD1 - How to

Configuring ccd1 on freeBSD with fourdisks

1. To remove the existing configuration. run the below command.

 # ccdconfig -v -U

2. Configure the Mirroring using the below command

# ccdconfig ccd0 32 CCDF_MIRROR  /dev/ada2 /dev/ada3 /dev/ada4 /dev/ada5

3. Construct the file system using the below command

# newfs /dev/ccd0

4 .Mount our mirrored disk and make it persistent

/dev/ccd0     /work0            ufs      rw     2   

5. Run # mount -a



Tuesday, August 6, 2013

Configuring CCD in FreeBSD - How to

In this how to I am explaining briefly about CCD ( Concatenated Disk Driver)


  1. To Configure CCD I am adding  4 new disks. System should be shutdown before adding to the disks

2. To confirm the detection of new disk check the kernel messages using dmesg command

 # dmesg













From the above output it's clear that 4 new disk has been added to the system with the names ada2,ada3,ada4;ada5.

3. Label the disks using the bsdlabel command

#  bsdlabel -w ada2

# bsdlabel -w ada3

# bsdlabel -w ada4

# bsdlabel -w ada5


4. Further label the disks using the bsdlabel -e


#  bsdlabel -e ada2

When you run the above command a file will be open in your default editor(Defined in the Editor Variable)







Add a new line starts with e: at the end of the file







Save the file( If it ask for the y/n question while saving please give 'n' and continue).


Repeat the same steps for all the disk ad3,ada4,ad5.


 5. Configure the CCD by running the below command.

# ccdconfig ccd0 32 0 ada2 ada3 ada4 ada5

Stripe size: Stripe size is the number defined x 512 bytes. In our case 32x512 =  16384 Bytes = 16KB

0 indicate the CCD level. level 0 is stripping and level 1 is mirroring


6. Generating UFS in the /dev/ccd0

# newfs /dev/ccd0


7. Create a mount point /work0 and mount our new ccd devise.

# mkdir /work0

# mount /dev/ccd0 /work0

4. To make the configuration become persistent across the reboot run

# ccdconfig -g  > /etc/ccd.conf


5. To make the mounting persistent across the reboot add line like shown below to /etc/fstab.










Run mount command

# mount -a


To test the I/O run the below command. The command create a 1 GB file in /work0 directory which is already mounted by /dev/ccd0.


dd if=/dev/zero bs=1M count=1024 of=/work0/testfile.text


Enjoy !







Thursday, July 11, 2013

Creating Swap file in the BSD

Creating a 512 MB file using below command.
# dd if=/dev/zero of=/swap1/swap0 bs=1024k count=512

# chmod 600 /swap1/swap0
Convert the file in to Swap usingthe belwo command
# mdconfig -a -t -t vnode -f /swap1/swap0 -u
# swapon /dev/md0

Check the swap availability using the below command
# swapinfo OR # top 
Make the setup persistent across the reboot add the below line to /et/rc.conf
swapfile="/swap1/swap0"

To turn off Swap
#swapoff /dev/md0

Storage Provisioning - BSD

FreeBSD Device Names


da - storage name begins with da is is SCSI|SATA|USB
ad - IDE mass storage
fla - flash
cd - SCSI|SATA cd-roms
acd - IDE cd roms 
fd - floppy

/var/run/demsg.boot contains log of detected hardware @ last boot.
# dmesg - this comment also give the same output.

I have added a 4 GB disk to the system and I am partitioning this as 4 GB pation and mounting this /storage

Steps involved:
1. # sysinstall
2. Select the option  >> 
3.This will lead us to the fdisk window and in fdisk window select  option. 
4.In the next screen select No boot loader option 
Save and quit
2. Re-enter sysinstall
a. configure
b.label
c. assign one or more label and mount point.
d. exit and check if the mount points suing # df -h and # cat /etc/fstab

Update /etc/fstab
/dev/ada1s1d /storage ufs rw 2 2

Checksum

Checksums are used for integrity check of contents.

2. Multiple types are there
a. md5 - 128 bit 
b. sha1 - 160 bit 
c. sha256 - 256 bit 

Locations of Checksum Binaries in BSD.
# which md5
 /sbin/md5
# which sha1
 
 /sbin/sha1
# which sha256
 /sbin/sha256
md5 waits on STDIN for input (use CTRL-D to terminate STDIn stream) - Generates a unique finger print.
Example.
vasanth aa8adc7e1fb2c83161357130a4281c1a
Checksum do not garantee that a man in the middle has not viewed your content. It simply means the content is intact.
Checksum strings do not vary with time. They are solely content-dependent.
b. sha1 - vasanth-  6a04ed4f77798a2e8661e44cc9746f329af953af
c. sha256 - vasanth - b932a819680211a67c15707c88ca2070c55093139c12dbacb34597f2d3c0467f

To generates unique fingerprint for the strings
# md5|sha1|sha256 -s "STRING"
Generating Fingerprint for the files.


# md5 filename
Create a file called check.txt and create finger print for the file.


# cat check.txt
This is fingerprint check file.
Run the following command to get the fingerprint using md5,sha1,sha256


# CFILE=check.txt ; md5 $CFILE && sha1 $CFILE && sha256 $CFILE
 MD5 (check.txt) = 1da283e6addeca541faff8d2c617dea4
 SHA1 (check.txt) = ab5a2ea17198ac8f17225bbfa4d7135e70deb744
 SHA256 (check.txt) = 3f6309880627d03d8941774456f865058f19db449f67f5165ec7a76f73a1375e
Checksums are only as goo as the security behind the provider of the content Generating the checksums and saving in file


# CFILE=check.txt ; md5 $CFILE >> $CFILE.sums && sha1 $CFILE >> $CFILE.sums && sha256 $CFILE >> $CFILE.sums


[root@basd1 ~]# cat check.txt.sums
MD5 (check.txt) = 1da283e6addeca541faff8d2c617dea4
SHA1 (check.txt) = ab5a2ea17198ac8f17225bbfa4d7135e70deb744
SHA256 (check.txt) = 3f6309880627d03d8941774456f865058f19db449f67f5165ec7a76f73a1375e


Publish sums file with source so that receiver can check the integrity of the source by checking the fingerprint.

Enjoy !!!

User Management in FreeBSD

These tools provide ability to manage the users across the system.
adduser is
# adduser 
Below are the steps involved when using adduser command in freeBSD.
Username: hemanth
Full name: Hemanth Murali
Uid (Leave empty for default):
Login group [hemanth]:
Login group is hemanth. Invite hemanth into other groups? []:
Login class [default]:
Shell (sh csh tcsh bash rbash nologin) [sh]: bash
Home directory [/home/hemanth]:
Home directory permissions (Leave empty for default):
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]:
Use a random password? (yes/no) [no]:
Enter password:
Enter password again:
Lock out the account after creation? [no]:
Username   : hemanth
Password   : *****
Full Name  : Hemanth Murali
Uid        : 1002
Class      :
Groups     : hemanth
Home       : /home/hemanth
Home Mode  :
Shell      : /usr/local/bin/bash
Locked     : no
OK? (yes/no): yes
adduser: INFO: Successfully added (hemanth) to the user database.
Add another user? (yes/no): yes
Username:


IN BSD adduser script updates password in two files
1. /etc/password
2. /etc/master.password 

adduser script automatically copies the /usr/share/skel directory dot files to users home directory.
REMOVING A LOCAL USER


[root@basd1 ~]# rmuser
Please enter one or more usernames: hemanth
Matching password entry:
hemanth:*:1002:1002::0:0:Hemanth Murali:/home/hemanth:/usr/local/bin/bash
this the entry you wish to remove? yes
Remove user's home directory (/home/hemanth)? yes
Removing user (hemanth): mailspool home passwd.

-y option with rmuser will remove with taking yes for all the questions
# rmuser -y hemnath 
To update the user attributes.
#chpass -s /bin/csh vasanth
The above command will change the uer shell to csh.
FreBSD imposes no account linits regarding: expiration and mandatory password change.
To change users password
# passwd username 
To list the attributes of a user
# pw show user vasanth
 Output:
vasanth:*:1001:1001::0:0:Vasanth Muraleedharan:/home/vasanth:/usr/local/bin/bash


To change the shell of the user using pw
# pw mod user vasanth -s /bin/sh

pw command changes the following files - /etc/passwd,/etc/master.passwd,group

Enjoy !!!

Gnome/X-setup in FreeBSD

By default in freeBSD there is no GUI installed.
Installing X and Gnome

Check the location of pkg_add by the below command.
# whereis pkg_add 
Output should be
pkg_add: /usr/sbin/pkg_add /usr/share/man/man1/pkg_add.1.gz

To install the X environment enter the below command.
# pkg_add -r xorg
After installation check the location of xorg by running the below command
# whereis xorg
Output should be
xorg: /usr/ports/x11/xorg
Installing GNOME

Add the below lines in /etc/rc.conf
gnome_enable="YES"
Save the file


Make the following lines in /etc/rc.conf
hald_enable="YES"
dbus_enable="YES"
Add the following lines in /etc/fstab
proc          /proc   procfs rw 0 0
This line is must for the Gnome to work properly.


Generate xorg.conf file by running the below command
Login as root
# Xorg -configure
Now a file named xorg.conf.new will be generated in the /root directory. Copy the file in to xorg.conf
# cp xorg.conf.new to xorg.conf 
# cp xorg.conf /etc/X11

Now we can start X in FreeBSD
# startx
Add the below line to /etc/rc.conf
gdm_enable="YES"
gnome_enable="YES"
and save the file
Install Gnome2 by running the below command


#pkg_add -r gnome2
After installation reboot the machine. No you can login to the Graphical environment.

Enjoy !!

Changing Network to DHCP in BSD

Changing Network to DHCP in BSD

open /etc/rc.conf

and change the the line starts with ifconfig_em0 to below
ifconfig_em0=" DHCP"
save and restart the network


# /etc/rc.d/netif restart