2d: Disk Partitioning

In this module we learn how to partition hard disk

Task 1: Linux disk partitioning

By default, Redhat and Centos derivative Linux operating systems first create a disk partition called /boot, just for the bootloader files. Then for the remaining disk space, they use the Logical Volume Manager to create 2 logical volume groups called cl-root and cl-swap.


This allows the system to expand the size of the root drive as needed by simply adding more hard drives to the physical volume called “cl” in the above diagram

We have chosen in our configuration not to do this. After all, a USB hard disk is hard to expand any further!

What do you notice about the boot drive? Is it managed by the Logical Volume Manager?

Why do you think it is done this way?

(hint: Think about how can you boot before the LVM starts, or booting into single-user mode?)

On our lab image we have a simple 2 partition layout based on the BIOS MBR default partition layout.

First thing would be to check the current layout: Use the following command


mount

There’s a lot of output. Let’s filter it using grep to only show the lines that start with /dev:

mount | grep '^/dev/'

This tells you the device (hint: /dev/sda*) and where it is mounted on the file system hierarchy. Run the command:

df

This tells you the amount of free space in the mounted file system. You can use the –h option to show MB/GB.

Finally, try:

parted /dev/sda print

This should display your current partitions. To see what’s inside the logical volume, use:

lvs

To view more detail of the swap partition (like how much swap memory is currently being used), try:

swapon

Open two shell windows. In one of them, run the top command. Pay close attention to the swap space shown by top (the “MiB Swap” line). Run the following commands. Pause between each command and watch what happens.

swapoff –a

swapon –a



Windows Server Disk Management

Server Manager on Windows has a separate dashboard for managing ‘File and Storage Services’. Find it in the left-hand menu of Server Manager after your Windows Server boots. You should see four options: Servers, Volumes, Disks and Storage Pools. Start by choosing “Disks” and your window should look something like the following.

It shows that our system has a 60GB disk, with three partitions/volumes. The main volume is the one labelled “C:” which is the main OS hard drive.

Have a look around the way you did in Linux, and make notes in your journal about the partition structure.

If you used a spare USB flash drive to create partitions in Linux, let’s mount it here in Windows too (optional if you skipped that part in Linux because you didn’t have a spare flash drive).

Insert the USB drive into your computer. When prompted by VMware whether to connect it to the host or guest OS, connect it to the Windows Server virtual machine.

You’ll probably notice that in the File and Storage Services window, it doesn’t automatically appear. That’s OK. Near the top-right of the window you should find a menu labelled “TASKS”. From the tasks menu you can “Rescan Storage” and your USB flash drive should appear.

Your USB drive should now appear in the list of disks.

Note that it if it’s the same disk you used earlier, you can still see that some of the space is used. In our example, we used an 8GB flash drive (Windows shows capacity as 7.5GB), but it shows only 5.5GB unallocated. This is because we created 2 x 1GB partitions in Linux. Although Windows can’t read the filesystem types, it knows the partitions exist. How?

Let’s clear everything on this drive and start again. Right-click on the USB flash drive (choose carefully!) and select the “Reset disk” option. This will clear all existing partitions. How can you tell it worked?

Now right-click on the same drive again and choose “New Volume…”. A wizard appears. Follow it through and create a volume (partition) with drive letter “N” that uses all available space on the disk. Note that you could also assign it to a folder, which is a bit like a mount point in Linux.

Verify that your new N: drive exists, and its size.

The good news is that now your flash drive is back to being a normal Windows flash drive that you can use in other computers!

Managing disks on non-server Windows systems

The tool we have been using – File and Storage Services within Server Manager – is specific to Windows Server machines. It isn’t normally available on Windows desktops.

To manage disks and volumes on a Windows desktop machine, go into the Settings and search for “disk” and you should find the Windows disk management tool (“Create and format hard disk partitions”). You can do the same thing on your Windows Server.