Monday, April 20, 2009
Sunday, April 19, 2009
Replacing Hard disk in RAID 1
Implementing RAID in LINUX
Create a RAID Device /dev/md4 by creating equal two disks from available free space on your harddisk and mount it on /data.
Create the Two partitions having equal size.
Change the Partition ID to fd (Linux raid Autodetect)
Use partprobe command to synchronic the partition table.
Why SGID bit?
Who ever creates the files/directories on /mygrpdir group owner should be
automatically should be the same group owner of /mygrpdir.
1. chmod g+s /mygrpdir
2. Verify using: ls -ld /mygrpdir
Permission should be like:
drwxrws--- 2 root sysusers 4096 Mar 16 18:08 /mygrpdir
If SGID bit is set on directory then who every users creates the files on directory group
owner automatically the owner of parent directory.
To set the SGID bit: chmod g+s directory
To Remove the SGID bit: chmod g-s directory
Extending and Reducing LV in LINUX
Sunday, April 12, 2009
Step by Step guide: Manage additional disk on Linux using LVM
#fdisk /dev/hdd (and create following partitions with id:8e)
Device Boot Start End Blocks Id System
/dev/hdd1 1 1000 503968+ 8e Linux LVM
/dev/hdd2 1001 2000 504000 8e Linux LVM
[root@localhost ~]# pvcreate /dev/hdd1 /dev/hdd2
Physical volume "/dev/hdd1" successfully created
Physical volume "/dev/hdd2" successfully created
[root@localhost ~]# pvdisplay [compare with the o/p of same command after creating f/s of LV]
"/dev/hdd1" is a new physical volume of "492.16 MB"
--- NEW Physical volume ---
PV Name /dev/hdd1
VG Name
PV Size 492.16 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID lanTX2-t6KC-MTID-Ag8V-un2g-R6a9-janMLC
"/dev/hdd2" is a new physical volume of "492.19 MB"
--- NEW Physical volume ---
PV Name /dev/hdd2
VG Name
PV Size 492.19 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID W29vIo-K2SN-07Zl-3Xn8-1pDX-hkxQ-P3gk2h
[root@localhost ~]# vgcreate testvg /dev/hdd1 /dev/hdd2
Volume group "testvg" successfully created
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name testvg
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 980.00 MB
PE Size 4.00 MB
Total PE 245
Alloc PE / Size 0 / 0
Free PE / Size 245 / 980.00 MB
VG UUID TbRxlH-zYl9-Y3zz-tsEH-1ASj-1uma-qhVLo8
[root@localhost ~]# lvcreate -L 124M -n testlv testvg [creating LV of size 124M with name testlv ]
Logical volume "testlv" created
[root@localhost ~]# lvdisplay /dev/testvg/testlv
--- Logical volume ---
LV Name /dev/testvg/testlv
VG Name testvg
LV UUID jFiX1B-SL0k-bZZ3-yHMb-zO4h-OySU-1Sw3a9
LV Write Access read/write
LV Status available
# open 0
LV Size 124.00 MB
Current LE 31
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
[root@localhost ~]# mkfs -t ext3 /dev/testvg/testlv [ creating filesystem ]
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
31744 inodes, 126976 blocks
6348 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
16 block groups
8192 blocks per group, 8192 fragments per group
1984 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost lvmmntpt]# pvdisplay
--- Physical volume ---
PV Name /dev/hdd1
VG Name testvg
PV Size 492.16 MB / not usable 4.16 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 122
Free PE 122
Allocated PE 0
PV UUID lanTX2-t6KC-MTID-Ag8V-un2g-R6a9-janMLC
--- Physical volume ---
PV Name /dev/hdd2
VG Name testvg
PV Size 492.19 MB / not usable 0
Allocatable yes
PE Size (KByte) 4096
Total PE 123
Free PE 92
Allocated PE 31
PV UUID W29vIo-K2SN-07Zl-3Xn8-1pDX-hkxQ-P3gk2h
[root@localhost lvmmntpt]# vgdisplay
--- Volume group ---
VG Name testvg
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 980.00 MB
PE Size 4.00 MB
Total PE 245
Alloc PE / Size 31 / 124.00 MB
Free PE / Size 214 / 856.00 MB
VG UUID TbRxlH-zYl9-Y3zz-tsEH-1ASj-1uma-qhVLo8
[root@localhost lvmmntpt]# lvdisplay /dev/testvg/testlv
--- Logical volume ---
LV Name /dev/testvg/testlv
VG Name testvg
LV UUID jFiX1B-SL0k-bZZ3-yHMb-zO4h-OySU-1Sw3a9
LV Write Access read/write
LV Status available
# open 1 [ here open is 1 because it's mounted]
LV Size 124.00 MB
Current LE 31
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
[root@localhost ~]# vi /etc/fstab
…....
…....
/dev/testvg/testlv /lvmmntpt ext3 defaults 0 0
[root@localhost ~]# mount -a
[root@localhost ~]# cd /lvmmntpt/
[root@localhost lvmmntpt]# ls
lost+found
(It indicates successful mounting of newly created LV )