Learning to create file systems and persistently mount them across reboots is an essential skill for Linux administrators. In this lab, we format two new system disks and create filesystems on the newly-created disk partitions. Then we create the directories for the mount points and configure `/etc/fstab` to persistently mount the file systems so they are available on system startup.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Log in to the Lab Server and Gain `root` Access
# sudo -i
- Format `xvdb`
List the available system disks and format
/dev/xvdb
. Entern
fornew partition
,p
forprimary
, and take the defaults. Typew
to write the changes to the system.# lsblk # fdisk /dev/xvdb Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0xae23de7b. 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): First sector (2048-4194303, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-4194303, default 4194303): Using default value 4194303 Partition 1 of type Linux and of size 2 GiB is set Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
- Create the File System and Directory for `dbadmin`
# mkfs.xfs /dev/xvdb1
# mkdir /dbadmin
- Configure `xvdb1` to Be Persistently Mounted
Configure
/etc/fstab
to persistently mount the/dbadmin
file system as read-only. Mount the file system, verify it mounted successfully, and test creating a file in that directory.# blkid /dev/xvdb1
# vim /etc/fstab UUID:<YOURDEVICESUUID> /dbadmin xfs ro,defaults 0 0
# mount -a # df -h # cd /dbadmin # touch test touch: cannot touch ‘test’: Read-only file system
- Format `xvdc`
List the available system disks and format
/dev/xvdc
. Entern
fornew partition
,p
forprimary
, and take the defaults. Typew
to write the changes to the system.# lsblk # fdisk /dev/xvdc Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0xae23de7b. 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): First sector (2048-4194303, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-4194303, default 4194303): Using default value 4194303 Partition 1 of type Linux and of size 2 GiB is set Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
- Create the File System and Directory for `www`
# mkfs.xfs /dev/xvdc1
# mkdir /www
- Configure `xvdc1` to Be Persistently Mounted
Configure
/etc/fstab
to persistently mount the/www
file system. Mount the file system and verify it mounted successfully.# blkid /dev/xvdc1
# vim /etc/fstab UUID:<YOURDEVICESUUID> /www xfs defaults 0 0
# mount -a # df -h