Moving FOG's /images files off the root partition 2017 edition


  • Moderator

    Here is an updated tutorial that is related to this tutorial. https://forums.fogproject.org/topic/6642/moving-fog-s-images-files-off-the-root-partition

    Since that tutorial was written I’ve learned some new stuff and changed my opinion about how to go about protecting the root partition from uncontrolled growth. The goal is still to go about moving the uncontrolled files off the root partition, but now with virtual servers its easier to grow virtual disks if/when addition space is needed. The following is how I go about doing this today.

    currently under constructions

    Part 1 Steps to take if FOG is not installed (easier process)

    1. If you are using Ubuntu or other OS that utilize sudo exclusivly you may want to issue the following command to become root. This command gives you roughly the same power as disabling UAC on windows, so be wise about how you use it. sudo su -i Then enter your password. From now on, you are in “god mode”, so behave your self.
    2. Add a new virtual hard drive to the server. Size this new vmdk file appropriately for the number of images you plan on capturing. For my installation I make this new vmdk file 100GB in size.
    3. Reboot the server to sync the OS
    4. Now we need to locate this new drive. Since this is the second hard drive in the system it would probably be defined as /dev/sdb. Issue the lsblk command to show you the drive structure.
    lsblk
    NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
    sda      8:0    0 298.1G  0 disk 
    ├─sda1   8:1    0 294.3G  0 part /
    ├─sda2   8:2    0     1K  0 part 
    └─sda5   8:5    0   3.8G  0 part [SWAP]
    sdb      8:16    0 100.0G  0 disk 
    
    1. Now that we know our 100GB disk is sdb connected. Lets start to provision the disk.
    2. We’ll use fdisk to create a new partition on our new disk. This partition will consume the entire new virtual hard drive. I’m going to give the commands rapid fire here. Please look up the fdisk utility to understand exactly what each command will do. Make absolute sure you know which disk is your new disk, because there is a risk you could wipe out your fog server OS disk if you are just parroting commands.
    # fdisk /dev/sdb
    n
    p
    <enter 3 time>
    w
    
    1. With the physical partition created we can now format the disk. In this case I’m formatting the disk in the ext4 format. Remember to select the first partition on the new disk (sdb).
      mkfs.ext4 /dev/sdb1
    2. Next we will create a directory where we can mount this new disk. Key in the following commands.
      mkdir /opt/fogdisk
    3. Add the following line to your /etc/fstab file. This command will tell your linux OS to mount /dev/sdb1 on the /opt/fogdisk directory upon each reboot.
    /dev/sdb1 /opt/fogdisk ext4 defaults 0 1
    
    1. Save and exit the /etc/fstab file.
    2. With the fstab file updated, lets tell the OS to mount all, to test to ensure that our new drive is mounted on each reboot.
      mount -a
    3. Issue the df -h command to show you the mounted devices. You should see a line in the df output that looks similar to this:
      /dev/sdb1 99G 0G 99G 99% /opt/fogdisk
    4. Now we need to create a few directories FOG will use and remap them to the new disk we just mounted.
      mkdir /images
      mkdir /opt/fog
      mkdir /opt/fog/snapins
    5. Create the matching directories on our new disk.
      mkdir /opt/fogdisk/images
      mkdir /opt/fogdisk/snapins
    6. This is where the magic happens. We are going to use a special type of mount called a bind mount (MS Windows has a similar function called junction in NTFS).
    7. Lets update the /etc/fstab file again.
      Issue the df -h command to show you the mounted devices. You should see a line in the df output that looks similar to this:
      /dev/mapper/fog_disk-fog_files 99G 0G 99G 99% /opt
    /images /opt/fogdisk/images bind bind 0 0
    /opt/fog/snapins /opt/fogdisk/snapins
    
    1. Save and exit /etc/fstab
    2. Run the mount command again to connect these bind directories.
      mount -a
    3. Now test to ensure that everything is setup properly. We are going to create a file in /images and /opt/fog/snapins and then verify the files were created on the new disk.
    4. First we’ll create our test files.
      touch /images/image.chk
      touch /opt/fog/snapin.chk
    5. List the directories to ensure the files are on the new disk.
      ls -la /opt/fogdisk/images
      ls -la /opt/fogdisk/snapins
    6. Both of the above ls commands should have displayed the *.chk file. If they did then the bind mount is working correctly.
    7. Lets clean up our check files since they are no longer needed.
      rm /images/image.chk
      rm /opt/fog/snapin.chk
    8. At this point you can install FOG normally. The disk environment is setup so that the FOG installer will think all of the storage is on the root partition.

  • Moderator

    Part 2 Steps to take if FOG is already installed (bit more complicated process)

    do something else


  • Moderator

    (place holder)


  • Moderator

    (place holder)


  • Moderator

    (place holder)


Log in to reply
 

853
Online

39.3k
Users

11.0k
Topics

104.4k
Posts

Looks like your connection to FOG Project was lost, please wait while we try to reconnect.