Skip to content

Instantly share code, notes, and snippets.

@cockok
Last active February 4, 2018 08:55
Show Gist options
  • Save cockok/469c81debf790e468f08 to your computer and use it in GitHub Desktop.
Save cockok/469c81debf790e468f08 to your computer and use it in GitHub Desktop.
GRUBの修復

さくらVPSで借りてたサーバのubuntuがGRUBが壊れて起動しなくなった

参考にしたのは以下

ISOカスタムイメージでrescue modeを起動

# fdisk -l

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048      499711      248832   83  Linux
/dev/vda2          501758   209713151   104605697    5  Extended
/dev/vda5          501760   209713151   104605696   8e  Linux LVM

# lvscan

  inactive            '/dev/www******/root' [96.88 GiB] inherit
  inactive            '/dev/www******/swap_1' [2.86 GiB] inherit

# lvchange --available y /dev/www******/root /dev/www******/swap_1

# mount /dev/mapper/www******-root /mnt

中身が無事なのを確認したのでとりあえずバックアップした

# mount /dev/vda1 /mnt/boot
# mount --bind /dev  /mnt/dev
# mount --bind /dev/pts  /mnt/dev/pts
# mount --bind /proc /mnt/proc
# mount --bind /sys  /mnt/sys
# chroot /mnt
# grub-install /dev/vda
# update-grub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment