RH133 7. ADVANCED FILE SYSTEM




    QUOTAS

To set up quota
1.vim /etc/fstab
   LABEL=/home    /home    ext3    defaults,usrquota      1 2
2.mount -a
3.mount
4.mount -o remount /home
5.mount
6.ls /home
7.quotacheck -cufmg /home
8.ls /home
9.quotaon /home

a> To Set quota for user limiting his block size (BLOCKS)
    Set 80 as  soft (min), and  120  as hard (max)

      blocks=56
      soft  =blocks  + soft(min)  ex:  56 + 80
      hard  =blocks  + hard(min)  ex:  56 + 120

1.edquota -u suma (edit the blocks of file as given below)
   Filesystem   blocks    soft       hard     inodes     soft     hard
   /dev/sda7     56     136         176          7       10       12

2.su - suma
    $> dd if=/dev/zero of=/home/suma/xyz bs=1024 count=80    //Warn
    $> dd if=/dev/zero of=/home/suma/xyz bs=1024 count=120   //Stop
    $> ctrl d
3.repquota -t /home


b> To Set quota for user limiting his num of files (INODES)
Set 10 as soft (min),and  12 as hard  (max)

1.edquota -u raju    (edit the inodes of file as given below)
     Filesystem   blocks     soft     hard     inodes     soft     hard
     /dev/sda7       56       0        0          7       10       12

2.su - raju
  $> touch 1 2 3
  $> ls -a |wc -l  //Warns
  $> touch 4 5
  $> ls -a |wc -l  //Stop
  $> ctrl d
3. repquota -t  /home   



    RAID  (redundant array of indepedent disks)

1. raid 0         ->stripping
2. raid 1         ->mirroring
3. raid 2 onwards ->parity check


TO CREATE RAID

1. fdisk  /dev/sda  ->create 3 partitons and label as fd
2. partprobe
3. fdisk -l
4. mdadm -C /dev/md0 -n 2 -l 1 /dev/sda8 /dev/sda9 ->create raid device
    where  n ->num of device l ->raid level

