Features:
1. Ability to create volume sets and stripe sets
2. LVM masks the underlying physical technology (ATA,ATAPI,IDE,SCSI,SATA,PATA,etc.)
3. LVM represents storage using a hierarchy:
a. Volume groups
a1. Physical volumes (/dev/sda2, /dev/sdb2, etc.)
b. Logical Volumes
b1. File systems
3. LVM physical volumes can be of various sizes
4. Ability to resize volumes on the fly
Note: Volume groups join: physical volumes (PVs) and Logical Volumes (LVs)
6 Steps to setup LVM:
1. Create LVM partitions via fdisk or parted
a. fdisk /dev/sda, /dev/sdb, /dev/sdc
b. n
c. p
d. +10G
e. t - change to type '8e' (LVM)
f. w
g. partprobe /dev/sda
2. Create Physical Volumes using 'pvcreate'
a. pvcreate /dev/sda3 /dev/sdb3 /dev/sdc3
3. Create Volume Groups using 'vgcreate'
a. vgcreate volgroup001 /dev/sda3 /dev/sdb3 /dev/sdc3
Note: Volume groups can be segmented into multiple logical volumes
4. Create one or more Logical Volumes
a. lvcreate -L 10GB -n logvolvar1 volgroup001
b. lvcreate -L 10GB -n logvolusr1 volgroup001
5. Create File system on logical volume(s)
a. mke2fs -j /dev/volgroup001/logvolvar1
b. mke2fs -j /dev/volgroup001/logvolusr1
6. Mount logical volume
a. mkdir /var1
b. mount /dev/volgroup001/logvolvar1 /var1
c. mkdir /usr1
d. mount /dev/volgroup001/logvolusr1 /usr1
Note: Be certain to update: /etc/fstab so that volumes are mounted when the system reboots
3-tiers of LVM display commands include:
a. pvdisplay - physical volumes - represent raw LVM partitions
b. vgdisplay - volume groups - aggregate physical volumes
c. lvdisplay - logical volumes - file systems - mount here
Rename of Logical Volume:
1. lvrename volume_group_name old new - used to rename volumes
Task: Rename 'logvolvar1' to 'logvolopt1'
a. lvrename volgroup001 logvolvar1 logvolopt1
Note: LVM is updated immediately, even while volume is mounted
However, you must remount the logical volume to see the changes
b. umount /var1 && mount /dev/mapper/volgroup001-logvolopt1 /opt1
c. Update /etc/fstab
Remove Logical Volume:
Task: Remove 'logvolusr1' from the logical volume pool
a. umount /usr1
b. lvremove /dev/mapper/volgroup001-logvolusr1
c. use 'lvdisplay' to confirm removal
Resize Logical Volume:
Task: Grow (resize) 'logvolopt1' to 20GB
a. lvresize -L 20GB /dev/volgroup001/logvolopt1
b. lvdisplay - to confirm new size of logical volume
c. df -h - will still reveal the current size
d. Resize the file system to update the INODE table on the logical volume to account for the new storage in 'logvolopt1'
'resize2fs -f -p /dev/volgroup001/logvolopt1'
Note: You may resize file systems online if the following are met:
1. 2.6x kernel series
2. MUST be formatted with ext3
Task: Shrink (resize) 'logvolopt1' to 15GB
a. lvresize -L 15GB /dev/volgroup001/logvolopt1
b. lvdisplay
c. df -h
d. resize2fs -f -p /dev/volgroup001/logvolopt1
Note: online shrinking is not supported
e. df -h
Note: Check disk utilization prior to shrinking to reduce the risk of losing data
LVM GUI Utility:
system-config-lvm
Hi I am T.VinaySudhir RHCE (author of this blog).. This Blog contains Basic notes needed for REDHAT ENTERPRISE EDITION LINUX 5 Certification Exam.
Sunday, December 19, 2010
Create Swap based on File
Features:
1. The ability to provision swap space based on a file, similar to pagefile.sys in Windows NT, etc., if you have no available disk space to partition.
2. Doesn't waste partitions
Task:
1. Create 512MB swap file
a. dd if=/dev/zero of=/home1/swapfile1 bs=1024 count=524288
b. mkswap /home1/swapfile1 - overlays swap file system
c. swapon /home1/swapfile1 - makes swap space avaialable to the kernel
2. Ensure that when the system reboots, the swapfile is made avialable to the kernel
a. nano /etc/fstab - /home1/swapfile1 swap swap defaults 0 0
3. Create 2GB swap file
a. dd if=/dev/zero of=/home1/swapfile2 count=2G
1. The ability to provision swap space based on a file, similar to pagefile.sys in Windows NT, etc., if you have no available disk space to partition.
2. Doesn't waste partitions
Task:
1. Create 512MB swap file
a. dd if=/dev/zero of=/home1/swapfile1 bs=1024 count=524288
b. mkswap /home1/swapfile1 - overlays swap file system
c. swapon /home1/swapfile1 - makes swap space avaialable to the kernel
2. Ensure that when the system reboots, the swapfile is made avialable to the kernel
a. nano /etc/fstab - /home1/swapfile1 swap swap defaults 0 0
3. Create 2GB swap file
a. dd if=/dev/zero of=/home1/swapfile2 count=2G
Thursday, October 21, 2010
Swap Partitions & Files
Features:
1. Extra, virtual RAM for the OS
Steps:
1. Identify current swap space
a. swapon -s - enumerates partitions and/or files, which constitute swap storage
b. free -m
2. Select target drive and provision swap partition
a. fdisk /dev/sdb
b. n
c. 2
d. 500
e. +512 (cylinder 562) - 63 cylinders are required for 512MB
f. t - change type
g. 82 - Linux Swap/Solaris
h. w - committ changes to disk
3. Create the swap file system on the raw partition: /dev/sdb2
a. mkswap /dev/sdb2
4. Enable swapping - publish the swap space to the kernel
a. swapon /dev/sdb2 - this enables swapping on /dev/sdb2
5. update /etc/fstab
a. /dev/sdb2 swap swap defaults 0 0
swapoff /dev/sdb2 - disables swapping on /dev/sdb2
Task:
1. Improve system performance by distributing swapping to /dev/sdb2
a. swapon /dev/sdb2
b. swapoff /dev/sda6
c. disable /dev/sda6 via /etc/fstab
1. Extra, virtual RAM for the OS
Steps:
1. Identify current swap space
a. swapon -s - enumerates partitions and/or files, which constitute swap storage
b. free -m
2. Select target drive and provision swap partition
a. fdisk /dev/sdb
b. n
c. 2
d. 500
e. +512 (cylinder 562) - 63 cylinders are required for 512MB
f. t - change type
g. 82 - Linux Swap/Solaris
h. w - committ changes to disk
3. Create the swap file system on the raw partition: /dev/sdb2
a. mkswap /dev/sdb2
4. Enable swapping - publish the swap space to the kernel
a. swapon /dev/sdb2 - this enables swapping on /dev/sdb2
5. update /etc/fstab
a. /dev/sdb2 swap swap defaults 0 0
swapoff /dev/sdb2 - disables swapping on /dev/sdb2
Task:
1. Improve system performance by distributing swapping to /dev/sdb2
a. swapon /dev/sdb2
b. swapoff /dev/sda6
c. disable /dev/sda6 via /etc/fstab
Basic Provisioning of Partitions and File Systems
Features:
1. Ability to provision extra storage on-the-fly
Steps:
1. Identify available storage
a. 'fdisk -l' - returns connected storage
2. Create partitions on desired hard drive:
a. 'fdisk /dev/sdb' - interacts with /dev/sdb drive
b. 'n' - to add a new partition
c. 'p' - primary
d. '1' - start cylinder
e. '+4096M' - to indicate 4 Gigabytes
f. 'w' - to write the changes to the disk
Note: use 'partprobe partition (/dev/sdb1)' to force a write to a hard drive's partition table on a running system
Note: 'fdisk' creates raw partitions
3. Overlay (format) the raw partition with a file system
a. mke2fs -j /dev/sdb1 - this will write inodes to partition
4. Mount the file system in the Linux file system hierarchy:
a. mkdir /home1 && mount /dev/sdb1 /home1
b. mount OR df -h - either will reveal that /dev/sdb1 is mounted
Note: lost+found directory is created for each distinct file system
5. Configure '/home1' to auto-mount when the system boots
a. nano /etc/fstab and copy and modify the '/home' entry
1. Ability to provision extra storage on-the-fly
Steps:
1. Identify available storage
a. 'fdisk -l' - returns connected storage
2. Create partitions on desired hard drive:
a. 'fdisk /dev/sdb' - interacts with /dev/sdb drive
b. 'n' - to add a new partition
c. 'p' - primary
d. '1' - start cylinder
e. '+4096M' - to indicate 4 Gigabytes
f. 'w' - to write the changes to the disk
Note: use 'partprobe partition (/dev/sdb1)' to force a write to a hard drive's partition table on a running system
Note: 'fdisk' creates raw partitions
3. Overlay (format) the raw partition with a file system
a. mke2fs -j /dev/sdb1 - this will write inodes to partition
4. Mount the file system in the Linux file system hierarchy:
a. mkdir /home1 && mount /dev/sdb1 /home1
b. mount OR df -h - either will reveal that /dev/sdb1 is mounted
Note: lost+found directory is created for each distinct file system
5. Configure '/home1' to auto-mount when the system boots
a. nano /etc/fstab and copy and modify the '/home' entry
Quotas
Features:
1. Limits disk usage (blocks or inodes)
2. Tied to file systems (set on a per file system basis)
3. Can be configured for users and groups
Steps to enable quota support:
1. Enable quota support per file system in: /etc/fstab
a. defaults,usrquota,grpquota
2. Remount the file system(s)
a. mount -o remount /
b. use 'mount' to confirm that 'usrquota,grpquota' support are enabled
3. Create quota database files and generate disk usage table
a. quotacheck -mcug / - this creates /aquota.user & /aquota.group
b. quotacheck -mavug
4. Assign quota policies
a. edquota username - set blocks/inodes soft_limits hard_limit
edquota student1 - sets quotas for user 'student1'
export EDITOR=nano - to have edquota default to 'nano' editor
5. Check quotas
a. quota username
quota student1
Note: place 'quotacheck -avug' in /etc/cron.*(hourly,daily)
6. Report on usage
a. repquota -a - this reports on usage
Note: The blocks are measured in 1K increments. i.e. 20000 blocks is roughly 20MB
1. Limits disk usage (blocks or inodes)
2. Tied to file systems (set on a per file system basis)
3. Can be configured for users and groups
Steps to enable quota support:
1. Enable quota support per file system in: /etc/fstab
a. defaults,usrquota,grpquota
2. Remount the file system(s)
a. mount -o remount /
b. use 'mount' to confirm that 'usrquota,grpquota' support are enabled
3. Create quota database files and generate disk usage table
a. quotacheck -mcug / - this creates /aquota.user & /aquota.group
b. quotacheck -mavug
4. Assign quota policies
a. edquota username - set blocks/inodes soft_limits hard_limit
edquota student1 - sets quotas for user 'student1'
export EDITOR=nano - to have edquota default to 'nano' editor
5. Check quotas
a. quota username
quota student1
Note: place 'quotacheck -avug' in /etc/cron.*(hourly,daily)
6. Report on usage
a. repquota -a - this reports on usage
Note: The blocks are measured in 1K increments. i.e. 20000 blocks is roughly 20MB
Symlinks
Features:
1. Provides shortcuts to files (including directories)
2. Provides hard links to inode (file system) locations
Soft Links:
1. ln -s source_file target
a. ln -s ./regextest.pl lastscript.pl
Note: Soft links may span multiple file systems/hard drives
Note: Symlink count is NOT increased when using soft links
2. ln -s /home/Linuxtutorial/testRH5/regextest.pl . - this will symlink (soft) to the /boot file system
Note: With soft links, if you change the name or location of the source file, you will break ALL of the symlinks (soft)
Hard Links:
Features:
1. The ability to reference the same inode/hard drive location from multiple places within the same file system
a. ln source target
ln regextest.pl ./testhardregextest.pl - creates a hard link
1. Provides shortcuts to files (including directories)
2. Provides hard links to inode (file system) locations
Soft Links:
1. ln -s source_file target
a. ln -s ./regextest.pl lastscript.pl
Note: Soft links may span multiple file systems/hard drives
Note: Symlink count is NOT increased when using soft links
2. ln -s /home/Linuxtutorial/testRH5/regextest.pl . - this will symlink (soft) to the /boot file system
Note: With soft links, if you change the name or location of the source file, you will break ALL of the symlinks (soft)
Hard Links:
Features:
1. The ability to reference the same inode/hard drive location from multiple places within the same file system
a. ln source target
ln regextest.pl ./testhardregextest.pl - creates a hard link
Thursday, July 15, 2010
File Types - Permissions - Symlinks
Features:
1. The ability to restrict/control access to files
Note: 10 bits represent permissions for files (including directories)
Note: use 'ls -l' to examine permissions or GUI application like 'Nautilus'
-rwxrwxr-x 1 linuxcbt linuxcbt 681 Jan 13 11:31 regextest.pl
1st bit = file type. '-' = file, 'd' = directory
2nd - 4th bits = owner's permissions
r = read = 4
w = write = 2
x = execute = 1
- = none = 0
5th - 7th bits = group owner's permissions
r = read = 4
w = write = 2
x = execute = 1
- = none = 0
8th - 10th bits = everyone (world)
r = read = 4
w = write = 2
x = execute = 1
- = none = 0
Task:
1. Manipulate file permissions using 'chmod'
a. chmod -x regextest.pl
-rw-rw-r-- 1 linuxcbt linuxcbt 681 Jan 13 11:31 regextest.pl
rw = 6 or 4+2 for owner
rw = 6 or 4+2 for group owner
r = 4 for everyone else (world)
Octal notation: 664 for file 'regexetest.pl'
chmod 664 regextest.pl - removes execution for ALL users
chmod 775 regextest.pl - enables execution for ALL users
2. Ensure that 'regextest.pl' is rw by owner and noone else
a. chmod 600 regextest.pl
Note: File will now be rw by owner (linuxcbt) and 'root'
3. Ensure that 'regextest.pl' is r by owner and noone else
a. chmod 400 regextest.pl && ls -l regextest.pl
Note: chmod supports string values, which represent octal values
chmod +/- x file
chmod +/- w file
chmod +/- r file
chmod +/- u+x file - updates owner's execute permissions on the file
chmod +/- o+x file - updates other's execute permissions on the file
chmod +/- g+x file - updates group's execute permissions on the file
chmod a+rwx = chmod 777
chown - permits changing of ownership of files
a. chown root regextest.pl - changes ownership to 'root'
b. chown linuxcbt:sales regextest.pl - changes owner and group to 'linuxcbt:sales'
Task:
Update 'regextest.pl' so that owner and group owner may modify the file
a. chmod 660 regextest.pl
SETUID:
Features:
1. ability to execute file as owner
chmod 4760 regextest.pl - this will ensure that the perl script always executes as the user 'linuxcbt'
-rwsrw---- 1 linuxcbt sales 787 Jan 28 16:08 regextest.pl
's' in the execute position means that the program will execute as that user
SETGID:
Features:
1. Ability to enforce permissions to a directory structure
mkdir /sales
chmod 2775 /sales
Create a file in the '/sales' directory as 'linuxcbt'
seq 1000000 > linuxcbt.1million.txt
chgrp:
Permits updating of group permissions
Sticky Bit:
Features:
1. Ability to ensure that users cannot delete others' files in a directory
drwxrwxrwt 23 root root 4096 Jan 28 15:05 /tmp/
/tmp - users cannot delete other user's files in '/tmp'
chmod 3777 /sales - ensures that /sales will not lose files from incorrect users
Task:
1. Set '/sales' using sticky bit and test
a. chmod 3777 /sales && ls -ld /sales OR chmod 777 /sales && chmod +t /sales
1. The ability to restrict/control access to files
Note: 10 bits represent permissions for files (including directories)
Note: use 'ls -l' to examine permissions or GUI application like 'Nautilus'
-rwxrwxr-x 1 linuxcbt linuxcbt 681 Jan 13 11:31 regextest.pl
1st bit = file type. '-' = file, 'd' = directory
2nd - 4th bits = owner's permissions
r = read = 4
w = write = 2
x = execute = 1
- = none = 0
5th - 7th bits = group owner's permissions
r = read = 4
w = write = 2
x = execute = 1
- = none = 0
8th - 10th bits = everyone (world)
r = read = 4
w = write = 2
x = execute = 1
- = none = 0
Task:
1. Manipulate file permissions using 'chmod'
a. chmod -x regextest.pl
-rw-rw-r-- 1 linuxcbt linuxcbt 681 Jan 13 11:31 regextest.pl
rw = 6 or 4+2 for owner
rw = 6 or 4+2 for group owner
r = 4 for everyone else (world)
Octal notation: 664 for file 'regexetest.pl'
chmod 664 regextest.pl - removes execution for ALL users
chmod 775 regextest.pl - enables execution for ALL users
2. Ensure that 'regextest.pl' is rw by owner and noone else
a. chmod 600 regextest.pl
Note: File will now be rw by owner (linuxcbt) and 'root'
3. Ensure that 'regextest.pl' is r by owner and noone else
a. chmod 400 regextest.pl && ls -l regextest.pl
Note: chmod supports string values, which represent octal values
chmod +/- x file
chmod +/- w file
chmod +/- r file
chmod +/- u+x file - updates owner's execute permissions on the file
chmod +/- o+x file - updates other's execute permissions on the file
chmod +/- g+x file - updates group's execute permissions on the file
chmod a+rwx = chmod 777
chown - permits changing of ownership of files
a. chown root regextest.pl - changes ownership to 'root'
b. chown linuxcbt:sales regextest.pl - changes owner and group to 'linuxcbt:sales'
Task:
Update 'regextest.pl' so that owner and group owner may modify the file
a. chmod 660 regextest.pl
SETUID:
Features:
1. ability to execute file as owner
chmod 4760 regextest.pl - this will ensure that the perl script always executes as the user 'linuxcbt'
-rwsrw---- 1 linuxcbt sales 787 Jan 28 16:08 regextest.pl
's' in the execute position means that the program will execute as that user
SETGID:
Features:
1. Ability to enforce permissions to a directory structure
mkdir /sales
chmod 2775 /sales
Create a file in the '/sales' directory as 'linuxcbt'
seq 1000000 > linuxcbt.1million.txt
chgrp:
Permits updating of group permissions
Sticky Bit:
Features:
1. Ability to ensure that users cannot delete others' files in a directory
drwxrwxrwt 23 root root 4096 Jan 28 15:05 /tmp/
/tmp - users cannot delete other user's files in '/tmp'
chmod 3777 /sales - ensures that /sales will not lose files from incorrect users
Task:
1. Set '/sales' using sticky bit and test
a. chmod 3777 /sales && ls -ld /sales OR chmod 777 /sales && chmod +t /sales
Subscribe to:
Posts (Atom)