Here’s how to extend an ext4 boot volume.
gcloud compute disks resize DISK_NAME --size DISK_SIZE --zone ZONE --project PROJECTID |
Resize the file system. Example / is on sda3.
growpart /dev/sda 3 resize2fs /dev/sda3 |
cloud engineer
Here’s how to extend an ext4 boot volume.
gcloud compute disks resize DISK_NAME --size DISK_SIZE --zone ZONE --project PROJECTID |
gcloud compute disks resize DISK_NAME --size DISK_SIZE --zone ZONE --project PROJECTID
Resize the file system. Example / is on sda3.
growpart /dev/sda 3 resize2fs /dev/sda3 |
growpart /dev/sda 3 resize2fs /dev/sda3
How to find a boot disk from an instance.
gcloud compute instances describe servername \ --format='get(disks[0].source)' \ --zone=us-central1-c \ --project project-id |
gcloud compute instances describe servername \ --format='get(disks[0].source)' \ --zone=us-central1-c \ --project project-id
Result
https://www.googleapis.com/compute/v1/projects/project-id/zones/us-central1-f/disks/servername-boot |
https://www.googleapis.com/compute/v1/projects/project-id/zones/us-central1-f/disks/servername-boot
How to add a startup-script to metadata. The script executes every time VM is started.
gcloud compute instances add-metadata instance-name \ --project your-project-id \ --zone us-central1-c \ --metadata=startup-script='#! /bin/bash sudo -i echo "Time: $(date)" >> /tmp/date.txt' |
gcloud compute instances add-metadata instance-name \ --project your-project-id \ --zone us-central1-c \ --metadata=startup-script='#! /bin/bash sudo -i echo "Time: $(date)" >> /tmp/date.txt'
How to resize a root partition in GCP.
Increase disk size.
gcloud compute disks resize server-boot-disk-name \ --size=50GB \ --zone us-central1-c \ --project your-project-id |
gcloud compute disks resize server-boot-disk-name \ --size=50GB \ --zone us-central1-c \ --project your-project-id
Run growpart.
growpart /dev/sda 1 |
growpart /dev/sda 1
Run xfs_growfs.
xfs_growfs /dev/sda1 |
xfs_growfs /dev/sda1
To verify, run these.
lsblk df -Th |
lsblk df -Th
This are grub fixes to servers that are not booting up due to improper entries in the grub menu.
grub --batch <<END root (hd0,0) setup (hd0,0) quit END # sed -i 's/dev\/sda/dev\/hda/' /boot/grub/device.map sed -i 's/(hd0)/(hd0,0)/' /boot/grub/menu.lst |
grub --batch <<END root (hd0,0) setup (hd0,0) quit END # sed -i 's/dev\/sda/dev\/hda/' /boot/grub/device.map sed -i 's/(hd0)/(hd0,0)/' /boot/grub/menu.lst
The fix includes replacing (hd0) with (hd0,0) and /dev/sda with /dev/hda.
Here’s how to find when a Windows server was last rebooted.
systeminfo | find /i "boot time" |
systeminfo | find /i "boot time"
The /etc/fstab file allow volumes to be automatically mounted on bootup. Add nofail in your automated mounts to prevent instances from hanging on boot. Nofail makes the instance to boot even if there are errors with the mounted volume.
UUID=aebf131c-6957-451e-8d34-ec978d9581ae /data xfs defaults,nofail 0 2 |
UUID=aebf131c-6957-451e-8d34-ec978d9581ae /data xfs defaults,nofail 0 2
The following commands will extend Linux Boot drive without a reboot.
List block devices. Check disk sizes.
lsblk df -h |
lsblk df -h
Determine file system type: xfs, ext2, ext3 or ext4.
file -s /dev/xvda1 # or df -Th |
file -s /dev/xvda1 # or df -Th
Extend volume from the console or command line.
aws ec2 modify-volume --region us-east-1 \ --volume-id vol-xxxxxxxxxxxx --size 10 \ --volume-type gp2 |
aws ec2 modify-volume --region us-east-1 \ --volume-id vol-xxxxxxxxxxxx --size 10 \ --volume-type gp2
Resize Linux partition.
# for /dev/xvda1 growpart /dev/xvda 1 # for /dev/xvda2 growpart /dev/xvda 2 # for ext2, ext3, ext4 resize2fs /dev/xvda1 # for xfs xfs_growfs /dev/mapper/root xfs_growfs /dev/xvda1 |
# for /dev/xvda1 growpart /dev/xvda 1 # for /dev/xvda2 growpart /dev/xvda 2 # for ext2, ext3, ext4 resize2fs /dev/xvda1 # for xfs xfs_growfs /dev/mapper/root xfs_growfs /dev/xvda1
Check if new file size is being displayed.
lsblk df -Th |
lsblk df -Th