{"id":5665,"date":"2018-07-23T21:10:06","date_gmt":"2018-07-23T19:10:06","guid":{"rendered":"https:\/\/michlstechblog.info\/blog\/?p=5665"},"modified":"2018-07-25T07:05:27","modified_gmt":"2018-07-25T05:05:27","slug":"esxi-expand-datastore-from-command-line","status":"publish","type":"post","link":"https:\/\/michlstechblog.info\/blog\/esxi-expand-datastore-from-command-line\/","title":{"rendered":"ESXi: Expand datastore from command line"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_5665 social_share_privacy clearfix 1.6.4 locale-en_US sprite-en_US\"><\/div><div class=\"twoclick-js\"><script type=\"text\/javascript\">\/* <![CDATA[ *\/\njQuery(document).ready(function($){if($('.twoclick_social_bookmarks_post_5665')){$('.twoclick_social_bookmarks_post_5665').socialSharePrivacy({\"services\":{\"flattr\":{\"uid\":\"Michl\",\"status\":\"on\",\"the_title\":\"ESXi%3A%20Expand%20datastore%20from%20command%20line\",\"the_excerpt\":\"Hi%2C%0D%0A%0D%0Asometimes%20the%20vSphere%20Client%20does%20not%20determine%20when%20an%20underlying%20Volume%20is%20expanded.%20So%20you%20cannot%20expand%20the%20datastore%20by%20the%20WebGUI%20or%20vSphere%20Client.%0D%0A%0D%0ABut%20the%20command%20line%20way%20is%20still%20possible%20%3A-%29%20These%20are%20the%20steps%3A%0D%0A%0D%0A%20%28more%26hellip%3B%29\",\"txt_info\":\"2 clicks for more data protection:\\r\\n\\r\\nOnly when you click here, the button will be come active and you can send your recommendation to Flattr. When activating, data are transmitted to third parties. \",\"perma_option\":\"off\"}},\"txt_help\":\"When you activate these fields by clicking, information to Flattr may be transferred abroad, and probably may also stored there.\",\"settings_perma\":\"Enable permanently and accept data transmission. \",\"info_link\":\"http:\\\/\\\/www.heise.de\\\/ct\\\/artikel\\\/2-Klicks-fuer-mehr-Datenschutz-1333879.html\",\"uri\":\"https:\\\/\\\/michlstechblog.info\\\/blog\\\/esxi-expand-datastore-from-command-line\\\/\",\"post_id\":5665,\"post_title_referrer_track\":\"ESXi%3A+Expand+datastore+from+command+line\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>Hi,<\/p>\n<p>sometimes the vSphere Client does not determine when an underlying Volume is expanded. So you cannot expand the datastore by the WebGUI or vSphere Client.<\/p>\n<p>But the command line way is still possible \ud83d\ude42 These are the steps:<\/p>\n<p><!--more--><br \/>\nIn this example the underlying volume\/LUN of datastore_0 was already expand from 6TB to 10TB at the storage system. So I also want to grow up the vmfs on datastore_0 to 10TB.<br \/>\nLogin to an ESXi Host by ssh.<\/p>\n<p>Rescan all storage adapter for changes<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;root@esxihost:~] esxcli storage core adapter rescan --all\r\n<\/pre>\n<p>Determine the disk path<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;root@esxihost:~] vmkfstools -P \/vmfs\/volumes\/datastore_0\r\nVMFS-5.61 file system spanning 1 partitions.\r\nFile system label (if any): datastore_0\r\nMode: public\r\nCapacity 6596801331200 (6291200 file blocks * 1048576), 217090883584 (207034 blocks) avail, max supported file size 69201586814976\r\nUUID: 5ad58cdb-c8604cf3-e8fc-a0369f990590\r\nPartitions spanned (on &quot;lvm&quot;):\r\nnaa.523545670e392ba2e81404da45912d543:1\r\nIs Native Snapshot Capable: YES\r\n<\/pre>\n<p>Depending on the output of vmkfstools the Diskpath is <strong>\/vmfs\/devices\/disks\/naa.523545670e392ba2e81404da45912d543<\/strong>, <strong>:1<\/strong> means datastore_0 is the first partition on the disk.<\/p>\n<p>Get the Disk layout<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;root@esxihost:~] partedUtil get \/vmfs\/devices\/disks\/naa.523545670e392ba2e81404da45912d543\r\n1336746 255 63 21474836480\r\n1 2048 12884901854 0 0\r\n<\/pre>\n<p><strong>Start Sector<\/strong> of the first partition is<strong> 2048<\/strong>, current <strong>end sector<\/strong> is <strong>12884901854 <\/strong>.<\/p>\n<p>Determine the last usable end sector. If an error occured like this:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;root@esxihost:~] partedUtil getUsableSectors \/vmfs\/devices\/disks\/naa.523545670e392ba2e81404da45912d543\r\nError: The backup GPT table is not at the end of the disk, as it should be.  This might mean that another operating system believes the disk is smaller.  Fix, by moving the backup to the end (and removing the old backup)? This will also fix the last usable sector as per the new size.\r\n<\/pre>\n<p>then you have to correct the GPT partition table first:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;root@esxihost:~] partedUtil fixGpt \/vmfs\/devices\/disks\/naa.523545670e392ba2e81404da45912d543\r\n\r\nFixGpt tries to fix any problems detected in GPT table.\r\nPlease ensure that you don't run this on any RDM (Raw Device Mapping) disk.\r\nAre you sure you want to continue (Y\/N): y\r\ngpt\r\n1336746 255 63 21474836480\r\n1 2048 12884901854 AA31E02A400F11DB9590000C2911D1B8 vmfs 0\r\n<\/pre>\n<p>And again. Determine the last usable sector <\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"> \r\n&#x5B;root@esxihost:~] partedUtil getUsableSectors \/vmfs\/devices\/disks\/naa.523545670e392ba2e81404da45912d543\r\n34 21474836446\r\n<\/pre>\n<p>Last usable sector is <strong>21474836446<\/strong>.<\/p>\n<p>Expand the first partition. 2048 is the start sector and 21474836446 the new end sector.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;root@esxihost:~] partedUtil resize \/vmfs\/devices\/disks\/naa.523545670e392ba2e81404da45912d5431 1 2048 21474836446\r\n<\/pre>\n<p>and also grow the filesystem<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;root@esxihost:~] vmkfstools --growfs \/vmfs\/devices\/disks\/naa.523545670e392ba2e81404da45912d543:1 \/vmfs\/devices\/disks\/naa.523545670e392ba2e81404da45912d543:1\r\n<\/pre>\n<p>rescan all volumes<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;root@esxihost:~] vmkfstools -V\r\n<\/pre>\n<p>That&#8217;s it \ud83d\ude42<\/p>\n<p>Michael<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, sometimes the vSphere Client does not determine when an underlying Volume is expanded. So you cannot expand the datastore by the WebGUI or vSphere Client. But the command line way is still possible \ud83d\ude42 These are the steps:<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[457,1224,1011,201,1227,556,1226,1225,1223],"class_list":["post-5665","post","type-post","status-publish","format-standard","hentry","category-vmware","tag-esxi","tag-expand","tag-filesystem","tag-grow","tag-refresh","tag-rescan","tag-the-backup-gpt-table-is-not-at-the-end-of-the-disk","tag-vmfs","tag-vpshere"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/5665","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/comments?post=5665"}],"version-history":[{"count":15,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/5665\/revisions"}],"predecessor-version":[{"id":5687,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/5665\/revisions\/5687"}],"wp:attachment":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/media?parent=5665"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/categories?post=5665"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/tags?post=5665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}