Week 2 Learning Journal
SSH and File System Mount Information
SSH
- SSH Layers:
- SSH operates on three layers:
- Transport layer
- Authentication layer
- Communication layer
- SSH operates on three layers:
- CLI Usage:
- SSH is commonly used via the command-line interface (CLI) for secure remote access to servers.
- Key-Based Authentication:
- SSH authentication often involves the use of key pairs, consisting of a private key and a corresponding public key.
- Sudo User and Package Management:
- In Linux, the
sudocommand is used to execute commands with superuser privileges. - Package management commands like
dnf,yum, andaptare often used withsudoto install, remove, or update software packages.
- In Linux, the
Docker, Vagrant, and Containers
- Learning About:
- Docker and Vagrant are tools used for containerization and virtualization, respectively.
- Containers provide a lightweight and portable way to package and deploy applications.
Chapter 2: Displaying File System Mount Information
- Command Usage:
- Various commands can be used to display information about file system mounts and storage devices.
- Commands:
man mount: Displays the manual page for themountcommand, providing detailed information on its usage and options.mount | grep nvme: Filters mount information to display only entries related to NVMe devices.blkid: Prints block device attributes like UUID and file system type.lsblk: Lists information about block devices and their relationships.df: Displays disk space usage of file systems.df -h: Displays disk space usage in a human-readable format.vim /etc/mtab: Opens the mount table file/etc/mtabfor editing using the Vim text editor.
Day 2: Linux Filesystems
Commands and Tools
mountCommand:- Used to mount filesystems and displays information about mounted filesystems.
- Use
man mountto access the manual page for detailed information on themountcommand.
/etc/mtabFile:- Stores information about currently mounted filesystems.
- Use
mount | grep nvmeorcat /etc/mtab | grep nvmeto filter and display information about NVMe devices.
/proc/mounts:- Another file used to show information about mounted filesystems.
blkidCommand:- Prints block device attributes like UUID and filesystem type.
lsblkCommand:- Lists information about block devices, their partitions, and other details.
- Use
lsblk -fto display additional information.
fuserCommand:- Identifies processes using a specified file or filesystem.
- Use
fuser /mnt/backuporfuser -v /mnt/backupto check processes using a specific directory.
lsofCommand:- Lists open files and the processes that opened them.
- Use
lsof | headto display the first few lines of output orlsof | grep /mnt/backupto filter output for processes related to a specific directory.
mount -aCommand:- Mounts all filesystems listed in
/etc/fstab.
- Mounts all filesystems listed in
df -hCommand:- Displays disk space usage in a human-readable format.
- Editing
/etc/mtab:- Use
vim /etc/mtabto open the/etc/mtabfile for editing using the Vim text editor.
- Use
Day 3: Chapter 2 - Videos 2 to 6
Video 2
- Manually Mounting Filesystems:
- Use
umount /mnt/datato unmount a filesystem. - Use
fuserandlsofcommands to identify processes preventing a filesystem from being unmounted. fuser -vprovides more detailed information.lsof | headandlsof | grep /mnt/backupare used to list open files related to a specific directory.- Use
fuser -k mnt/backupto kill processes using a filesystem.
- Use
Video 3
- Automatic Mounting at Boot:
- When the system boots, it doesn’t automatically add entries into
fstab, so drives are not auto-mounted. - Use
mount -acommand to readfstaband mount filesystems listed there. - Use
lsblk -lto list block devices.
- When the system boots, it doesn’t automatically add entries into
syncCommand:syncflushes filesystem buffers.
Video 4
- Swap Space:
- Swap space is used as virtual memory when physical RAM is full.
- Typically, swap space is twice the amount of RAM.
- Use commands like
swapon -s,swapon --show, orcat /proc/swapsto view swap usage. freecommand displays memory usage.
- Systemd Mount Units:
- Systemd automatically creates mount units based on
fstabinformation. - Explore systemd mount units in
/run/systemd/generator.
- Systemd automatically creates mount units based on
Video 6 (Lab 1 of Chapter 2)
Learning Objectives:
- Create and enable a swap partition using
/dev/xvdg1. - Add an entry to
/etc/fstabto ensure the swap partition persists through a reboot (use the UUID). - Create and enable a 1 GB swap file in the root directory called “extraswap”.
- Add an entry to
/etc/fstabto ensure the swap file persists through a reboot (use the full path to the file name).
Lab: Working with Swap Space
Task 1: Creating and Enabling a Swap Partition
- Designating Swap Disk:
- Used
lsblkcommand to identify the swap disk. - Created swap space using
mkswap /dev/xvdg1. - Enabled swap space using
sudo swapon /dev/xvdg1. - Verified swap space using
swapon --show.
- Used
- Adding Entry to
/etc/fstab:- Edited
/etc/fstabusingvim /etc/fstab. - Added the UUID entry for swap partition and saved the file.
- Edited
Task 2: Creating and Enabling a Swap File
- Creating Swap File:
- Created a 1 GB swap file using
dd if=/dev/zero of=/extraswap bs=1M count=1024. - Checked file size using
ll -h /extraswap. - Restricted read access for others and granted only root write access using
chmod 600 /extraswap. - Designated the file as swap using
mkswap /extraswap. - Enabled the swap file using
swapon /extraswap. - Verified the swap file using
swapon --show.
- Created a 1 GB swap file using
- Adding Entry to
/etc/fstab:- Added the swap file entry to
/etc/fstabto ensure persistence through reboot.
- Added the swap file entry to
Lab: Working with Systemd Mount Units
Task 1: Creating a Unit File for Data Mount
- Creating Unit File:
- Used
lsblk -fto grab UUID for the data mount. - Created a unit file
mnt-data.mountin/etc/systemd/systemwith appropriate configuration. - Reloaded systemd using
systemctl daemon-reload. - Enabled and started the mount unit using
systemctl enable mnt-data.mount --now.
- Used
Task 2: Creating a Unit File for Backup Mount
- Creating Unit File:
- Similar steps as Task 1 for creating a unit file
mnt-backup.mount.
- Similar steps as Task 1 for creating a unit file
Task 3: Creating an Automount Unit File for Backup Mount
- Creating Automount Unit File:
- Created an automount unit file
mnt-backup.automountbased on provided instructions. - Enabled and started the automount unit using appropriate systemctl commands.
- Created an automount unit file
Chapter 4: Automatically Mounting File Systems with Autofs
Lesson 1: Introduction to Autofs
- Installation:
- Installed autofs package using
yum install -y autofs. - Enabled and started autofs service using
systemctl enable autofs --now. - Checked the status of autofs service using
systemctl status autofs.
- Installed autofs package using
- Configuration Files:
/etc/sysconfig/autofs: Global options for all mounts./etc/auto.master: Main configuration file with entries for mounts.
- Mount Points:
- Created mount points using
mkdir. - Configured indirect and direct mounts in
/etc/auto.master. - Created map files for indirect mounts.
- Created mount points using
Lesson 2: File System Types and Extensions
- File System Types:
- Discussed various file system types like ISO 9660, UDF, HFS.
- Explained ISO 9660 extensions: Rock Ridge, Joliet, El Torito.
Lesson 3: Data Encryption
- Installation:
- Installed cryptsetup package using
yum install -y cryptsetup.
- Installed cryptsetup package using
Lab: Working with Autofs
Learning Objectives:
- Install the
autofsPackage and Start and Enable theautofsService - Create an Indirect Mount at
/mnt/marketing - Create a Direct Mount at
/mnt/admin/data - Create a Direct Mount at
/mnt/user/data
Performing the Lab:
- Installation and Configuration:
- Installed autofs package and started/enabled the service.
- Created mount points for marketing, admin, and user data.
- Edited
/etc/auto.masterto include entries for mounts.
- Indirect Mount:
- Created an indirect mount for marketing data.
- Configured
/etc/auto.marketingfile with mount options.
- Direct Mounts:
- Configured direct mounts for admin and user data.
- Edited
/etc/auto.adminand/etc/auto.useraccordingly.
- Verification:
- Restarted autofs service and checked mount points using
df -handll.
- Restarted autofs service and checked mount points using
Additional Activities
Mounting and Formatting External Hard Drive
Identification and Confirmation
- Identifying Drive Name:
- Used
lsblkcommand to identify the name of the external hard drive. - Confirmed using
sudo blkid /dev/sdc1.
- Used
Formatting Process
- Formatting External Hard Drive:
- Used
sudo mkfs.fat -F 32 -n extdrive /dev/sdc1command to format the drive as FAT32 with label “extdrive”. - Verified the formatting using
sudo blkid /dev/sdc1.
- Used
Result
- Successful Formatting:
- Successfully formatted the external drive from NTFS to FAT32 file system.
Considerations
- File System Choice:
- Opted for FAT32 file system for compatibility with both Linux and Windows.
- Mentioned other file system options like exFAT, NTFS, or ext4 based on specific requirements.
- Alternative Tools:
This post is licensed under CC BY 4.0 by the author.


