Tuesday, December 25, 2012

Enlarge a file system in an LVM

Suppose /dev/sdb is the newly added disc. The original volume group is vg_dvd01. The logical volume to be enlarged is lv_home.

# Use fdisk to change a partition to be added to ID 8e
fdisk /dev/sdb 
# Make /dev/sdb1 a physical volume 
pvcreate /dev/sdb1
# Add /dev/sdb1 to the volume group 
vgextend -v vg_dvd01 /dev/sdb1
# Resize the target logical volume to use 100% free space of the volume group
lvresize -l +100%FREE /dev/vg_dvd01/lv_home
# Umount the file system first to speed up the resize operation
umount /home
# Do the resize
resize2fs /dev/vg_dvd01/lv_home
# Mount it back
mount /home

Create a few users on the just installed Linux

# Create the group first with group ID 1000
groupadd -g 1000 dvdgrp1

# Create the first user with user ID 1000
useradd -u 1000 -g dvdgrp1 user1

# Add other users

for i in user2 user3 user4 user5 user6 user7 user8 user9 user10
do
    useradd -g dvdgrp1 $i
done


# Set initial password to the same as user name

for i in user1 user2 user3 user4 user5 user6 user7 user8 user9 user10
do
    echo $i | passwd --stdin $i
done

Enable Samba server in CentOS 6.3

  1. Install Samba
    yum install samba samba-common 
  2. Edit Samba config file
    vi /etc/samba/smb.conf
    1. In the [global] section
              security = user
              passdb backend = tdbsam
              # Set to follow symbolic links
              follow symlinks = yes
              wide links = yes
              unix extensions = no
    2. In the [homes] section
              comment = Home Directories
              browseable = no
              writable = yes
              valid users = %S
              create mask = 0664
              directory mask = 0775
  3. Enable Samba in run levels 2, 3, 4, 5
    chkconfig --levels 2345 smb on
  4. Start the just installed Samba
    /etc/init.d/smb start
  5. Add users with default password as user name
    for i in user1 user2 user3 user4 user5
    do
            echo -e $i\\n$i | smbpasswd -a -s $i
    done
  6. Add these lines to /etc/sysconfig/iptables
    -A INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
    -A INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
  7. Restart iptables
    service iptables restart
  8. Let SELinux enable Samba home dirs
    setsebool -P samba_enable_home_dirs on
For more details, see http://wiki.centos.org/HowTos/SetUpSamba

Monday, December 24, 2012

中文英文之間要加個空白

用 Google 的拼音輸入法的語音輸入,發現他會自己在中文英文之間加個空白,像是:「一個人要 499」。

這跟我的習慣一樣,突然有「德不孤必有鄰」的感覺。

陶板屋

今天有新人報到,老闆照例又聚餐,今天吃的是陶板屋,這個比較合口味,不過不便宜,一個人要 499。

Sunday, December 23, 2012

Friday, December 21, 2012

Build and install tmux without root privilege

tmux is the new terminal multiplexer. It is used to replace the old screen.
 
mkdir ~/tools
cd tools
TOOLPATH=$PWD
tar zxf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure --prefix=$TOOLPATH
make
make install
cd ..
tar zxf tmux-1.7.tar.gz
cd tmux-1.7
CPPFLAGS="-I$TOOLPATH/include" LDFLAGS="-L$TOOLPATH/lib" ./configure --prefix=$TOOLPATH
make
make install
cd ..


After tmux is installed to $TOOLPATH/bin, do not forget to add where $TOOLPATH/bin is to your .bashrc. For a good example of .tmux.conf, please check here http://blog.longwin.com.tw/2011/04/tmux-learn-screen-config-2011/. The link is https://github.com/tsung/config/blob/master/shell/tmux.conf.