Skip to content

Commit 7e4a64a

Browse files
committed
fix: mount disk using cloud init
1 parent ca754af commit 7e4a64a

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

main.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,25 @@ data "cloudinit_config" "config" {
3838
gzip = false
3939
base64_encode = false
4040

41+
part {
42+
# https://docs.cloud.google.com/compute/docs/disks/format-mount-disk-linux
43+
# https://docs.cloud.google.com/container-optimized-os/docs/concepts/disks-and-filesystem#mounting_and_formatting_disks
44+
filename = "bootcmd"
45+
content_type = "text/cloud-config"
46+
merge_type = "list(append)+dict(no_replace, recurse_list)+str()"
47+
content = yamlencode({
48+
bootcmd = [
49+
# Format disk if not already formatted
50+
"blkid /dev/disk/by-id/google-${local.atlantis_persistent_disk_name} || mkfs.ext4 -m 0 -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/disk/by-id/google-${local.atlantis_persistent_disk_name}",
51+
# Check and repair filesystem
52+
"fsck.ext4 -tvy /dev/disk/by-id/google-${local.atlantis_persistent_disk_name}",
53+
# Create mount point and mount the disk
54+
"mkdir -p ${local.atlantis_disk_mount_path}",
55+
"mount -t ext4 -o discard,defaults /dev/disk/by-id/google-${local.atlantis_persistent_disk_name} ${local.atlantis_disk_mount_path}"
56+
]
57+
})
58+
}
59+
4160
part {
4261
filename = "runcmda"
4362
content_type = "text/cloud-config"

0 commit comments

Comments
 (0)