Sunday, August 2, 2009

Samba Server on Centos HOWTO

TDB database
root: > smbd -b | grep PRIVATE_DIR
/etc/samba

root: >smbd -b | grep LOCKDIR
/var/cache/samba

use tdbbackup utility to backup those tdb files

mkdir a directory and change its ownship
chown account.group /path/to/directory

Samba Configruation File
root: >smbd -b | grep smb.conf
/etc/samba/smb.conf

Dry run Samba Configurations
root: >testparm /etc/samba/smb.conf
root: >smbclient -L xxx.xxx.xxx.xxx(SambaServerIP) -U%

Samba valid user setup
root: >smbpasswd -a csguest
New SMB password:
Retype new SMB password:
startsmbfilepwent_internal: file /etc/samba/smbpasswd did not exist. File successfully created.
Added user csguest.

chown user.group /path/to/sambashare

Run/start/stop/restart Samba Server
root: >service smb reload
root: >service smb start
root: >service smb stop
root: >service smb condrestart

Mount Samba Share in Linux
root: >apt-get install smbfs
root: >smbmount //SambaServerIP/SambaShare /mnt/Dir -o username=account, password=pwd

Access Samba Share in WindowsXP
Control Panel -> User Accounts -> yourUserAccount
Click Manage my network passwords
Add button to enter Server, User name and Password
Server: xxx.xxx.xxx.xxx(SambaServerIP)
Username: xxx.xxx.xxx.xxx\AccountName
Password:******

My Computer -> Tools -> Map Network Drive
Folder: //SambaServerIP/SambaShare

Friday, May 1, 2009

Centos: nilfs compiling from src

Download source:
2.6.18 centos kernel source code (kernel-devel-2.6.18-128.el5.centos.plus.i686.rpm)
http://rpm.pbone.net/index.php3/stat/4/idpl/12390365/com/kernel-devel-2.6.18-128.el5.centos.plus.i686.rpm.html
kernel module source code
http://www.nilfs.org/download/nilfs-2.0.12.tar.bz2
patch for Centos
http://www.nilfs.org/pub/centos/5/SRPMS/nilfs-kmod-2.0.12-r.src.rpm
userland utilities source code
http://www.nilfs.org/download/nilfs-utils-2.0.12.tar.bz2

Required packages:
gcc
yum install gcc
e2fsprogs-devel
yum install e2fsprogs-devel

default installed: make binutils

Installation Instructions:
I. use Centos rpm installer to unpackage the kernel source code
The source code will be in the directory :
/usr/src/kernels/2.6.18-128.1.6.el5-i686

2. untar the nilfs kernel module source code and userland utilities source code
kernel module is in the directory: nilfs-2.0.12
utilities is in the directory: nilfs-utils-2.0.12

3. uncompress the nilfs-kmod-2.0.12-r.src.rpm package and copy the patch file nilfs-rhel5-kern-feature.patch to the kernel module src directory nilfs-2.0.12
_______________________________________________________

--- a/fs/kern_feature.h 2008-02-12 08:38:22.000000000 -0000
+++ b/fs/kern_feature.h 2009-04-09 12:27:24.000000000 -0000
@@ -30,6 +30,25 @@
/*
* Please define as 0/1 here if you want to override
*/
+/* for Red Hat Enterprise Linux / CentOS 5.x */
+#if defined(RHEL_MAJOR) && (RHEL_MAJOR == 5)
+# define NEED_MOUNT_SEMAPHORE 1
+# define NEED_INODE_GENERIC_IP 0
+# define NEED_INODE_BLKSIZE 0
+# define HAVE_PAGE_MKWRITE 1
+# if (RHEL_MINOR < 1)
+# define PageChecked PageFsMisc
+# define SetPageChecked SetPageFsMisc
+# define ClearPageChecked ClearPageFsMisc
+# endif
+# if (RHEL_MINOR > 0)
+# define NEED_INC_NLINK 0
+# if (RHEL_MINOR > 2)
+# define NEED_DROP_NLINK 0
+# define HAVE_LE32_64_ADD_CPU 1
+# endif
+# endif
+#endif

