M01: Introduction to Operating Systems
TU1: Installing, configuring and exploiting a computer system
ASIX1
Practical. Exercise 11a: Working with File Systems 10-2-20

Practical Exercise 11a:  Working with File Systems

GENERAL CONDITIONS
1- Deadlines ASIX1: 
    a) PART 1 (1 hour session): 11-2-2020    17:45PM   
    b) PART 2: (1hour session): 11-2-2020    19.15PM   

    c) PART 3: (1 hour session): 17-2-2020   19:15PM

2- Deadline DAW1      
    a) PART 1 (1 hour session): 14-2-2020    15:45PM   
    b) PART 2: (1hour session):  20-2-2020    15:45PM   

    c) PART 3: (1 hour session): 20-2-2020    16:45PM


DOCUMENTATION ABOUT WORKING WITH FILE SYSTEMS

1- Partitioning a secondary storage device (drive) : GParted, fdisk and gdisk

a)
You can create and manipulate partitions with the following secondary storage devices (or drives):
b) You can not create and manipulate partitions with any kind od optical storage device such as CD, DVD or Blu-rays.

c) Typical partition managers:
d) Working with fdisk:

e) Working with gdisk:

2- Building (or installing) a filesystem on a hard disk partition: Gparted, mkfs and mkswap

a) Typical programs and command to build filesystems:
b) Working with mkfs:
c) Working with mkswap:

3- Mounting and unmounting a filesystem found on a hard disk partition or. Enabling a disabling a SWAP partition


3.1- Working with mount


a) Description: The mount command serves to attach the filesystem found on some device to the Linux directory structure.

b) Synopsis:  mount  -t  filesystem  device  mountpoint
   
c) Typical filesystems:
    * For Windows --> vfat (fat32), ntfs
    * For Linux Linux --> ext2, ext3 and ext4
       
d) Typical devices:
    * For hard disks and USB drives --> sda1, sda2,........sdb1,.....
     
e) Typical mountpoints:
    *  Any folder in /media
    * Any folder in /mnt

f) Examples:
   * Example 1:   mount  -t  vfat  /dev/sdb1  /media/usb  --> Attaching a FAT32 filesystem build on /dev/sdb1 to the /media/usb folder. 
  
* Example 2:   mount  -t  ext4  /dev/sdc2  /mnt/disk  --> Attaching a Ext4 filesystem build on /dev/sdc2 to  /mnt/disk folder. 

3.2- Working with umount

a) Description: The umount command detaches a filesystem from the Linux directory structure.

b) Synopsis 1:  umount  device

c)
Synopsis 2:  umount  mountpoint
 

d) Examples
    * Example 1:   umount  /dev/sdb1 --> Detach /dev/sdb1 from the Linux directory structure
    * Example 2:   umount  /media/usb --> Detach /dev/sdb1 from the Linux directory structure


3.3- Working with swapon and swapoff

a) Description: The swapon command enables a SWAP partition  or show a list of enabled swap partitions. The swapoff command disables a SWAP partition.

b) Synopsis 1: swaponswapon  device  --> Enables a SWAP partition

c)
Synopsis 2: swaponswapon  -s --> Show a list of enabled SWAP partition

d)
Synopsis 3: swapoff:  swapoff  device --> Disables a SWAP partition
 

e) Examples
    * Example 1:   swapon  /dev/sdb1 --> Enable the SWAP filesystem build on  /dev/sdb1.
    * Example 2:   swapoff /dev/sdb1 --> Disable the SWAP filesystem build on  /dev/sdb1.
    * Example 3:   swapon -s  --> Show a list of enabled swap partitions, size, priority and used space.

4- Some useful commands

4.1- Show the disk usage of files and folders: du

a) Description: Shows the real disk usage of a file or directory. In other words, the disk space allocated to store such file or directory. Works recursively for directories. By default, du  displays the number of 1K-blocks allocated by the system to a file or directory. 

b) Important: Be careful, because file size and disk usage could be diferent. For instance, if you are working with a partition where a block size equal to 4096 was set and you have created a file whose size is 7432 bytes, the command du will show a disk usage of 8 (8KiB or 8192 bytes).

c) Useful options:
    -s --> Summarize: Display only a total. Particularly interesting for directories.
    -h --> Human readable: Print sizes in human readable format (K,M,G..)

d) Examples:
    *  du  -h /etc/passwd  -->  Show disk usage of  /etc/passwd  in a human readable format.
    *  du  -sh  /etc  --> Show the  summarized disk usage of /etc in a human readable format.
   

4.2- Show the disk usage of files and folders (user-friendly): ncdu

a) Description: It is a curses-based, fast and user-friendly version of du. It is a really useful and poweful command. It analyses any directory on your system and you can easily navigate from one directory to another directory using the arrow keys.

b) Important: In order to install ncdu run  aptitude install ncdu as the root user.

c) Examples:
    * ncdu  /home  --> Analyse and show information about the /home directory.
    * ncdu / -->  Analyse and show information about the / directory.

