I am using a local SSD in Google Cloud Platform, and the characteristic of the local SSD provided by Google is that the user has to re-format and mount it every time the user restarts the OS :
https://cloud.google.com/compute/docs/disks/add-local-ssd#formatmultiple
I wanted to automate this because it's annoying having to do this manually every time the system restarts. So I created a script in /etc/init.d/automountssd.sh
#!bin/bash
sudo mdadm --create /dev/md0 --level=0 --raid-devices=4 /dev/nvme0n1 /dev/nvme0n2 /dev/nvme0n3 /dev/nvme0n4
sudo mkfs.ext4 -F /dev/md0
sudo mount /dev/md0 /root/Downloads/
Then assign permissions : chmod 775 /etc/init.d/automountssd.sh
And I registered it as autorun : update-rc.d automountssd.sh defaults
And after rebooting, nothing happened. :(
Solved : I followed alfajorcito's answer and this works perfectly on GCP platform.
First I followed his advice and changed #!bin/bash to #!/bin/bash.
And register it as a service by doing the following : nano /etc/systemd/system/automountssd.service
[Unit]
Description=automount for GCP local ssd
[Service]
Type=oneshot
ExecStart=/etc/init.d/automountssd.sh
TimeoutStartSec=0
[Install]
WantedBy=multi-user.target
And Start the service automatically when booting, and run the service : sudo systemctl enable automountssd && sudo systemctl start automountssd
Now whenever the OS is booted, the SSD will be automatically formatted, Raid configured and mounted :)