Eu tenho um servidor Ubuntu. Via cloud-init eu faço partições. Quando eu reiniciar meu servidor, ele não virá novamente. Tenho certeza que sinto falta de um comando para dizer ao sistema qual partição deve ser usada para inicializar.
Antes de particionar o sda1 era o disco de inicialização e um 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
Após particionar o sda1 deve manter o disco de inicialização e deve usar gpt
.
Mas quando eu chamo parted -l
ou fdisk -l
os flags de inicialização não aparecem?
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
Aqui está o meu cloud-config que funciona:
#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
O que eu sinto falta?
Eu tenho que dizer algo mais para o fstab?