d) Use the arrow keys to navigate, press ? for help and q to quit.

4.3- Display a detailed report for each mounted file system: df

a) Description: The df  command allows you to display a detailed report on the disk space usage for each mounted filesystem. The command displays the filesystem name, filesystem type, size, how much space is used, how much space is still available, the percentage of space usage, and where is the file system mounted.

b) Useful options:
    -T --> Print filesystem type (ext4, vfat,...)
    -h --> Human readable: Print sizes in human readable format (K,M,G..)

c) Examples: df  -Th

PRACTICAL EXERCISE


PART 1

NOTE: Questions written in red characters are those you have to show on your terminal the moment we check your exercise at classroom

1.- Shutdown your system. Create a new SATA hard diska with the following characteristics:
     a) Hard drive file type: VDI
     b) Dinamically allocated
     c) Name: disk01
     d) Size: 20GiB
     e) 
Attached to  SATA 1
   

2.-  Install lsscsi.
List SCSI/SATA device attached to your system.

3.- Run gdisk on /dev/sdb and:
    a
) Create a new  GPT partition table on the selected disk.
    b) Create a primary - 10GB - NTFS (Microsoft basic data).
    c)
Create a primary - 9GB - Linux  partition.
    d)
Create a primary - Free space left - Swap  partition
    e) Show the /dev/sdb partition table
information (partitions, size, number of blocks and supposedly installed file system type).

4- Build the following filesystems:

    a) NTFS filesystem on the first partition of /dev/sdb
    b) Ext4
filesystem on the second partition of /dev/sdb
    c) Swap
filesystem on the third primary partition of /dev/sdb

5.- Mount the following filesystems:
    a)
The NTFS file system installed on the first partition of  /dev/sdb on a new directory called /mnt/disk01/ntfs.
    b)
The Ext4 file system installed on the second partition of  /dev/sdb on a new directory called /mnt/disk01/ext4. 

6- Enable the swap filesystem build on the third primary partition of /dev/sdb.

7.- Display a detailed report on the disk space usage for each mounted filesystem.

8-  Show a list of enabled swap partitions, size, priority and used space.


PART 2

NOTE: Questions written in red characters are those you have to show on your terminal the moment we check your exercise at classroom

1.- Shutdown your system. Create two new SATA hard diska with the following characteristics:
     
a) Hard drive file type: VDI
      b) Dinamically allocated
      c) Name: disk02
      d) Size: 20GiB
      e) 
Attached to  SATA 2

2.-  Install lsscsi.
List SCSI/SATA device attached to your system.

3.- Run  fdisk on /dev/sdc and:
   
a) Create a new  MBR (DOS) partition table on the selected disk.
    b) Create a primary / 10GB / Linux / Boot partition
    c)
Create an extended / 9GB partition
   
d) Create a primary - Free space left - Swap  partition
    e) Create a logical / 7GB / NTFS partition
    f
) Create a logical -  - Free extenden partition space left - FAT32 partition   
    g) Show the /dev/sdc partition table information (
partitions, size, number of blocks and supposedly installed file system type).

4- Build the following filesystems:
    a) Ext4 filesystem on the first primary partition of /dev/sdc
   
b) Swap filesystem on the third primary partition of /dev/sdc
    c)
NTFS filesystem on the first logical partition of /dev/sdc
    d) FAT32
filesystem on the second logical partition of /dev/sdc 

5.- Mount the following filesystems:
    a
) The Ext4 file system installed on the first partition of  /dev/sdc on a new directory called /mnt/disk02/ext4.
    b) The NTFS file system installed on the first logical partition of  /dev/sdc on a new directory called /mnt/disk02/ntfs.
    c)
The FAT32 file system installed on the second logical partition of  /dev/sdc on a new directory called /mnt/disk02/fat32.

6- Enable the swap filesystem build on the third primary partition of  /dev/sdc.

7.- Display a detailed report on the disk space usage for each mounted filesystem.

8-  Show a list of enabled swap partitions, size, priority and used space.


PART 3

NOTE: Questions written in red characters are those you have to show on your terminal the moment we check your exercise at classroom

1.- Mount the following filesystems:
    
a) The NTFS file system installed on the first partition of  /dev/sdb on  /mnt/disk01/ntfs.
     b
) The Ext4 file system installed on the first partition of  /dev/sdc on /mnt/disk02/ext4.
     c) Enable the swap filesystem build on the third primary partition of  /dev/sdc.

2.- Display a detailed report on the disk space usage for each mounted filesystem.

3-  Show a list of enabled swap partitions, size, priority and used space.

4- Umount:
    a) The NTFS file system mounted in question 1.a
   
b) The Ext4 file system mounted in question 1.b
    c) Disable
the swap filesystem on the third partition of  /dev/sdc.

4.- Display a detailed report on the disk space usage for each mounted filesystem.

5.-  Show a list of enabled swap partitions, size, priority and used space.

6.- Show the summarized disk usage of /var and /home in a human readable format.

7.- Show the total,  /var and /var/log disk usages with the help of ncdu.