In: Computer Science
Part I– Check your file system
Step 1: Execute the ls /dev/sd* command to see the current hard disk devices.
Step 2. Execute the fdisk -l command to list the current hard disk partitions
Step 3. Execute the parted -l command to list the current hard disk partition table.
Part II– Create a new virtual disk
Step 1. In the Oracle VM VirtualBox Manager program, create a new virtual hard disk with the size of 200 MB, and name it as “your_name.vdi” (for example, jbondsvdi).
Step 2. Load this virtual hard disk to your virtual machine.
Step 3. Repeat the steps in Part I, and highlight the differences
Part III– Creating Partitions and Filesystems
Step 1. Use the fdisk command to create a new primary partition on the new hard disk.
Step 2. Use the correct command to create an ext4 filesystem on the new partition.
Step 3. Repeat the steps in Part I, and highlight the differences
Step 4. Make a new directory named /cyse. And mount the new partition under this directory.
Step 5. Use the df command to check the mounting point of the new partition.
Step 6. Create a new file named file1.txt in the directory /cyse and put your name in that file
Step 7. Unmount /cyse directory.
Step 8. Check the contents in /cyse directory. What do you find?
Step 1: Execute the ls /dev/sd* command to see the current hard disk devices. We can see that no external drive is present right now in my system.
Step 2. Execute the fdisk -l command to list the current hard disk partitions. Right now it is showing the information about the default hard disk that is attached to the system while configuring it.
Step 3. Execute the parted -l command to list the current hard disk partition table. This command shows the partitions.
After creating the new virtual disk and loading it in the virtual machine, we can see changes when we run the above commands.
ls /dev/sd* shows one directory. This means that the external hard disk has been successfully loaded.
fdisk -l shows one new entry of the attached disk.
parted -l also shows a new entry.
Creating the partition on /dev/sda using the fdisk command.
Creating the ext4 filesystem on this partition using the mkfs.ext4 command.
Running the steps in Part 1 again. ls /dev/sd* shows that a new partition has been created.
fdisk -l shows a new entry of the partitioned drive.
parted -l also shows that a new partition has been created for the drive /dev/sda.
Making the /cyse directory and mounting it on the partition using mkdir and mount command.
Running the 'df' command shows our mounted partition. (last line of the output)
Now we write the name in /cyse/file1,txt file and verify it using the cat command. We can see the file is successfully created.
After unmounting /cyse and checking the contents we can see that it is empty. file1.txt cannot be seen here.
This is because the file was created after we mounted the partition. Therefore it is saved in the partition and not in the directory. If we again mount it, we will be able to see it.
You can consider the partition as a pen drive and mounting as attaching it to the system. When you create a file in the pen drive, it only remains there. After you remove it, you can't access the file. Same happens here.