20% of Exam
- Configure and manage LVM storage
- Manage and configure the virtual file system
- Create, manage, and troubleshoot filesystems
- Use remote filesystems and network block devices
- Configure and manage swap space
- Configure filesystem automounters
- Monitor storage performance
show commands
lsblk
sudo mkswap /dev/sdb
df -TH
swapon -h
swapon -s
10MB 21MB 15MB
sudo fdisk /dev/vdb
# m for menu
m
# n for new partition
n
# enter defaults and +10M for size
+10M
# w for writing the partition
w
mkswap /dev/vdb2
swapon /dev/vdb2
swapon -s
swapoff /dev/vdb2
cfdisk
-
List block devices:
lsblk
- Display information about all block devices on the system.
-
Create a swap area on
/dev/sdb
:sudo mkswap /dev/sdb
- Initialize the partition
/dev/sdb
as swap space.
- Initialize the partition
-
Check file system disk usage:
df -TH
- Show disk usage information for all mounted filesystems, with sizes in human-readable format and file system type.
-
Display active swap space:
swapon -h
- Show the currently active swap spaces in a human-readable format.
-
View detailed swap space information:
swapon -s
- Display detailed information about all swap spaces.
-
Open
fdisk
to partition/dev/vdb
:sudo fdisk /dev/vdb
- Open
fdisk
to manage partitions on/dev/vdb
.
- Open
-
Use
m
for the help menu infdisk
:m
- Display the help menu in
fdisk
.
- Display the help menu in
-
Create a new partition in
fdisk
:n
- Create a new partition.
-
Enter default values for the partition size and set it to
+10M
:+10M
- Set the size of the new partition to 10MB.
-
Write partition changes:
w
- Write changes and exit
fdisk
.
- Write changes and exit
-
Create a swap space on the new partition
/dev/vdb2
:mkswap /dev/vdb2
- Initialize
/dev/vdb2
as swap space.
- Initialize
-
Enable the new swap space:
swapon /dev/vdb2
- Activate the swap space on
/dev/vdb2
.
- Activate the swap space on
-
View swap space status:
swapon -s
- Display the status of active swap spaces.
-
Disable a swap space:
swapoff /dev/vdb2
- Disable the swap space on
/dev/vdb2
.
- Disable the swap space on
-
Open the
cfdisk
partition manager:cfdisk
- Start the
cfdisk
utility to manage disk partitions with a graphical interface.
- Start the
show commands
mkfs.xfs -L "DataDisk" /dev/vdb
mkfs.ext4 -N 2048 /dev/vdc
mount /dev/vdb/ /mnt
mount /dev/vdb/ /mnt/
lsblk
mount /dev/vdb /mnt/
umount /mnt
mkdir /test
sudo mano /etc/fstab
cat /etc/fstab
sudo nano /etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during curtin installation
/dev/disk/by-uuid/8ee8caa8-cef0-4e5c-a626-03f2a0f13c00 / ext4 defaults 0 1
/swap.img none swap sw 0 0
#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
#VAGRANT-END
/dev/vdc /test ext4 defaults 0 2
/dev/vdb none swap defaults 0 0
xfs_admin -L "SwapFS" /dev/vdb
-
Format a disk with XFS and label it:
mkfs.xfs -L "DataDisk" /dev/vdb
- Format
/dev/vdb
with the XFS file system and label it "DataDisk."
- Format
-
Format a disk with ext4 and specify the number of inodes:
mkfs.ext4 -N 2048 /dev/vdc
- Format
/dev/vdc
with the ext4 file system and create 2048 inodes.
- Format
-
Mount a disk to a directory:
mount /dev/vdb /mnt
- Mount the
/dev/vdb
device to the/mnt
directory.
- Mount the
-
List block devices and their mount points:
lsblk
- Display information about block devices and their mount points.
-
Unmount a device:
umount /mnt
- Unmount the device mounted at
/mnt
.
- Unmount the device mounted at
-
Create a new directory:
mkdir /test
- Create the directory
/test
.
- Create the directory
-
Edit the
/etc/fstab
file withnano
:sudo nano /etc/fstab
- Open the
/etc/fstab
file in thenano
text editor to manage filesystem mounts.
- Open the
-
View the contents of
/etc/fstab
:cat /etc/fstab
- Display the contents of the
/etc/fstab
file.
- Display the contents of the
-
Example entry for
/etc/fstab
:<file system> <mount point> <type> <options> <dump> <pass> /dev/disk/by-uuid/8ee8caa8-cef0-4e5c-a626-03f2a0f13c00 / ext4 defaults 0 1 /swap.img none swap sw 0 0 /dev/vdc /test ext4 defaults 0 2 /dev/vdb none swap defaults 0 0
-
Change the label of an XFS file system:
xfs_admin -L "SwapFS" /dev/vdb
- Change the label of the XFS file system on
/dev/vdb
to "SwapFS."
- Change the label of the XFS file system on
show commands
cat /proc/mounts
findmnt
findmnt /dev/vda1
umount /mnt
mount /dev/vdb1 /mnt/ -o ro,noexec,nosuid
mount -o remount,rw /dev/vdb1 /mnt
vi /etc/fstab
/dev/vdb1 /mnt ext4 defaults,ro 0 2
-
View currently mounted file systems:
cat /proc/mounts
- Display information about all mounted file systems from
/proc/mounts
.
- Display information about all mounted file systems from
-
Find mounted file systems:
findmnt
- Display a tree of mounted file systems.
-
Find where a specific device is mounted:
findmnt /dev/vda1
- Display the mount point for
/dev/vda1
.
- Display the mount point for
-
Unmount a device:
umount /mnt
- Unmount the device mounted at
/mnt
.
- Unmount the device mounted at
-
Mount a device with specific options:
mount /dev/vdb1 /mnt/ -o ro,noexec,nosuid
- Mount
/dev/vdb1
to/mnt
with read-only, no execution, and no SUID options.
- Mount
-
Remount a device as read-write:
mount -o remount,rw /dev/vdb1 /mnt
- Remount
/dev/vdb1
as read-write on/mnt
.
- Remount
-
Edit the
/etc/fstab
file:vi /etc/fstab
- Open
/etc/fstab
for editing to manage filesystem mounts.
- Open
-
Example
/etc/fstab
entry:/dev/vdb1 /mnt ext4 defaults,ro 0 2
- Mount
/dev/vdb1
to/mnt
with the ext4 file system in read-only mode.
- Mount
show commands
vi /etc/exports
/home 10.0.0.0/24(ro)
sudo exportfs -r
systemctl restart nfs-server
grep "/home" /etc/exports
mount 127.0.0.1:/home /mnt
vi /etc/fstab
127.0.0.1:/home /mnt nfs defaults 0 0
vi /etc/exports
/home 192.0.0.0/24(ro) 127.0.0.10(rw,no_root_squash)
exportfs -r
-
Edit the NFS exports file:
vi /etc/exports
- Open
/etc/exports
to configure NFS shared directories.
- Open
-
Example NFS export entry:
/home 10.0.0.0/24(ro)
- Share
/home
as read-only for the10.0.0.0/24
subnet.
- Share
-
Apply NFS export changes:
sudo exportfs -r
- Re-export all directories in
/etc/exports
without restarting the NFS service.
- Re-export all directories in
-
Restart the NFS server:
systemctl restart nfs-server
- Restart the NFS server to apply changes.
-
Verify NFS export configuration for
/home
:grep "/home" /etc/exports
- Search for
/home
in the/etc/exports
file to verify export configurations.
- Search for
-
Mount an NFS share locally:
mount 127.0.0.1:/home /mnt
- Mount the NFS share from
127.0.0.1:/home
to/mnt
.
- Mount the NFS share from
-
Edit
/etc/fstab
to mount NFS share automatically:vi /etc/fstab
- Open
/etc/fstab
to configure automatic mounting.
- Open
-
Example NFS
/etc/fstab
entry:127.0.0.1:/home /mnt nfs defaults 0 0
- Automatically mount the NFS share from
127.0.0.1:/home
to/mnt
at boot.
- Automatically mount the NFS share from
-
Add multiple NFS export rules:
vi /etc/exports
- Open
/etc/exports
to add multiple export rules.
- Open
-
Example multi-host NFS export entry:
/home 192.0.0.0/24(ro) 127.0.0.10(rw,no_root_squash)
- Export
/home
as read-only for the192.0.0.0/24
subnet and as read-write withno_root_squash
for127.0.0.10
.
- Export
-
Apply NFS export changes:
exportfs -r
- Re-export all configured directories without restarting the NFS service.
show commands
sudo apt install lvm2 -y
sudo lvmdiskscan
pvcreate /dev/vdb /dev/vdc
pvs
vi /root/pvsize
pvremove /dev/vdc
vgcreate volume1 /dev/vdb
vgextend volume1 /dev/vdc
vgreduce volume1 /dev/vdc
vgs
lvcreate --size 0.5G --name smalldata volume1
lvresize --size 752M volume1/smalldata
mkfs.xfs /dev/volume1/smalldata
sudo lvremove volume1/smalldata
-
Install LVM2:
sudo apt install lvm2 -y
- Install the LVM2 package for managing Logical Volume Management (LVM).
-
Scan disks for LVM physical volumes:
sudo lvmdiskscan
- Scan the system for available physical disks for LVM.
-
Create physical volumes:
pvcreate /dev/vdb /dev/vdc
- Initialize
/dev/vdb
and/dev/vdc
as physical volumes for LVM.
- Initialize
-
Display physical volumes:
pvs
- Show information about all physical volumes on the system.
-
Open a file for editing:
vi /root/pvsize
- Open
/root/pvsize
for editing (e.g., to save size info).
- Open
-
Remove a physical volume:
pvremove /dev/vdc
- Remove the LVM label from
/dev/vdc
and wipe the physical volume.
- Remove the LVM label from
-
Create a volume group:
vgcreate volume1 /dev/vdb
- Create a volume group named
volume1
using/dev/vdb
as the physical volume.
- Create a volume group named
-
Extend a volume group:
vgextend volume1 /dev/vdc
- Add
/dev/vdc
to thevolume1
volume group.
- Add
-
Reduce a volume group:
vgreduce volume1 /dev/vdc
- Remove
/dev/vdc
from thevolume1
volume group.
- Remove
-
Display volume groups:
vgs
- Show information about all volume groups on the system.
-
Create a logical volume:
lvcreate --size 0.5G --name smalldata volume1
- Create a logical volume named
smalldata
with a size of 0.5 GB in thevolume1
group.
- Create a logical volume named
-
Resize a logical volume:
lvresize --size 752M volume1/smalldata
- Resize the logical volume
smalldata
involume1
to 752 MB.
- Resize the logical volume
-
Format a logical volume with XFS:
mkfs.xfs /dev/volume1/smalldata
- Format the logical volume
smalldata
involume1
with the XFS file system.
- Format the logical volume
-
Remove a logical volume:
sudo lvremove volume1/smalldata
- Remove the logical volume
smalldata
from thevolume1
volume group.
- Remove the logical volume
show commands
# https://www.redhat.com/sysadmin/linux-access-control-lists
raid1 mirrored
cat /proc/mdstat
getfacl archive
# https://www.alibabacloud.com/help/en/ecs/use-cases/create-a-raid-array-for-a-linux-instance#:~:text=Run%20the%20mdadm%20command%20to,based%20on%20your%20business%20requirements.&text=If%20you%20are%20prompted%20that,to%20install%20the%20mdadm%20tool.
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/vd[bc]
lsblk
setfacl --modify user:john:rw specialfile
setfacl --remove user:john specialfile
setfacl --modify group:mail:rx specialfile
setfacl --recursive --modify user:john:rwx collection/
-
Check RAID status:
cat /proc/mdstat
- Display the current status of RAID arrays and devices.
-
View access control lists (ACLs) of a file:
getfacl archive
- Show the ACLs for the file
archive
.
- Show the ACLs for the file
-
Create a RAID 1 (mirrored) array:
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/vd[bc]
- Create a RAID 1 array using two devices (
/dev/vdb
and/dev/vdc
) and name it/dev/md0
.
- Create a RAID 1 array using two devices (
-
List block devices:
lsblk
- Display information about block devices in a tree format.
-
Modify ACLs to give user
john
read and write permissions:setfacl --modify user:john:rw specialfile
- Grant read and write permissions to the user
john
on the filespecialfile
.
- Grant read and write permissions to the user
-
Remove ACLs for user
john
:setfacl --remove user:john specialfile
- Remove ACL entries for the user
john
onspecialfile
.
- Remove ACL entries for the user
-
Modify ACLs to give the group
mail
read and execute permissions:setfacl --modify group:mail:rx specialfile
- Grant read and execute permissions to the group
mail
onspecialfile
.
- Grant read and execute permissions to the group
-
Recursively modify ACLs to give user
john
read, write, and execute permissions:setfacl --recursive --modify user:john:rwx collection/
- Recursively grant read, write, and execute permissions to the user
john
on thecollection/
directory and its contents.
- Recursively grant read, write, and execute permissions to the user