Home > Uncategorized > Creating AWS Git Repository Volume

Creating AWS Git Repository Volume

See my previous post AWS Git Repository with Alestic Gitolite for creating an AWS Git Repository

I place my Git repositories on a seperate EC2 Volume for three reasons:

1. Make backup of the repositories easier vs backing up the entire Git server vai EBS Snapshots.
2. Make migrating the repositories to a new EC2 instance easier.
3. Make increasing the size of the repository volume easier.

Create the EBS volume. Be sure to select the same Zone as where you created your Git instance. The volume size should be larger then the amount of your repository data with acceptable growth space. After creation, edit the Name tag and call it “Git Repositories”.

Attach the volume to your Git instance. If you already have additional volumes attached you will need to change the default Device:

/dev/sdf

Simply make it /dev/sdg. The Alestic Git Server Ubuntu instance I’m using will automatically map that device to another device name, I’ll show you have to discover that name shortly. It may take a few minutes for the volume to attach to the instance.

Here’s a good Ubuntu post on InstallingANewHardDrive

SSH into your server. Follow the above documentation, or what I’ve written below.

To discover the device name:

sudo fdisk -l

Disk /dev/xvda1: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/xvda1 doesn't contain a valid partition table

Disk /dev/xvdf: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders, total 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/xvdf doesn't contain a valid partition table

By default you should see your system volume /dev/svda1. You should also see a second volume /dev/xvdf (ifyou have more than one volume attached, it will be named differently – make note and replace appropriately in the following commands)

Create a new partition using fdisk:

sudo fdisk /dev/xvdf

Create a new (n) primary (p) number (1) default first sector / default last sector finally write (w)

The new partition will be named /dev/xvdf1 . Note the 1 to indicate the first partition.

Format the partition:

sudo mkfs -t ext4 /dev/xvdf1

Create a temporary mount point and allow write:

cd /mnt/
sudo mkdir repositories
sudo chmod 777 repositories

Mount the new volume

sudo mount /dev/xvdf1 /mnt/repositories

Disable access to Git.

Switch user to git and copy existing repositories into new volume and exit back to ubuntu user deleting the temporary mount point.

sudo su git
cd repositories
cp -R /home/git/repositories/* .
exit
sudo umount /dev/xvdf1
sudo rm -R repositories

You can at this point delete the old repositories in the /home/git/repositories folder, but I’ll leave that as an exercise for the user. Next we will mount the new volume in /home/git/repositories.

Edit fstab:

sudo nano /etc/fstab

Add the following line:
/dev/xvdf1 /home/git/repositories ext4 defaults 0 2

Mount the volume

sudo mount -a

Change ownership of the volume to user git:

sudo chown git:git /home/git/repositories

At this point reboot the server and verify. Reenable access to Git.

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. September 21, 2012 at 2:48 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: