Skip to content

Instantly share code, notes, and snippets.

@chhibber
Created January 27, 2017 14:54
Show Gist options
  • Save chhibber/5d40b4775580d3d17694d9a6006116f2 to your computer and use it in GitHub Desktop.
Save chhibber/5d40b4775580d3d17694d9a6006116f2 to your computer and use it in GitHub Desktop.
Mounting a larger workspace an EC2 slave system on boot

What your block devices look like before mapping:

ubuntu@cpu:~$ lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
xvda    202:0    0  100G  0 disk 
└─xvda1 202:1    0  100G  0 part /
ubuntu@cpu:~$ 

Under the instance configuration section, click on advanced and add the following to Block device mapping:

/dev/sdf/=:100

This assumes we are mounting sdf to the device /dev/xdvf and setting the drive size to 100G

Add the following to the user-data section in the jenkins ec2-plugin section of the instance:

#!/bin/bash

mkfs -t ext4 /dev/xvdf &&  mkdir /jenkins && mount /dev/xvdf /jenkins
chown -R ubuntu.ubuntu /jenkins

Set Remote FS root to /jenkins

Save the configuration and run a job uses this node. Create a test job to show the output of lsblk example output from my job:

root@cpu:~# lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
xvda    202:0    0  100G  0 disk 
└─xvda1 202:1    0  100G  0 part /
xvdf    202:80   0  100G  0 disk /jenkins
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment