0

I have an ubuntu server. Via cloud-init I make partitions. When I restart my server, it would not come up again. I am sure I miss one command to tell the system which partition should be used for booting.

Before partitioning the sda1 was the boot disk and a mbr.

cat /etc/fstab

root@source ~ # cat /etc/fstab
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=3f234dd2-63e6-4676-8ef3-0cde83e52484 /               ext4    discard,errors=remount-ro 0       1
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0

parted -l

root@source ~ # parted -l
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 20.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  20.5GB  20.5GB  primary  ext4         boot

fdisk -l

root@source ~ # fdisk -l
Disk /dev/sda: 19.1 GiB, 20480786432 bytes, 40001536 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x02d71cad

Device     Boot Start      End  Sectors  Size Id Type
/dev/sda1  *     2048 40001502 39999455 19.1G 83 Linux

After partitioning the sda1 should stay the boot disk and should use gpt.

But when I call parted -l or fdisk -l the boot flags wont show up?

parted -l

root@source ~ # parted -l
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 20.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  5121MB  5120MB  ext4
 2      5121MB  20.5GB  15.4GB  xfs

fdisk -l

root@source ~ # fdisk -l
Disk /dev/sda: 19.1 GiB, 20480786432 bytes, 40001536 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 8D6B03D7-1A3B-4BFC-8F8F-64EEF049CB9E

Device        Start      End  Sectors  Size Type
/dev/sda1      2048 10002431 10000384  4.8G Linux filesystem
/dev/sda2  10002432 40001502 29999071 14.3G Linux filesystem

cat /etc/fstab

root@source ~ # cat /etc/fstab
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=3f234dd2-63e6-4676-8ef3-0cde83e52484 /               ext4    discard,errors=remount-ro 0       1
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0
/dev/sda1   /   auto    defaults,nofail,x-systemd.requires=cloud-init.service,comment=cloudconfig   0   2
/dev/sda2   /data_disk  auto    defaults,nofail,x-systemd.requires=cloud-init.service,comment=cloudconfig   02

Here is my cloud-config which works:

#cloud-config
resize_rootfs: false

disk_setup:
  /dev/sda:
    table_type: 'gpt'
    layout:
      - 25
      - 75
    overwrite: true

fs_setup:
  - label: root_fs
    filesystem: 'ext4'
    device: /dev/sda
    partition: sda1
    overwrite: true

  - label: data_disk
    filesystem: 'xfs'
    device: /dev/sda
    partition: sda2
    overwrite: true

runcmd:
  - [ partx, --update, /dev/sda ]
  - [ partprobe ] # asfaik partx and partprobe commands do the same
  - [ parted, /dev/sda, set, 1, on, boot ] # <<-- set boot flag here
  - [ mkfs.xfs, /dev/sda2 ] # format second partition with xfs

mounts:
  - ["/dev/sda1", "/"] # mount boot disk on /
  - ["/dev/sda2", "/data_disk"] # mount data_disk

What I am missing? Do I have to tell fstab something more?

0

I see you have changed the partitioning type from MBR to GPT. Is your firmware in legacy/CSM/BIOS mode, or did you also change the firmware type to UEFI? In any case, you will need to reinstall your bootloader. If you are using BIOS mode (not UEFI), you will need to add a GRUB BIOS boot partition, because the sectors that were used for storing GRUB Stage 1.5 are now occupied by the GPT. If you are using UEFI firmware, you will need to add a FAT formatted EFI System Partition (ESP) from the firmware to boot from.

  • Thank you very much. For the moment I stay with MBR. As a partition newbie it looks a bit complicated. my example above works but wont keep the boot partition. If anyone is interested in a reboot able xfs partition with mbr: this example works: gist.github.com/exocode/a7e12b063f23a1ef899b23bcbfc7d123 – Jan Mar 29 '18 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.