/*
* defaults dependent to kernel versions
_______________________________________________________

4. apply the patch to the kernel module source code
root: ~> patch -p1 < nilfs-rehel-kern-feature.patch

5. compile the kernel module source code root: ~> make
root: ~> make install

6. compile the utils source code
root: ~> make
root: ~> make install

Userful resource:
http://www.nilfs.org/download/READMEv2
http://www.cyberciti.biz/faq/appy-patch-file-using-patch-command/
http://rpm.pbone.net/index.php3/stat/4/idpl/12390365/com/kernel-devel-2.6.18-128.el5.centos.plus.i686.rpm.html
http://www.nilfs.org/en/faq.html
http://www.nilfs.org/en/pkg_centos.html

Tuesday, April 21, 2009

NilFS: tutorial

Nilfs is a LFS that NTT(Nippon Telegraph and Telephone Corp.) Group distributed to the Linux world. 

It has been merged into Linux mainline 2.6.30 rc-1

Below is the tutorial of how to set up a LFS partition in a VMware VM.

1. Attach multiple virtual disks to the VM in VMware

Editing virutal machine settings ->  add -> add a hard disk

 2. Install a CentOS5.1 distro in the VM and run the more than 260 updates 
(It is said CentOS5.1/5.2 are both OK. But CentOS5.0 needs to be patched.)

root : centos


3. Download the NilFS kmod and utils rpms from nilfs.org site.



Look for the nilfs utilities : nilfs-utils-2.0.12-1.i386.rpm 
Look for the exact kernel version 2.8.18_128 : kmod-nilfs-2.0.12-2.2.6.18_128.1.6.el5.i686.rpm

the utilities and the kernel module version should match the same nilfs version and also the centos kernel version.

(It also includes PAE and Xen rpm packages in the same directory)

4. Install the NilFS rpm package

root: ~>rpm -Uvh  kmod-nilfs-2.0.12-2.6.18_128.1.6.el5.i686.rpm

5. Format the virtual disk as nilFS and mount to the system.
(The extra disk is /dev/hda)

Format the disk by mkfs command
root: ~>mkfs -t nilfs2  /dev/hda
mount the LFS disk by mount command
root: ~>mount -t nilfs2   /dev/hda      /root/nilfs



6. Use the nilFS to recover the data

Before you make some changes, you can set a checkpoint by mkcp
root: ~>mkcp
root: ~>lscp   (lscp will show what checkpoints you have)


After you make the changes, you sjhould  make the previous checkpoint to be a snapshot and then mount that previous snapshot to a new spot
root: ~>chcp  ss  5
root: ~>mount -t  nilfs2 -r -0 cp=5   /dev/hda   /root/nilfs-cp

 



nilfs.org website instructions are at the link  http://www.nilfs.org/en/about_nilfs.html (how to use nilfs --incomplete)




7. Umount nilFS disk
root: ~>umount     /root/nilfs-cp
root: ~>umount    /root/nilfs

Next --> Setup NilFS in a Xen Guest



Monday, January 19, 2009

gcc linking error

Sympton:
/usr/lib/gcc/i586-suse-linux/4.1.2/../../../../i586-suse-linux/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference in \
/tmp/ccox5xu2.o
/lib/libc.so.6: could not read symbols: Bad value

Diagnosis:
Link error

Analysis:
/usr/include/unistd.h includes features.h which is using errno.h

So errno.h should be included.

Solution:
(Final)
#include before #include

(Temporary)
gcc -include /usr/include/errno.h code.c

Reference:
  1. http://www.robotercoding.com/blog/?p=36
  2. http://blog.chinaunix.net/u1/36607/showart_313647.html

Lab build

Ubuntu Hardy 8.04 LTS

Sun java
sudo apt-get install sun-java6-jdk - For the JDK (Developer)
sudo apt-get install sun-java6-jre - For the JRE (User)
sudo update-alternatives --config java

Acrobat Reader 8
sudo wget http://www.medibuntu.org/sources.list.d/hardy.list -O /etc/apt/sources.list.d/medibuntu.list
sudo apt-get update && sudo apt-get install medibuntu-keyring && sudo apt-get update
sudo apt-get install acroread

emacs
sudo apt-get install emacsx
smart-compile tag
/usr/share/emacs/site-lisp/smart-compile.el


Sunday, May 25, 2008

Solaris xVM ---PV Linux domU

Solaris system is reinstalled and vanilla. Xen is working. But still something needs to do from the beginning.
  • VNC configuration
  • virt-manager
To configure VNC to let it support xen display by the following command:
# svccfg -s xvm/xend setprop config/vncpaswd = astring:\"passwd\"
# svccfg -s xvm/xend setprop config/vnc-listen=astring:\"0.0.0.0\"
# svcadm refresh xvm/xend; svcadm restart xvm/xend

To install virt-manager, download the package and use the following command:
#pkgadd -d. SUNWvirt-manager

The one thing I left undone yet is paravirtual Linux domU. Generally, we have three methods to create a PV Linux domU: virt-install, virt-manager, and xm create.
virt-manager is GUI installlation and supports Fedora well. It is network install.
virt-install is command-line style but works substantially in diverse ways: netinstall, isoinstall, cdrom, etc.
xm create is command-line style too but mainly work in iso or cdrom install, which required configuration file prehand.

First, virt-manager. Due to our specific box, only centos works and DNS in guest still doesn't work properly. So I use the path address: http://128.153.145.19/pub/centos/5/os/i386/
The screenshot for installation can be seen as below:
I am just waiting for its completion and when it restarts, it looks like this:
While it is installing, it can not probe the video card. Either the driver is not ported or the virt-manager is not complete yet.
Note: so far I have no idea of where virt-manager has stored the configuration file for the guest. As I know, in virt-manager log it did log the xml format guest configuration.

To boot the installed CentOS domU guest, you need the following configuration file
name="centosP"
#kernel="/var/lib/xen/virtinst-vmlinuz.UAktlH"
#ramdisk="/var/lib/xen/virtinst-initrd.img.XxNCk0"
disk=['file:/export/home/newbie/centosP.img,xvda,w']
memory=1024
vif=['']
root="/dev/xvda"

Note: virtinst-vmlinuz.UAktlH and virtinst-initrd.img.XxNCk0 are created by virt-manager and when booting the guest, those two lines should be removed. Grub in the image will take over and boot up the guest. BTW, xvda is required in disk option rather than 0,w]

Graphics doesn't work for Paravirtualization in Solaris yet. Also even using virt-manager, CentOS cannot detect properly the video card type, so only text mode network installation works, using a generic video driver. ParaVirtualization is still black-and-white world. Some drivers are missing and need to be ported but they are in progress and almost there.

When we tried virt-install and xm create. It cannot install from iso because cdrom is not paravirtual ported. In another word, we didn't have cdrom paravirtual drivers there. We can have the CentOS boot up, but it will keep asking you the CD-ROM device driver. When booting a Linux-made , XENBUS said block device driver, nic device driver, and the console missing. The details can be seen as below:

It is said that one way to circle around CDROM is to use NFS. But I am not familiy

Solaris DNS

After saving the files from the last broken solaris, I need to reinstall the Solaris again. But this time, I didn't get that luck so that everything was smoothy. The network is broken. I have dual network cards in that box. One plugin for external, and the other integrated for internal. It only gets an IP 10.0.0.x and cannot work on the external one. I bet the plugg-in network card is broken. So I hook the external cable to the integrated network card. It can get an external IP now, but the DNS server address 2.35 is wrong. It can browse google by 61.233.169.104. But it can not go any further with DNS broken.

Without network, Solaris is a lonely isolated island. Even the sky is grey.

The solaris is default using the facility NWAM to auto configure the network. I have tried to switch to GNOME network configuration tool, it doesn't work that well. So I have to research in NWAM and make it work right.

For more details you can check the pages:
http://opensolaris.org/os/project/nwam/
and
http://docs.sun.com/app/docs/doc/806-1386/6jam5ahnd?a=view

Generally speaking, most of the websites introduce the way to configure DNS in solaris is to modify the related configuration file: /etc/resolv.conf and /etc/nsswitch.conf.
/etc/resolv.conf is to specify the DNS server, search domain, etc.
sample:
search clarkson.edu
nameserver 128.153.128.2
nameserver 128.153.4.2


/etc/nsswitch.conf is to specify the resolution order. To resolve an address, it has many ways: files, dns, mdns, etc.
key part of a sample
hosts: files dns mdns
ipnodes: files dns mdns

Originally, hosts option only has files, we need to add dns and mdns after it to provide more resolution methods.

How does DNS work in Solaris?
When there is an web address to be resolved, the DNS client in solaris FIRST consults the /etc/nsswitch.conf file to see which to look into first. In this example, the presumed order is local file first, DNS server second.
THEN, if the DNS client consults the local file and does not find an entry, the client consults the /etc/resolv.conf file to look through the name resolution search list and the address of the local DNS server.

It seems that as long as we make these two configure files right, then it is done. However, Solaris doesn't work as Linux does. Linux working style is to modify the configuration, and then restart the service, then all will be good. Solaris style works differently. Everything is in framework. No manually modifying configuration files but there are always tools or facilities to provide consistent modification.

Once the facility nwam can obtain IP from DHCP server, then the DNS should also work properly now. But there is another problem for Clarkson Network. The DHCP server in Clarkson gives me the 2.35 which is not the DNS server at all(I also tried ubuntu, the same result). The key problem is that Clarkson has multiple DNS servers. If it can broadcast and collect all the DNS server responses, then 2.35 is not a problem any more.

Solaris has the facility mdnsd (multicast DNS daemon)but it doesn't automatically run after booting. It is to broadcast to discover the DNS servers.

To make it work, first /etc/nsswitch.conf should be modified to add mdns after hosts option.
Then, to start the service by the following command:
# svcadm enable svc:/network/mdns:default
As the DNS daemon will cache the file. So once the configuration is done, Solaris needs to REBOOT.
-----------------------------------------ADDON-----------------------------------------------------------------------------------
The network interfaces in Solaris is stored in the file /etc/nwam/llp (LLP)
# cat /etc/nwam/llp
bge0 dhcp
rge0 dhcp

The host name and domain is stored in the file /etc/hosts
# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain solaris