Decrease volume size of EC2
Create a smaller volume
Go to EBS volumes
Click Create Volume
Choose the volume type (same as previous)
Enter size; 30
Choose availability zone, same as the availability zone.
tag, new-volume
Attach the new volume
Right click on the new volume
Click attach volume
Choose instance name
Click attach
ubuntu@ip-172-31-22-162:~$ 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 25G 0 disk
ubuntu@ip-172-31-22-162:~$ sudo file -s /dev/xvdf
/dev/xvdf: data
ubuntu@ip-172-31-22-162:~$ sudo mkfs -t ext4 /dev/xvdf
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 6553600 4k blocks and 1638400 inodes
Filesystem UUID: 21d004ce-5bc7-426c-9a0d-ef465b97e0f7
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
ubuntu@ip-172-31-22-162:~$
ubuntu@ip-172-31-22-162:~$ sudo grub-install --root-directory=/mnt/new-volume/ --force /dev/xvdf
Installing for i386-pc platform.
grub-install: warning: File system `ext2' doesn't support embedding.
grub-install: warning: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and their use is discouraged..
Installation finished. No error reported.
ubuntu@ip-172-31-22-162:~$ sudo umount /mnt/new-volume
ubuntu@ip-172-31-22-162:~$ blkid
/dev/xvda1: LABEL="cloudimg-rootfs" UUID="b227be2c-6837-465f-83ac-42956a89ad4c" TYPE="ext4"
ubuntu@ip-172-31-22-162:~$ blkid
/dev/xvda1: LABEL="cloudimg-rootfs" UUID="b227be2c-6837-465f-83ac-42956a89ad4c" TYPE="ext4"
ubuntu@ip-172-31-22-162:~$ ^C
ubuntu@ip-172-31-22-162:~$ ^C
ubuntu@ip-172-31-22-162:~$ sudo tune2fs -U b227be2c-6837-465f-83ac-42956a89ad4c /dev/xvdf
tune2fs 1.42.13 (17-May-2015)
ubuntu@ip-172-31-22-162:~$ sudo e2label /dev/xvda1
cloudimg-rootfs
ubuntu@ip-172-31-22-162:~$ sudo e2label /dev/xvdf cloudimg-rootfs
ubuntu@ip-172-31-22-162:~$
Check gitlab installation
ubuntu@ip-172-31-22-162:~$ sudo gitlab-rake gitlab:check SANITIZE=true
Checking GitLab subtasks ...
Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 13.13.0 ? ... OK (13.13.0)
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Internal API available: FAILED - Internal API error (502)
gitlab-shell self-check failed
Try fixing it:
Make sure GitLab is running;
Check the gitlab-shell configuration file:
sudo -u git -H editor /opt/gitlab/embedded/service/gitlab-shell/config.yml
Please fix the error above and rerun the checks.
Checking GitLab Shell ... Finished
Checking Gitaly ...
Gitaly: ... default ... OK
Checking Gitaly ... Finished
Checking Sidekiq ...
Sidekiq: ... Running? ... no
Try fixing it:
sudo -u git -H RAILS_ENV=production bin/background_jobs start
For more information see:
doc/install/installation.md in section "Install Init Script"
see log/sidekiq.log for possible errors
Please fix the error above and rerun the checks.
Checking Sidekiq ... Finished
Checking Incoming Email ...
Incoming Email: ... Checking Reply by email ...
IMAP server credentials are correct? ... Checking noreply.j143@gmail.com
yes
Init.d configured correctly? ... skipped
MailRoom running? ... skipped
Checking Reply by email ... Finished
Checking Incoming Email ... Finished
Checking LDAP ...
LDAP: ... LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab App ...
Git configured correctly? ... yes
Database config exists? ... yes
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config up to date? ... yes
Log directory writable? ... yes
Tmp directory writable? ... yes
Uploads directory exists? ... yes
Uploads directory has correct permissions? ... yes
Uploads directory tmp has correct permissions? ... yes
Init script exists? ... skipped (omnibus-gitlab has no init script)
Init script up-to-date? ... skipped (omnibus-gitlab has no init script)
Projects have namespace: ...
2/1 ... yes
6/2 ... yes
2/4 ... yes
2/7 ... yes
12/8 ... yes
2/9 ... yes
2/10 ... yes
2/11 ... yes
2/12 ... yes
2/13 ... yes
2/14 ... yes
12/15 ... yes
2/16 ... yes
2/17 ... yes
2/18 ... yes
2/19 ... yes
2/20 ... yes
2/21 ... yes
2/22 ... yes
2/23 ... yes
2/24 ... yes
2/25 ... yes
2/26 ... yes
2/27 ... yes
16/28 ... yes
16/29 ... yes
2/30 ... yes
2/31 ... yes
17/32 ... yes
2/33 ... yes
18/34 ... yes
18/35 ... yes
18/36 ... yes
2/37 ... yes
19/38 ... yes
19/39 ... yes
19/40 ... yes
19/41 ... yes
2/42 ... yes
19/44 ... yes
19/45 ... yes
19/46 ... yes
19/47 ... yes
20/49 ... yes
20/50 ... yes
20/51 ... yes
20/52 ... yes
20/53 ... yes
20/54 ... yes
17/55 ... yes
20/56 ... yes
20/57 ... yes
2/58 ... yes
2/59 ... yes
20/60 ... yes
20/61 ... yes
20/62 ... yes
20/63 ... yes
20/64 ... yes
20/65 ... yes
20/66 ... yes
20/67 ... yes
20/68 ... yes
20/69 ... yes
20/70 ... yes
20/71 ... yes
2/72 ... yes
20/73 ... yes
20/74 ... yes
20/75 ... yes
2/76 ... yes
19/77 ... yes
19/78 ... yes
19/79 ... yes
19/80 ... yes
19/81 ... yes
2/82 ... yes
Redis version >= 4.0.0? ... yes
Ruby version >= 2.5.3 ? ... yes (2.7.2)
Git version >= 2.29.0 ? ... yes (2.29.0)
Git user has default SSH configuration? ... yes
Active users: ... 8
Is authorized keys file accessible? ... yes
GitLab configured to store new projects in hashed storage? ... yes
All projects are in hashed storage? ... yes
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
Run the gitlab with
# This file is managed by gitlab-ctl. Manual changes will be
# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
# and run `sudo gitlab-ctl reconfigure`.
# GitLab user. git by default
user: git
# Url to gitlab instance. Used for api calls. May but need not end with a slash.
gitlab_url: "http+unix://%2Fvar%2Fopt%2Fgitlab%2Fgitlab-workhorse%2Fsockets%2Fsocket"
gitlab_relative_url_root:
http_settings:
# user: someone
# password: somepass
# ca_file: /etc/ssl/cert.pem
# ca_path: /etc/pki/tls/certs
# self_signed_cert: false
# File used as authorized_keys for gitlab user
auth_file: "/var/opt/gitlab/.ssh/authorized_keys"
# SSL certificate dir where custom certificates can be placed
# https://golang.org/pkg/crypto/x509/
ssl_cert_dir: "/opt/gitlab/embedded/ssl/certs/"
# Log file.
# Default is gitlab-shell.log in the root directory.
log_file: "/var/log/gitlab/gitlab-shell/gitlab-shell.log"
# Log level. INFO by default
log_level:
log_format: json
# Audit usernames.
# Set to true to see real usernames in the logs instead of key ids, which is easier to follow, but
# incurs an extra API call on every gitlab-shell command.
audit_usernames:
migration:
{"enabled":true,"features":[]}
sudo gitlab-ctl reconfigure
ubuntu@ip-172-31-22-162:~$ sudo pkill nginx & wait $!
[1] 5401
[1]+ Done sudo pkill nginx
Increase EC2 volume size
#!/bin/bash
# Specify the desired volume size in GiB as a command line argument. If not specified, default to 20 GiB.
SIZE=${1:-20}
# Get the ID of the environment host Amazon EC2 instance.
INSTANCEID=$(curl http://169.254.169.254/latest/meta-data/instance-id)
# Get the ID of the Amazon EBS volume associated with the instance.
VOLUMEID=$(aws ec2 describe-instances \
--instance-id $INSTANCEID \
--query "Reservations[0].Instances[0].BlockDeviceMappings[0].Ebs.VolumeId" \
--output text)
# Resize the EBS volume.
aws ec2 modify-volume --volume-id $VOLUMEID --size $SIZE
# Wait for the resize to finish.
while [ \
"$(aws ec2 describe-volumes-modifications \
--volume-id $VOLUMEID \
--filters Name=modification-state,Values="optimizing","completed" \
--query "length(VolumesModifications)"\
--output text)" != "1" ]; do
sleep 1
done
#Check if we're on an NVMe filesystem
if [ $(readlink -f /dev/xvda) = "/dev/xvda" ]
then
# Rewrite the partition table so that the partition takes up all the space that it can.
sudo growpart /dev/xvda 1
# Expand the size of the file system.
# Check if we are on AL2
STR=$(cat /etc/os-release)
SUB="VERSION_ID=\"2\""
if [[ "$STR" == *"$SUB"* ]]
then
sudo xfs_growfs -d /
else
sudo resize2fs /dev/xvda1
fi
else
# Rewrite the partition table so that the partition takes up all the space that it can.
sudo growpart /dev/nvme0n1 1
# Expand the size of the file system.
# Check if we're on AL2
STR=$(cat /etc/os-release)
SUB="VERSION_ID=\"2\""
if [[ "$STR" == *"$SUB"* ]]
then
sudo xfs_growfs -d /
else
sudo resize2fs /dev/nvme0n1p1
fi
fi
Last updated
Was this helpful?