Lab 7 - Creating and Mounting File System

.pdf
School
Post University**We aren't endorsed by this school
Course
GEO 510
Subject
Computer Science
Date
Jan 4, 2025
Pages
7
Uploaded by ChefWren8422
ITP3901 Operating Systems Fundamentals 30 @HKIIT 2024 Lab 7 - Creating and Mounting File SystemModule Intended Learning OutcomePerform system management tasks by using both command line interface and GUI. Lesson Intended Learning OutcomeManage disk in Linux. Note: Before turning on the Virtual Machine, Edit Virtual Machine Settings to add a secondary SCSI hard disk with a size of 8G. In this lab section, we will create partitions and file systems in the new hard disk, making them accessible to your system. Examining the partitions in disk, sda IDE and SCSI drives need to be partitioned before a file system can be created. fdiskis used to manipulate partition information. 1.Login as root2.Use fdiskcommand to examine the disk, you can easily corrupt the partition tables and the data on the disk. Start the fdiskcommand supplying as an argument the correct disk name you want to manipulate. The pcommand in fdiskwill print out the partition table information. fdisk /dev/sda when prompted "Command (m for help):", type pHow many partitions are there? _____[1]_____ What are the device names? _____[2]_____ Which partition has the largest size and what is the size of it? _____[3]_____ 3.Use qcommand to quit fdiskas you are not expected to make any change in /dev/sda.
Background image
ITP3901 Operating Systems Fundamentals 31 @HKIIT 2024 Create Linux partitions 1.Use fdiskcommand again to examine the newly added 8GB hard disk. fdisk /dev/sdb Is there any partition with the Disk2 (Y/N)? _____[4]_____ Which command in fdiskis used to display help? _____[5]_____ 2.To create a partition in Disk2, use ncommand in fdisk. Take pcommand action to create primary partition and 1for the 1st partition with the size of approximate 4G (type +4000Mas input for Last cylinder.) 3.Similarly, (do it on your own) create the 2nd partition in Disk 2 with the size of approximate 2G.
Background image
ITP3901 Operating Systems Fundamentals 32 @HKIIT 2024 4.Then create the 3rd partition as an extended partition (use ecommand action). The size of it will be the remaining size of Disk2 (use default for last cylinder). 5.In the extended partition, create one logical drive (/dev/sdb5) with the size of 512M. 6.Type pkey at fdiskprompt to view partition table information. You should see the following: 7.Convert the logical partition to Linux swap. Note from preceding output that the default type for new partitions created with fdiskis 83(Linux); to change this, you can type the tkey at the fdiskprompt. To change the /dev/sdb5partition to Linux swap, you can do the following:
Background image
ITP3901 Operating Systems Fundamentals 33 @HKIIT 2024 8.Type pkey at fdiskprompt to view the change. (If you make any mistakes in partitioning the secondary hard disk, you should use q key at fdiskprompt to re-do the above steps.) Finally, to save partition changes to the hard disk, use wkey at the fdiskprompt. As a summary, see the device names below for the partitions in Disk2. (tick lab with this screen shown to your lecturer, 1/2) Create Linux File System 1.Create a new Linux ext2file system on /dev/sdb1. It is needed to specify the type as ext2. The mkfscommand will destroy any existing data on the partition. mkfs -t ext2 /dev/sdb1 Note: The -t ext2″is optional as it can be auto-detected by the system.
Background image
ITP3901 Operating Systems Fundamentals 34 @HKIIT 2024 2.To use the new file system, we need to mount it somewhere under the root directory (/). Suppose the mount point is /data1. As the directory /data1does not exist, use the following command to create it and mount it. mkdir /data1 mount -t ext2 /dev/sdb1 /data1 3.Now, the new ext2file system is ready to use. It can be accessed via the directory /data1. cd /data1 *Try to create a text file, myfile.txt by using vieditor. contents: I like Linux commands. Linux commands are for experts. 4.Type ls -l /data1 to examine the /data1directoryWhat is the output of the above command? _____[6]_____ What is the output of this command df -m /data1 ? _____[7]_____ 5.To allow the system to mount this filesystem automatically at each boot, simply edit /etc/fstabfile and add the following entry for /dev/sdb1. /dev/sdb1 /data1 ext2 defaults 1 2 What are the meanings of the last two fields in /etc/fstab? (Use man fstab to check) The fifth (second last) field: _____[8]_____ The sixth (last) field: _____[9]_____
Background image
ITP3901 Operating Systems Fundamentals 35 @HKIIT 2024 6.Create a new Linux ext3 file system on /dev/sdb2. The mkfscommand will destroy any existing data on the partition. mkfs -t ext3 /dev/sdb2 Note: You may also use ″mke2fs -j /dev sdb2″ to create ext3 system.7.To use the new file system, mount it to /data2. As the directory /data2does not exist, suggest the commands to create this directory. _____[10]_____ State the command to mount /dev/sdb2 to /data2 as ext3system. _____[11]_____ 8.Type df -m /data1 /data2to check disk space usage. (tick lab 2/2) 9.Use the new ext3file system by adding the following files to /data2cd /data2 touch mynewfile1.txt mynewfile2.txt ls -l /data2 Can you create those two files? (Y/N)? _____[12]_____ 10.Reboot your system, login as student01(password: student01). Check the contents of /data1and /data2. ls -l /data1 /data2 Why are those two newly created files (mynewfile1.txtand mynewfile2.txt) not in /data2? ____[13]____
Background image
ITP3901 Operating Systems Fundamentals 36 @HKIIT 2024 Adding Additional Swap Space Sometimes, it is necessary to add additional swap while the system is running. We will configure and add additional swap space to the system. 1.Login as root. 2.Review the swap space in the system with the command cat /proc/swapsWhat is the output of the above command? _____[14]_____ 3.The mkswapcommand sets up a swap area on a device or a file. mkswap /dev/sdb5 4.Use swaponcommand to add the pre-configured swap space to the system. swapon /dev/sdb5 5.The -soption to swaponshows the swap space of the system. (Similar to cat /proc/swaps) Type swapon -s, what is the output? _____[15]_____ 6.The swapoffcommand removes the swap space from the system swapoff /dev/sdb5 --- end ---
Background image