Bookmark this page

Guided Exercise: Practice: Adding Partitions, File Systems, and Persistent Mounts

In this lab, you will create an MBR partition on a newly allocated disk, format the partition with an ext4 file system, and configure the file system for persistent mounting.

Resources:
Machines: serverX

Outcomes:

1 GiB ext4 file system on second disk persistently mounted at /archive.

  • Reset your serverX system.

  • Log into serverX.

  • Switch to root using sudo -i.

You have been asked to archive data to a new directory, /archive, on serverX. You have been allocated a second disk for this purpose. The /archive directory will require 1 GiB of space. To make sure that the /archive directory is always available for use, you will need to configure the newly created file system to be persistently mounted at /archive even after a server reboot.

Once you have completed your work, reboot your serverX machine and verify that the newly created file system is persistently mounted at /archive after the reboot.

  1. Create a 1 GiB MBR partition on /dev/vdb of type Linux.

    1. Use fdisk to modify the second disk.

      [root@serverX ~]# fdisk /dev/vdb
    2. Display the original partition table, then add a new partition that is 1 GiB in size.

      Command (m for help): p
      
      Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
      Units = sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      Disk label type: dos
      Disk identifier: 0xfd41a9d3
      
      Device Boot    Start      End   Blocks  Id  System
      
      Command (m for help): n
      Partition type:
         p   primary (0 primary, 0 extended, 4 free)
         e   extended
      Select (default p): p
      Partition number (1-4, default 1): 1
      First sector (2048-20971519, default 2048): Enter
      Using default value 2048
      Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +1G
      Partition 1 of type Linux and of size 1 GiB is set
      
    3. Save the partition table changes.

      Command (m for help): w
      The partition table has been altered!
      
      Calling ioctl() to re-read partition table.
      Syncing disks.
      
    4. If fdisk issues a warning, then run the partprobe command to make the kernel aware of the partition table change. This will not be necessary if the disk device is currently unused.

      [root@serverX ~]# partprobe
  2. Format the newly created partition with the ext4 file system.

    [root@serverX ~]# mkfs -t ext4 /dev/vdb1
    mke2fs 1.42.9 (28-Dec-2013)
    Filesystem label=
    OS type: Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    Stride=0 blocks, Stripe width=0 blocks
    65536 inodes, 262144 blocks
    13107 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=268435456
    8 block groups
    32768 blocks per group, 32768 fragments per group
    8192 inodes per group
    Superblock backups stored on blocks:
            32768, 98304, 163840, 229376
    
    Allocating group tables: done
    Writing inode tables: done
    Creating journal (8192 blocks): done
    Writing superblocks and filesystem accounting information: done
  3. Configure the newly created file system to persistently mount at /archive.

    1. Create the /archive directory mount point.

      [root@serverX ~]# mkdir /archive
    2. Determine the UUID of the new partition on the second disk.

      [root@serverX ~]# blkid /dev/vdb1
      /dev/vdb1: UUID="5fcb234a-cf18-4d0d-96ab-66a4d1ad08f5" TYPE="ext4"
    3. Add an entry to /etc/fstab.

      UUID=5fcb234a-cf18-4d0d-96ab-66a4d1ad08f5 /archive ext4 defaults 0 2
  4. Test mounting the newly created file system.

    1. Execute the mountcommand to mount the new file system using the new entry added to /etc/fstab.

      [root@serverX ~]# mount -a
    2. Verify that the new file system is mounted at /archive.

      [root@serverX ~]# mount | grep -w /archive
      /dev/vdb1 on /archive type ext4 (rw,relatime,seclabel,data=ordered)
  5. Reboot serverX. After the server has rebooted, log in and verify that /dev/vdb1 is mounted at /archive.

    [student@serverX ~]$ mount | grep ^/
    /dev/vda1 on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
    /dev/vdb1 on /archive type ext4 (rw,relatime,seclabel,data=ordered)
Revision: rh134-7-63a207e