Description: Candidates should be able to design a disk partitioning scheme for a Linux system.
Key Knowledge Areas:
◉ Allocate filesystems and swap space to separate partitions or disks.
◉ Tailor the design to the intended use of the system.
◉ Ensure the /boot partition conforms to the hardware architecture requirements for booting.
◉ Knowledge of basic features of LVM.
The following is a partial list of the used files, terms and utilities:
◉ / (root) filesystem.
◉ /var filesystem.
◉ /home filesystem.
◉ swap space.
◉ mount points.
◉ partitions.
Designing your file system disk layout
So it most certainly is possible to maintain your complete file system on a single partition and, for some systems, this may be the best layout. In general we want to separate out directories where data storage could be high and cause the file – system to fill. If the root file system becomes full then the server will not boot correctly.
During the install of many Linux distributions you may well be offered at least one if no more disk partitioning proposals. At the very least it will contain the root and swap partitions but may propose a separate home partition, for users’ home directories. You may also find a suggestion to partition up /boot separately, although small and will be rarely written to, the /boot directly holds the kernel and must be accessible to the boot loader.
Let’s take a look at a few directories that may benefit from being on a separate disk or partition.
◉ /boot : The /boot directory on a Linux device will hold the kernel and will need to be accessed by the boot loader. The boot loader often is GRUB (Grand Unified Boot Loader) or GRUB2 on new systems. Boot loaders are covered in detail in objective 102.2. The boot loader itself has a limited set of file systems that it may access so where you a more elaborate root file system such as btrfs having a separate file system for boot will allow you to format /boot with a simple file system like ext2. In this way the boot loader can access the kernel and the ram disk that will have the driver support to access the rot file system.
◉ /home : The home directories of standard users will be located in their own subdirectories below /home. If users store date here we can expect that this could grow. The contents may include mail files as well as the normal collateral consisting of music, jpegs from holidays and job applications. As administrators it is out job the keep the server running and we do not want a user causing the server to crash by downloading a movie into their home folder. Having a separate partition for /home will limit any disruption just to the users not to the system . We can also apply user quotas to each partition as it is mounted and using these tools we can limit how much each user can store under /home. Quotas are taught in objective 104.4.
◉ /var : The /var directory, variable data!. This can hold print spool files, log files, the RPM (software) database. Mail spool files may be located here. This certainly should be considered as a target for its own partition to protect the root file system from filling up. I have often seen servers that do not boot as a result of log files filling the root file system. This would not occur if /var was partitioned separately. On some systems administrators will add in the folders for the web server and ftp server underneath /var so space has to available to these services and not to detract from the root file system.
Partitioning your disk
Partitioning will work in the same way as we looked at for creating swap partitions. We can use fdisk on standard (MSDOS) disks or parted on standard or GPT disks. The partition type can be left at the default ID of 83. Using the command below we create a 99M partition, staring at 101M and finishing at 200M on the disk /dev/sdb; the second SCSI disk in this system, the disk SDA being the first in the system and disk SDB the second.
parted -a cylinder /dev/sdb mkpart primary 101 200
We can display the partitions with:
parted /dev/sdb print
We can then format the disk using mkfs so we can mount it. If we used mkfs.xfs we would format it with the XFS file system. Using mkfs -t xfs would achieve the same result.
mkfs.xfs /dev/sdb2
The previous command will format partition number 2 on the second disk (SDB) with the xfs file system.
Mounting your partition
To make the file system available as with swap we will need to mount the file system. In Linux the partition is mounted to a mount point. The mount point is just the target directory. This may be an existing directory or we can create a new directory. Linux will allow you to mount the file system to a directory with content but the original content is masked, or inaccessible until the partition is un-mounted again. So there is not point in mounting this partition to /home until I have copied the contents across to the new partition.
I can first create a directory /mnt/home and then mount the newly formatted partition to this directory. Using && to separate the two commands the mounting will only happened if the first command, creating the directory succeeds.
mkdir /mnt/home && mount /dev/sdb2 /mnt/home
Now we can use the copy command or rsync to copy the home directory contents to the mount point /mnt/home.
cp -aR /home/8 /mnt/home
ls /mnt/home
Now we can now delete the /home directory contents and use the empty home directory as the new mount point for /dev/sdb2. Take care in deleting content from the server.
rm -rf /home/* && umount /mnt/home && mount /dev/sdb2 /home
ls /home
Adding an entry to /etc/fstab will complete the exercise making the mount persistent.
/dev/sdb2 /home xfs defaults 0 2
0 comments:
Post a Comment