rh135-day12.pdf

(239 KB) Pobierz
RH135-Day12
Written by Rajib Shahriar Rubence
------------------
Day 12
------------------
Network Configuration and Troubleshooting:
-Change the IP, Subnet, Gateway and DNS Information from command prompt:
# cd /etc/sysconfig/network-scripts/
# vi ifcfg-eth0
-Change the HOSTNAME Information:
# cd /etc/sysconfig
# vi network
-Add a hostname to IP Address mapping
# vi /etc/hosts
- Check the network information
# ip addr  (same as ifconfig)
# ip route
# hostname
# cat /etc/resolve.conf
1/5
RH135-Day12
Written by Rajib Shahriar Rubence
# cat /etc/hosts
Overview of Adding New Filesytem to the Filesystem Tree:
01. Identify device:
The first step in adding a new filesystem is to identify the device to be
used. This is usally something lik /dev/hda or /dev/sda. use the following command to check the
devices and the existing partitions created :
# fdisk -l
02. Partition device:
We can do the partition with the utility tool fdisk to partition the device and
choose the partition type. Linux-specific partitions would normally one of the following types:
- 5 (or f) -- Extended Partition
- 82       -- Linux Swap       
- 83       -- Linux
- 8e       -- Linux LVM
While using the "fdisk" tool to partition "/dev/sda" device we need to declare the partition type by
pressing "t" . We'll get a complete list of Partition type by pressing "L"
partprobe: At system bootup, the kernel makes its own in-memroy copy of the partition tables
from the disks. "fdisk" tools edit the on-disk copy of the partition tables. To update the
in-memory copies we need to run partprobe
# partprobe /dev/sda
03. Make filesystem
The filesystem is what organizes files on a device. The filesystem type used on Redhat
Enterprise Linux 6 is ext4. The following command will be used to make the filesystem (Format
the partition /dev/sda11)
# mkfs.ext4 /dev/sda11
04. Label the filesystem
This step is not required. but highly recommended. Filesystem labeling creates a layer of
abstraction that allows you to identify filesystem by a unique label rather then the device name.
labeling is done with the following command:
# e2label /dev/sda11 testlabel
2/5
RH135-Day12
Written by Rajib Shahriar Rubence
05. Create an entry in /etc/fstab
/etc/fstab is referenced each time the system boots to create the desired filesystem hierarchy. It
consists of six fields per line for each filesystem to be connected to the tree as follows:
# cat /etc/fstab
# device                  mount point             FS_type  Options    dump_freq  fsck_order
UUID=5022bbc4-1c7c-420e-81ee-c9567741566b /                       ext4    defaults        1         1
UUID=ebebbade-25b1-480a-90fc-f46cfbaf392f /boot                   ext4    defaults        1         2
UUID=811168ec-7439-46ab-bdb2-e19df6fe2b27 swap                    swap    defaults        0        
0
tmpfs                   /dev/shm                          tmpfs   defaults        0         0
devpts                  /dev/pts                          devpts  gid=5,mode=620  0         0
sysfs                   /sys                              sysfs   defaults        0         0
proc                    /proc                             proc    defaults        0         0
LABEL="testlabel"    /newdir                      ext4    defaults      0             0
In device name we can use either the device name (/dev/sda11) or "LABEL="testlabel" or UUID
(Universal Unique Identifier). to find the UUID run the following command
# blkid   (will show all partitions labeling and UUID)
# blkid /dev/sda11  (for specific partition)
06. Mounting the filesystem :
The filesystem cant be used to store and access data unless its not mounted . For mounting to
a new directory the following command should be invoked
# mkdir /newdir
# mount /dev/sda11 /newdir
Managing Simple Partitions and Filesystem:
Creating and Formating Simple Partition from Command Prompt
# fdisk -cu /dev/sda
3/5
RH135-Day12
Written by Rajib Shahriar Rubence
Some questions will be asked after this command. Do the following:
# p  --> Print the current partition table
# n  --> for new partition
# l  --> for logical partition
# First Sector --> Take the default Sector Number
# Last Sector:  +2GB ---> This will create 2 GB Partition
# p --> Check if new partition is created
# w --> Write (save) your work in partition table
Now aware the kernel about new partition
# partprobe /dev/sda
Reboot your machine
4/5
RH135-Day12
Written by Rajib Shahriar Rubence
check kernel is aware about the new partition
# cat /proc/partitions
Format the ext4 partition
# mkfs.ext4 /dev/sda11
configure the machine to automatically mount the partition on bootup
# mkdir /mountpoint
# vim /etc/fastab
/dev/sda11    /mountpoint    ext4     defaults    0 0
 
5/5
Zgłoś jeśli naruszono regulamin