5. cat /proc/mdstat             ->status of raid device
6. mkfs.ext3 /dev/md0           ->format raid
7. mkdir /raid
8. mount /dev/md0 /raid         ->mount raid
9. cp /etc/* /raid              ->put some contents to raid dir
10.ls /raid/
11.mount                      
12.df -h
13.vim /etc/fstab               ->mount raid permanently
   /dev/md0   /raid  ext3  defaults   1 2 (Add this line to /etc/fstab)
14.mount -a


    TO VERIFY RAID

1. cat /proc/mdstat       -->status of raid device
2. umount /raid
3. mdadm --stop /dev/md0  -->stop raid device
4. umount /raid
5. cat /proc/mdstat      
6. mkdir /test1             -->create dir for mounting raid partitions
7. mkdir /test2
8. mount /dev/sda8 /test1      --> mount partiton on dir
9. mount /dev/sda9 /test2
10.ls /test1
11.ls /test2
12.umount /test1                -->umount the partitions
13.umount /test2
14.mdadm --assemble /dev/md0 /dev/sda8 /dev/sda9 -->assemble partitions
15.cat /proc/mdstat
16.mount /dev/md0 /raid         --> mount back the raid
17.cat /proc/mdstat

   
    TO RECOVER A FAILED PARTITION

1. cat /proc/mdstat
2. mdadm --fail /dev/md0 /dev/sda8       //Fail a partition
3. cat /proc/mdstat
4. mdadm --add /dev/md0 /dev/sda10       //Add a partition
5. mdadm --remove /dev/md0 /dev/sda8     //Remove faulty partition
6. cat /proc/mdstat

    TO REMOVE THE CONFIGURED RAID

1. vim /etc/fstab         ->Remove raid entries from /etc/fstab
2. umount /dev/md0        ->unmounting the raid device
3. mdadm --stop /dev/md0  ->Stop the raid device
4. fdisk /dev/hda         ->Delete the partitions



FIELDS OF /ETC/FSTAB
1.partition or label of partition
2.Directory to mount the partition
3.file system type
4.Defaults (rw,ro,acl,quota)
5.Dump (backup)  1->Take backup  0->dont take backup
6.File system check  1->first priority 2 ->second priority
                     0->Dont check file system


a>. TO TAKE BACK UP OF PARTITION USING DUMP COMMAND

1. dump -0uf 123 /boot    ->Take backup of /boot in 123 file
2. du -h /boot/           ->check space of /boot and 123
3. du -h 123

4. mkdir /boot/extra      ->add some more contents to /boot dir
5. cp /etc/* /boot/extra
6. du -h /boot/extra/

7. dump -1uf 456 /boot ->Again take backup of only newly added contents
8. du -h 456
9.du -h /boot/extra/

TO RESTORE BACK
1.cd abc             ->go to dir where you want to restore
2.restore -rf /456   ->where /456 is place where we took backup


b>. TO TAKE BACK UP  USING TAR COMMAND

1.tar -cvf backup file1 file2 file3 ->c-create v-verbose f-file,take
                             backup of file1 to file3 in backup file

2.tar   -tvf backup        ->t-list num of files  backed up

3.tar   -xvf backup        ->x-extract files backed up in pwd.

4.tar  -rvf backup  file4 file5 ->r-append more files to backed up file

5.tar  -xvf backup -C /var ->Extract files inside /var dir


To uncompress and extract a file  gzip file

1.gzip backup    ->compress the file
2. tar  zxvf  backup  ->uncompress + extract the file

To uncompress and extract a file  bzip2 file
1.bzip2 backup    ->compress the file
2. tar  jxvf  backup  ->uncompress + extract the file


    LVM (LOGICAL VOLUME MANAGER)

1. TO CREATE LVM

1.fdisk /dev/sda   ->create 3 partitions + label to 8e
2.partprobe
3.fdisk -l
4.pvcreate /dev/sda8 /dev/sda9
5.pvdisplay /dev/sda8
6.pvdisplay /dev/sda9
7.vgcreate vg0 /dev/sda8 /dev/sda9
8.vgdisplay
9.lvcreate -L +200M -n /dev/vg0/home1
10.lvdisplay /dev/vg0/home1
11.lvcreate -L +300M -n /dev/vg0/var1
12.lvdisplay /dev/vg0/var1
13.mkfs.ext3 /dev/vg0/var1
14 mkfs.ext3 /dev/vg0/home1
15.mkdir /home1
16.mkdir /var1
17.mount /dev/vg0/home1 /home1
18.mount /dev/vg0/var1 /var1
19.cp /etc/a* /home1
20.cp /etc/b* /var1
21.vim /etc/fstab
   /dev/vg0/var1   /var1    ext3  defaults   1 2
   /dev/vg0/home1  /home1   ext3  defaults   1 2
22.mount -a

TO EXTEND LVM

1.lvdisplay /dev/vg0/home1
2.lvextend -L +200M /dev/vg0/home1
3.ls /home1
4.resize2fs /dev/vg0/home1
5.ls /home1

TO REDUCE LVM

1. lvdisplay
2. umount /var1
3. e2fsck -f /dev/vg0/var1
4. resize2fs /dev/vg0/var1 100M
5. lvreduce -L -100M -n /dev/vg0/var1
6. mount /dev/vg0/var1 /var1
7. df -h

LVM SNAPSHOT

1.  lvcreate  -L 200M -s -n lv2 /dev/llc/lv1

TO EXTEND PV
1.pvcreate /dev/sda10
2.pvdisplay
 
TO EXTEND VG
1.vgextend vg0 /dev/sda10
2.vgdisplay vg0

TO REDUCE VG
1.vgreduce vg0 /dev/sda10
2.vgdisplay

TO REDUCE PV
1.pvremove /dev/sda10
2.pvdisplay

REMOVE LVM
1.lvdisplay
2.umount /dev/vg0/home1
3.umount /dev/vg0/var1
4.vim /etc/fstab
5.lvremove /dev/vg0/home1
6.lvremove /dev/vg0/var1
7.lvdisplay

REMOVE VG
1.vgdisplay
2.vgremove /dev/vg0
3.vgdisplay

REMOVE PV
1.pvdisplay
2.pvremove /dev/sda9
3.pvremove /dev/sda8

If you found this post useful, I would really love it, if you can Like the Page, or share it with your Facebook/Google+/Twitter Friends... It will keep me motivated. Thank you!

No comments:

Post a Comment