Moving FOG's /images files off the root partition 2017 edition
-
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)
- 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. - 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.
- Reboot the server to sync the OS
- 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
- Now that we know our 100GB disk is sdb connected. Lets start to provision the disk.
- 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
- 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
- Next we will create a directory where we can mount this new disk. Key in the following commands.
mkdir /opt/fogdisk
- 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
- Save and exit the /etc/fstab file.
- 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
- 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 - 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
- Create the matching directories on our new disk.
mkdir /opt/fogdisk/images
mkdir /opt/fogdisk/snapins
- 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).
- 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 bind bind 0 0 /opt/fog/snapins /opt/fogdisk/snapins
- Save and exit /etc/fstab
- Run the mount command again to connect these bind directories.
mount -a
- 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.
- First we’ll create our test files.
touch /images/image.chk
touch /opt/fog/snapins/snapin.chk
- List the directories to ensure the files are on the new disk.
ls -la /opt/fogdisk/images
ls -la /opt/fogdisk/snapins
- Both of the above
ls
commands should have displayed the *.chk file. If they did then the bind mount is working correctly. - Lets clean up our check files since they are no longer needed.
rm /images/image.chk
rm /opt/fog/snapin.chk
- 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.
- 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.
-
(place holder)
-
(place holder)
-
(place holder)
-
Part 2 Steps to take if FOG is already installed (bit more complicated process)
do something else
-
@george1421 said in Moving FOG's /images files off the root partition 2017 edition:
touch /opt/fog/snapin.chk
Tutorial worked like a charm! The is some minor errors as follows:
The following line needs bind bind 0 0 added
/opt/fog/snapins /opt/fogdisk/snapins bind bind 0 0and the Snapin test file needs to be in the right directory!
touch /opt/fog/snapins/snapin.chk -
@george1421 said in Moving FOG's /images files off the root partition 2017 edition:
/dev/mapper/fog_disk-fog_files 99G 0G 99G 99% /opt
At step 16, I do not get this printout from df -h as listed above. The directory /image and /snapin are linking to the /opt/fogdisk which is mapped to the new disk partition, but for some reason, the /opt/fogdisk/images and /snapin are mapped to the root partition. Any recommendations? Did I miss something?
When I run mount, I get the following:
/dev/xvdb1 on /opt/fogdisk type ext4 (rw,relatime)
/dev/mapper/ubuntu–vg–1-ubuntu–lv on /opt/fogdisk/images type ext4 (rw,relatime)
/dev/mapper/ubuntu–vg–1-ubuntu–lv on /opt/fogdisk/snapins type ext4 (rw,relatime) -