0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GPT & gdisk meno

Last updated at Posted at 2016-05-29

GPT ?

AND

ggrks via UEFI.
ggrks via Over 2TB limit

gdisk

fdisk can not treat GPT, so user gdisk

GPT root disk

Amazon linux's root volume GPT

The Amazon linux's root volume is partined with GPT.
But EC2 not support uefi, so part #128 (disk 1st sector) should be BIOS boot partioion .
https://forums.aws.amazon.com/message.jspa?messageID=553933

# gdisk /dev/xvda
GPT fdisk (gdisk) version 0.8.10

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): p
Disk /dev/xvda: 62914560 sectors, 30.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 4FC1A985-701F-4614-A040-C7A5CFB924C6
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 62914526P
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            4096        62914526   30.0 GiB    8300  Linux
 128            2048            4095   1024.0 KiB  EF02  BIOS Boot Partition

Proc for amazon linux

  1. gdisk
# gdisk  /dev/xvdf
GPT fdisk (gdisk) version 0.8.10

Command (? for help): n
Partition number (1-128, default 1): 128
First sector (34-20971486, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-20971486, default = 20971486) or {+-}size{KMGTP}: +1M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): EF02
Changed type of partition to 'BIOS boot partition'

Command (? for help): n
Partition number (1-128, default 1):
First sector (34-20971486, default = 4096) or {+-}size{KMGTP}:
Last sector (4096-20971486, default = 20971486) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): p
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'

Command (? for help): p
Disk /dev/xvdf: 20971520 sectors, 10.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): F992E234-8A2C-4E38-BCB3-F2F99CB98146
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 20971486
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            4096        20971486   10.0 GiB    8300  Linux filesystem
 128            2048            4095   1024.0 KiB  EF02  BIOS boot partition

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/xvdf.
The operation has completed successfully.```
  1. mkfs & mount

  2. copy files via dump & restore

cd <your mount point to target (shrunk) disk>
dump -0uf - /dev/sdc1 | restore rf -
  1. chroot (maybe vain..)
cd <your mount point to target (shrunk)>
mount -t proc proc ./proc
mount -t sysfs sys ./sys
mount --bind /dev ./dev
chroot .
  1. grub install
    Amazon linux grub != grub2. grub-install does not work correctly.
# grub
grub> device (hd0) /dev/sdf
device (hd0) /dev/sdf
grub> root (hd0,0)
root (hd0,0)
 Filesystem type is ext2fs, partition type 0x83
grub> setup (hd0)
setup (hd0)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... failed (this is not fatal)
 Running "embed /boot/grub/e2fs_stage1_5 (hd0,0)"... failed (this is not fatal)
 Running "install /boot/grub/stage1 (hd0) /boot/grub/stage2 p /boot/grub/grub.conf "... succeeded
Done.
grub> quit
quit

5') for CentOS6
edit boot/grub/grub.conf & replace current disk-UUID.

To get disk-UUID
blkid /dev/sdf1

  1. unchroot (maybe vain...)
exit (chroot)
umount ./dev
umount ./sys
umount ./proc
umount <your mount point>
  1. e2label [your disk] /
    e2label /dev/xvdf1 /
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?