Linux certification-chapter5(study notes)

in #studies2 years ago

linux.PNG

linux ch5.PNG

Linux filesystem administration

The /dev directory

• Device files are found in the dev directory, they are disks, terminals and serial ports, one file per device
• Character devices transfer information character-by-character.
• Block devices transfer information chunks of blocks at a time, these transfer faster and are CDs DVDs USBs and disks(HDD SSD)
• To look what type of device file use ls -l and look for the c or d character
• Check table 5-1
• Major number points to the device driver
• Minor number indicates the device or different partitions in HHDs and SSDs
• mknod command recreates the device file if you have the major and minor numbers.
• View contents of devices with /proc/devices file
• View block devices /sys/block
• View detailed information of block devices use lsblk command

Filesystems

• Journals keep track of changes made to the filesystem, journaling
• If the system loses power it can use this to complete changes
• Filesystem types:
• Check table 5-2
• Mounting:
• The process a disk is made accessible. They are attached to a mounting point
• Best practice is to make empty directories to mount on
• mount and umount commands

Working with USB flash memory drives

• lsusb command verifies USB is recognized
• mkfs command makes a new filesystem on the USB
• check table 5-3 for more commands
• df command is used to see a list of mounted filesystems
• a device will not mount if a user is using the directory to check if a user is use the fuser -u command to check.
• Umount command must be used before removing the device to avoid errors
• Check table 5-4

Working with CDs, DVDs, and ISO images

• Device files are different depending on the technology the drive uses (PATA, SATA, SCSI CD, DVD)
• You will need disc burning software to write data to the /dev/cdrom or /dev/sro
• Must be mounted with mount -r
• CDs and DVDs cannot be ejected until unmounted. Eject command
• To make an ISO image use mkisofs command

Working with removable media within a GUI environment

• Automatic mounting is done in /run/media/username directory
• The USB name will display in this directory after username.

Working with Hard Disks and SSDs

• 3 types: PATA, SATA and SCSI/SAS
• The second 2 are faster than PATA and have more connections.
• NVMes have different device files and can me divided into namespaces.
• Standard hard disk partitioning:
• It is good practice to use more than 2 partitions.
• Use segregation
• Hard disks have tracks which has sectors where the information is read off. See figure 5-4
• Check table 5-5
• Working with standard hard disk partitions:
• fdisk command to create a partition, use the m key for more prompts
• run the partprobe command if the fdik command needs to be reloaded manually or you can reboot the system
• alternatively, you can use the cfdisk command to fdisk. Reboot system after using this command
• use the mkswap command when preparing the partition and the swapon command to activate.
• If you are using GPT you can use gdisk to create and work with its partitions.
• The parted is used to create and modify MBR and GPT partitions
• After creating any partitions use the mkfs to format the partition with a file system or the mount command to add them to the directory tree.
• Working with the LVM:
• Logical volume manager creates logical volumes for mounting, they also allow you to add free space found anywhere on the computer.
• They contain: Physical volumes (PVs), unused partitions
• Volume Groups (VGs), groups of PVs
• Logical Volumes (LVs)
• See figure 5-8
• Create a PVS first to configure the LVM, use the pvcreate command
• The pvdisplay command displays info about the PVs
• Use the vgcreate command after creating PVs
• Be careful when making VGs, it is not safe to edit.
• Use the vgcreate command and note the physical extent(PE) size.
• Use lvcreat command in the VG space available.
• 3 other useful commands; pvscan, vgscan, lvscan

Monitoring filesystems

• Disk usage:
• Monitor the usage, if / filesystems falls below 10% free it can cause problems. Use df and -h command
• Move directories to free up space, use du command to see usage.
• Check your inodes are not used up, dumpe2fs -h command
• Checking filesystem for errors:
• Errors occur when the system is not shut down correctly. The data in the memory must be fully synced to the hard drive
• Damage to the hard drive platter is known as bad blocks
• Use fsck to scan for errors -f must be used for full scan
• See table 5-6
• Use the esfsck to check filesystems (ext2)
• Full system checks are forced when an ext2, ext3 or ext4 is mounted. The tune2fs -I command will set intervals between checks

Disk Quotas

• Restrict number of files created and usage of a user.
• Soft limits: limits with warnings for a period
• Hard limits: cannot exceed.
• See pages 263 to 266 for usage

Chapter summary:

credit: view image copyright details

• Disk devices are represented by device files that reside in the /dev directory. These device files specify the type of data transfer, the major number of the device driver in the Linux kernel, and the minor number of the specific device.
•  Each disk device must contain a filesystem, which is then mounted to the Linux directory tree for usage with the mount command. The filesystem can later be unmounted using the umount command. The directory used to mount the device must not be in use by any logged-in users for mounting and unmounting to take place.
•  Hard disks must be partitioned into distinct sections before filesystems are created on those partitions. To partition a hard disk with an MBR or GPT, you can use a wide Copyright 2020 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. Copyright 2020 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-202 CHAPTER 5 Linux Filesystem Administration 267 variety of tools including fdisk, cfdisk, gdisk, and parted.
•  Many filesystems are available to Linux; each filesystem is specialized for a certain purpose, and several filesystems can be mounted to different mount points on the directory tree. You can create a filesystem on a device using the mkfs command and its variants.
•  The LVM can be used to create logical volumes from the free space within multiple partitions on the various hard disks within your system. Like standard hard disk partitions, logical volumes can contain a filesystem and be mounted to the Linux directory tree. They allow for the easy expansion and reconfiguration of storage.
•  Most removable media devices are recognized as SCSI disks by the Linux system and are automounted by GUI environments.
•  It is important to monitor disk usage using the df, du, and dumpe2fs commands to avoid running out of storage space. Similarly, it is important to check disks for errors using the fsck command and its variants. •  If hard disk space is limited, you can use disk quotas to limit the space that each user has on filesystems.