• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

boot

GCP Extend ext4 Boot Volume

July 28, 2022

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

Filed Under: Cloud, Linux Tagged With: boot, ext4, extend, gcloud, gcp, growpart, resize2fs, volume

GCP Find Instance Boot Disk

April 13, 2022

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

Filed Under: Cloud Tagged With: boot, disk, find, gcp

GCP Compute add startup-script to metadata

February 2, 2022

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'

Filed Under: Cloud Tagged With: add, boot, compute, gcp, metadata, startup-script

Resizing XFS root partition in GCP

July 16, 2021

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

Filed Under: Cloud, Linux Tagged With: boot, extend, gcp, growpart, root, xfs, xfs_growfs

GRUB Fixes

February 15, 2020

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.

Filed Under: Linux Tagged With: boot, fix, grub, issues, menu

Windows Boot Time

December 2, 2019

Here’s how to find when a Windows server was last rebooted.

systeminfo | find /i "boot time"

systeminfo | find /i "boot time"

Filed Under: Windows Tagged With: boot, cmd, last, server, windows

Add nofail

May 1, 2019

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

Filed Under: Cloud, Linux Tagged With: boot, errors, fstab, nofail

Extend Linux Boot

February 6, 2019

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

Filed Under: Linux Tagged With: boot, extend, partition

  • Go to page 1
  • Go to page 2
  • Go to Next Page »
  • Home
  • About
  • Archives

Copyright © 2023