This tutorial will cover adding an additional hard drive to your FOG server to store more images. We will do this by formatting and mounting the new hard drive on the FOG server, and then in the FOG server configuration we will create a second storage node configuration on the FOG server
[editor note] I don’t care for your wording here
In this example I’ve added an additional vmdk (hard drive) to my testing FOG server. In the example below this new hard drive is connected to the fog server as /dev/sdb
( note1: for testing I also added a 3rd vmdk just in case I needed it later. That one is mounted as /dev/sdc. That hard drive will not be used in this tutorial so you may ignore it for the rest of this document )
( note2: my testing fog server’s OS is Centos 7, so the instructions are going to be Centos centric. You should be able to translate them to other linux distributions pretty easy with a little Google-fu )
- First we’ll use lsblk to understand what block devices are connected to our fog server. You’ll notice that there are 2 “new” hard drives attached to my fog server without any partitions (sdb and sdc).
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 30G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 29.5G 0 part
├─centos-root 253:0 0 26.5G 0 lvm /
└─centos-swap 253:1 0 3G 0 lvm [SWAP]
sdb 8:16 0 40G 0 disk
sdc 8:32 0 50G 0 disk
sr0 11:0 1 1024M 0 rom
- Now lets create a partition on /dev/sdb using the fdisk command. I’m just going to post the keystrokes needed to create the partition using fidsk
fdisk /dev/sdb
And now the required keystrokes
n
p
1
<enter>
<enter>
w
The actual fdisk actions will look like this:
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.
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): 1
First sector (2048-83886079, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-83886079, default 83886079):
Using default value 83886079
Partition 1 of type Linux and of size 40 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
#
- Use the lsblk command to confirm the partition is now visible on /dev/sdb
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 30G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 29.5G 0 part
├─centos-root 253:0 0 26.5G 0 lvm /
└─centos-swap 253:1 0 3G 0 lvm [SWAP]
sdb 8:16 0 40G 0 disk
└─sdb1 8:17 0 40G 0 part
sdc 8:32 0 50G 0 disk
sr0 11:0 1 1024M 0 rom
- Now lets format the partition (/dev/sdb1)
mkfs.ext4 /dev/sdb1
[Editor note: maybe should consider xfs file system instead of ext4, because xfs handles huge files better]
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
2621440 inodes, 10485504 blocks
524275 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2157969408
320 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
- Next we will create a new mount point (directory) to attach our hard drive partition (/dev/sdb1) to.
mkdir /images2
- Edit the fstab so our new drive is mounted to our mount point every time we reboot the fog server.
vi /etc/fstab
- Insert this line at the bottom of the fstab
/dev/sdb1 /images2 ext4 defaults 0 1
- Use the df command to confirm the new drive is not connected (just to show a before and after example)
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 27G 9.5G 18G 36% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 8.6M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 497M 217M 281M 44% /boot
tmpfs 380M 0 380M 0% /run/user/0
- Notice that /dev/sdb does not appear in the printout above
- Tell the file system to mount all devices in the fstab. I’m doing it this way to ensure when the FOG server reboots that the drives are mounted correctly. We could use the mount command directly such as in
mount -t ext4 /dev/sdb1 /images2
. But that wouldn’t guaranty that we keyed things in right in the fstab file.
mount -a
- Now repeat the df command
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 27G 9.5G 18G 36% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 8.6M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 497M 217M 281M 44% /boot
tmpfs 380M 0 380M 0% /run/user/0
/dev/sdb1 40G 49M 38G 1% /images2
- Note that now we are mounting /dev/sdb1 to /images2
- Lets create the required directory structure on our new drive
mkdir /images2/dev
mkdir /images2/dev/postinitscripts
mkdir /images2/postdownloadscripts
cp /images/dev/postinitscripts/* /images2/dev/postinitscripts
cp /images/postdownloadscripts/* /images2/postdownloadscripts
touch /images2/dev/.mntcheck
touch /images2/.mntcheck
chown -R fogproject.root /images2
- We need to update/create our nfs shares for our new disk. The FOS engine will mount these shares to capture and deploy images.
- Use the showmount command to list the existing (current) shares
showmount -e 127.0.0.1
Export list for 127.0.0.1:
/images/dev *
/images *
- You will notice that we have both /images and /images/dev shares currently shared. Now we will add our /image2 directories to the share list. We will do this by editing the exports file (similar to the fstab file, but for shared directories)
vi /etc/exports
- Append the following lines to the end of the /etc/exportfs file:
Note: Ensure you update the fsid values if you copy and paste existing lines.
/images2 *(ro,sync,no_wdelay,no_subtree_check,insecure_locks,no_root_squash,insecure,fsid=3)
/images2/dev *(rw,async,no_wdelay,no_subtree_check,no_root_squash,insecure,fsid=4)
- Save and exit the editor
- Now tell the OS to reload the exports file.
exportfs -ra
- Rerun the showmount command to confirm we have our new drive shared
showmount -e 127.0.0.1
Export list for 127.0.0.1:
/images2/dev *
/images2 *
/images/dev *
/images *
- That concludes the operating system setup steps. Refer to Part 2 For the FOG server configuration to finish the setup.