Category Archives: Linux

RAID1, replace failed disk

  • /dev/sda – ok disk
  • /dev/sdb – failed disk, to be replaced

Remove failed disks from the array

mdadm --manage /dev/md0 --remove /dev/sdb1

Add new disk

Create the exact same partitioning as on /dev/sda.

sfdisk -d /dev/sda | sfdisk /dev/sdb

Add disk to mdx arrays

mdadm --manage /dev/md0 --add /dev/sdb1

Let it sync, then add bootloader to disks

# grub
grub> find /grub/stage1
 (hd0,0)
 (hd1,0)
grub> device (hd0) /dev/sda
grub> root (hd0,0)
grub> setup (hd0)
grub> device (hd0) /dev/sdb
grub> root (hd0,0)
grub> setup (hd0)

Links:

 

 

 

Setting hostname in ubuntu

Most people recommend setting up the hostname on a Linux box so that:

1) running ‘hostname‘ returns the short name (i.e. myhost)
2) running ‘hostname -f‘ returns the FQDN (i.e. myhost.prod.example.com)
3) running ‘hostname -d‘ returns the domain name (i.e prod.example.com)

After experimenting a bit and also finding this helpful Server Fault post, here’s what we did to achieve this (we did it via Chef recipes, but it amounts to the same thing):

  • make sure we have the short name in /etc/hostname:

myhost

(also run ‘hostname myhost‘ at the command line)

  • make sure we have the FQDN as the first entry associated with the IP of the server in /etc/hosts:

10.0.1.10 myhost.prod.example.com myhost myhost.prod

  • make sure we have the domain name set up as the search domain in /etc/resolv.conf:

search prod.example.com

Reboot the box when you’re done to make sure all of this survives reboots.
http://agiletesting.blogspot.com/2014/06/setting-up-hostname-in-ubuntu.html