VMware Cloud Community
dvdnt91
Contributor
Contributor

I would like scripting the creation of a partition vmfs3

I would like scripting the creation with no humain intervention.

When i rescan, i see the new disk.

But when i use vmkfstools :

vmkfstools -C vmfs23 -S lun0 /vmfs/devices/disk/vmhba1:0:5:0

the error is operation not permitted

I don't want to use fdisk because that's a interactive programs.

Thanks

0 Kudos
7 Replies
Deli
Enthusiast
Enthusiast

Hallo,

you need first create the Partion and then the VMFS3.

See Page 33: http://www.rtfm-ed.eu/docs/vmwdocs/esx3.x-vc2.x-serviceconsole-guide.pdf

Regards,

Marco

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ No trees were killed in the sending of this message. However a large number of electrons were terribly inconvenienced
0 Kudos
dvdnt91
Contributor
Contributor

Yes, but i try to make a script to create the partition.

I don't want to use fdisk because it's an interactive program and i would like create this partition in script.

Regards,

0 Kudos
krishnaprasad
Hot Shot
Hot Shot

Hello,

You can use fdisk in your script. you can provide inputs to fdisk using bash script.

for eg/-

fdisk /dev/sda << **

n

p

1

startsize

endsize

w

\**

this program creates a partition 1 in /dev/sda with start size and end size provided in MBs.

in your case after creating partition, you need to change the device type since by default the created partition will take 83 as its type ( linux ) so u need to add the following lines to it.

fdisk /dev/sda << **

t

1

fb

w

**

here fb is the type of vmfs3 partition. and the script converts ur linux partition to a vmfs partition

hope this helps

0 Kudos
dvdnt91
Contributor
Contributor

I will try to do that, and i will put my script nin this topics.

thanks a lot

Regards

0 Kudos
Texiwill
Leadership
Leadership

Hello,

The other option when scripting a fdisk is to use the 'sfdisk' command. Use 'man sfdisk' for information. Use of fdisk and sfdisk is very dangerous. So use both carefully.

Best regards,

Edward

--
Edward L. Haletky
vExpert XIV: 2009-2023,
VMTN Community Moderator
vSphere Upgrade Saga: https://www.astroarch.com/blogs
GitHub Repo: https://github.com/Texiwill
0 Kudos
dvdnt91
Contributor
Contributor

I give you my script and thanks a lot t o all the people who help me.

Regards

The first one is :

\----


#!/bin/sh

fdisk /dev/sdi < /root/script-fdisk.sh

vmkfstools -C vmfs3 -S Lun9-fdisk5 /vmfs/devices/disks/vmhba1\:0\:6\:1

esxcfg-rescan

\----


and the second (answer to fdisk)

\----


n

p

1

t

fb

w

\----


0 Kudos
john23
Commander
Commander

Hey,

I am using the script as you mentioned,Its working fine,but while taking the partition id ,it is not taking vmfs ,it is taking linux (default one).I have checked the id list ,it is not showing 'fb' there.Is there any way to give partition as type as 'fb'?

Thanks for your response.

Thanks -A Read my blogs: www.openwriteup.com
0 Kudos