Search code examples
azureautomationjenkins-pipelinemountinfrastructure

Automate mount datadrive in azure vm


I am able to spin up a (Ubuntu)vm in azure, adding datadisk by terraform and then i need to mount the added datadisk in the azure vm through automation(either jenkins pipeline or powershell) and as well as i need change docker directory through automation. Can anyone help me please.

I tried to automate the manual steps for mount datadrive , but i am not able to mount it -facing issues while executing below commands. I am not able to execute below commands in single line

sudo parted /dev/sdc

I am not able to copy value after executing below command and paste it in /etc/fstab

sudo -i blkid

Automate all below commands

**dmesg | grep SCSI
sudo parted /dev/sdc
sudo mkfs -t ext4 /dev/sdc1
sudo mkdir /datadrive
sudo mount /dev/sdc1 /datadrive
sudo -i blkid
sudo vi /etc/fstab**

I need to automate all above commands through jenkins pipeline or powershell. I am trying automate infrastructure i got stucked at this point. Can anyone help me please.


Solution

  • Below commands are working fine.

    dmesg | grep SCSI
    echo -e "o\nn\np\n1\n\n\nw" | fdisk /dev/sdc
    sudo mkfs -t ext4 /dev/sdc1
    sudo mkdir /datadrive
    sudo mount /dev/sdc1 /datadrive