Section 33.3. Filesystem (Topic 2.203)


33.3. Filesystem (Topic 2.203)

33.3.1. Review Questions

  1. What is the difference between the /etc/fstab and the /etc/mtab files?

  2. What is the meaning of the sixth field in the /etc/fstab file?

  3. Where would the following line appear, and what does it accomplish?

     cdrom   -fstype=iso9660,ro,sync,nodev,nosuid    :/dev/cdrom 

  4. What type of information is found in the /proc/mounts file?

  5. For a device named /dev/sda1, you wish to learn the last mount time, the maximum count of boot times that have occurred between checks by fsck, and the maximum mount counts. You know that some of the output may not be understood by the dumpe2fs command. What dumpe2fs option would you use to get this command to report all findings?

  6. What command flushes all data and writes it to disk?

  7. How can you see that an attempted copy using the dd command failed?

  8. You have tried to use the swapon command on a partition named /dev/hda3. This partition has the following entry in /etc/fstab:

     /dev/hda3       /            ext3    defaults,noauto,errors=remount-ro 0 

    What information in this line can help you identify the most likely problem?

33.3.2. Answers

  1. The /etc/fstab file shows the filesystems that will be mounted. The /etc/mtab file lists the filesystems that are mounted. In other words, /etc/fstab controls the behavior of the system, whereas /etc/mtab reflects the results.

  2. The sixth field of /etc/fstab determines the order that partitions (that is, filesystems) are checked when a system boots.

  3. The entry is part of the autofs configuration file. The entry automatically mounts the /dev/cdrom drive as a read-only device when a disk is inserted. SUID files are not mounted, and neither are device files. The filesystem type is iso9660, which is standard for CD-ROM devices.

  4. The filesystems that are currently mounted and active.

  5. dumpe2fs -f /dev/sda1.

  6. sync.

  7. The failed dd command issues an error code greater than 0 to standard error. An error message such as "No space left on device" may also be displayed.

  8. The noauto option precludes the use of the /dev/hda3 device as a swap file.

33.3.3. Exercises

  1. Use the cat command to view the contents of the /proc/mounts file. What do this file's contents have in common with the contents of the /etc/mtab file?

  2. Review the /etc/fstab file and take note of the syntax. Be able to identify the following:

    • The filesystem used

    • The mount point

    • The filesystem type

    • The options: be able to describe each one

    • The dump value

    • The pass number

    Familiarize yourself with each of the fields and their possible values.

  3. Use the less command to read the contents of the /etc/mtab file. Then use the badblocks command to look for problems on one of the Linux filesystems. Make sure that you unmount the partition first. For example, if you wanted to read the /dev/hda3 partition, you would issue the following commands:

     umount /dev/hda3 badblocks -o bad.txt /dev/hda3 

    The bad.txt file will contain a list of all bad blocks on the partition.

  4. Try out the dd command to copy the contents of a partition into a single file. Make sure that you have a large amount of disk space in the destination directory. Suppose you have a partition named /dev/hda3 that is 500 MB. You could write it to a single image (using a different partition) as follows:

     dd if=/dev/hda3 of=hda3.img 

    The following copies the contents of bootdisk.img to a floppy disk:

     dd if=bootdisk.img of=/dev/fd0 

  5. It is also important to know the options to dd. For instance, you can increase the block size to make writing faster and more efficient. Or you can specify the block size to copy only the data that you need. For example, to copy the boot sector from the /dev/hda device, you could tell dd to perform this operation once on the first 512 bytes:

     dd if=/boot/grub/stage1 of=/dev/fd0 bs=512 count=1 

  6. You can then tell dd to write the second stage onto the same floppy. This time, you will use the seek option, which tells dd to skip over the first 512 bytes, as specified in the bs option, and continue writing on byte 513 of the floppy:

     dd if=/boot/grub/stage2 of=/dev/fd0 bs=512 seek=1 

    Continue experimenting with the dd command, but be careful: a simple mistake can destroy all data on your drive or partition.

  7. On a system that has sufficient unused space, create a new 500-MB partition. Use the fsck command and create a type 82 partition. Next, use the mkswap command to make this space a swap file, for instance:

     mkswap -c /dev/hdb2 

    Now use the swapon command to activate the partition so that it can be used as RAM:

     swapon /dev/hdb2 

    Issue the swapoff command for the /dev/hdb2 partition. Use fdisk to re-create the partition. Then, use the mke2fs -j command to create an ext3 partition on it. Copy data to this new partition. If you want to keep it, update the /etc/fstab file to automatically mount it. If you wish, you can recreate the swap space and then update /etc/fstab to automatically mount it with the following line:

     /dev/hdb2       none            swap    sw              0       0 



LPI Linux Certification in a Nutshell
LPI Linux Certification in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596005288
EAN: 2147483647
Year: 2004
Pages: 257

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net