• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Extend your disk partition to max

    Scheduled Pinned Locked Moved
    Tutorials
    5
    12
    12.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      astrouga
      last edited by

      Since I use “one image to rule them all”, I have to remember to shrink my partition down below the smallest disk in inventory before I sysprep it. Otherwise the image will fail on some systems. I have some disks that are 80GB and some that are 500GB. So I usually manually shrink my disk down below 80GB before I sysprep it. Then after imaging a system with larger disks, I have to extend the partition to the max size. I got tired of doing this manually, so I wrote a vbscript to do this for me. I’m sharing it in hopes that it helps others, but also to see if anyone has a better way.

      I actually use this snippet of code in a larger vbscript that does other things (local account creation, firewall exceptions, registry changes, printer installs, etc), but I’ve pulled out necessary the code below. Should be complete. Note it is actually two files. One is the vbscript that just runs diskpart, the other is a text file that contains the options to pass to diskpart.

      [B][U]extend_max.vbs[/U][/B]:
      [CODE]’ ########## Extend Disk Partition (MAX) ##########
      LogFilename = “C:\Windows\Setup\InstallLog.txt”
      LogFile.writeline “-------------------------------”
      LogFile.writeline “Extending partition to max size:”
      LogFile.writeline “-------------------------------” & VbCrlf

      diskpartScript = “C:\Windows\Setup\Scripts\extend_max.txt”

      Set oShell = CreateObject(“Wscript.Shell”)
      Set oShellExec = oShell.Exec("cmd /c diskpart -s " & diskpartScript)
      set oStdOutputText = oShellExec.StdOut

      Do While Not oStdOutputText.AtEndOfStream
      diskpartOutput = oStdOutputText.ReadLine
      LogFile.writeline diskpartOutput
      Loop[/CODE]

      [B][U]extend_max.txt[/U][/B]:
      [CODE]select disk 0
      detail disk
      list disk
      select volume c
      extend disk 0
      list disk
      exit[/CODE]

      I call this script by adding a line to my SetupComplete.vbs script. Something like:

      REG ADD %KEY%\005 /VE /D “Extending disk partition size to max” /f
      REG ADD %KEY%\005 /V 1 /D “%systemroot%\Setup\Scripts\extend_max.vbs” /f

      astrouga

      1 Reply Last reply Reply Quote 0
      • D
        David Atkinson
        last edited by

        FWIW, I have a much shorter diskpart.txt file:
        [CODE]select disk 0
        select partition 2
        extend[/CODE]

        I just call it from the SetupComplete.cmd script:

        [CODE]@echo off
        diskpart /s C:\Windows\Setup\Scripts\diskpart.txt

        del /Q /F C:\Windows\System32\Sysprep\unattend.xml
        del /Q /F C:\Windows\Panther\unattend.xml
        del /Q /F C:\Windows\Setup\Scripts\diskpart.txt

        sc config “Sophos AutoUpdate Service” start= auto
        sc config “Sophos Agent” start= auto
        sc config “Sophos Message Router” start= auto[/CODE]

        But, of course, I’m blessed with very consistent, almost homogeneous hardware.

        1 Reply Last reply Reply Quote 0
        • T
          The Dealman
          last edited by

          [quote=“David Atkinson, post: 9134, member: 2696”]FWIW, I have a much shorter diskpart.txt file:
          [CODE]select disk 0
          select partition 2
          extend[/CODE]

          I just call it from the SetupComplete.cmd script:

          [CODE]@echo off
          diskpart /s C:\Windows\Setup\Scripts\diskpart.txt

          del /Q /F C:\Windows\System32\Sysprep\unattend.xml
          del /Q /F C:\Windows\Panther\unattend.xml
          del /Q /F C:\Windows\Setup\Scripts\diskpart.txt

          sc config “Sophos AutoUpdate Service” start= auto
          sc config “Sophos Agent” start= auto
          sc config “Sophos Message Router” start= auto[/CODE]

          But, of course, I’m blessed with very consistent, almost homogeneous hardware.[/quote]

          Whoa this is all interesting what image types are you using for the master image and your deployment image?

          Fog 1.5.9 running currently on all servers

          1 Reply Last reply Reply Quote 0
          • T
            The Dealman
            last edited by

            [quote=“astrouga, post: 8537, member: 907”]Since I use “one image to rule them all”, I have to remember to shrink my partition down below the smallest disk in inventory before I sysprep it. Otherwise the image will fail on some systems. I have some disks that are 80GB and some that are 500GB. So I usually manually shrink my disk down below 80GB before I sysprep it. Then after imaging a system with larger disks, I have to extend the partition to the max size. I got tired of doing this manually, so I wrote a vbscript to do this for me. I’m sharing it in hopes that it helps others, but also to see if anyone has a better way.

            I actually use this snippet of code in a larger vbscript that does other things (local account creation, firewall exceptions, registry changes, printer installs, etc), but I’ve pulled out necessary the code below. Should be complete. Note it is actually two files. One is the vbscript that just runs diskpart, the other is a text file that contains the options to pass to diskpart.

            [B][U]extend_max.vbs[/U][/B]:
            [CODE]’ ########## Extend Disk Partition (MAX) ##########
            LogFilename = “C:\Windows\Setup\InstallLog.txt”
            LogFile.writeline “-------------------------------”
            LogFile.writeline “Extending partition to max size:”
            LogFile.writeline “-------------------------------” & VbCrlf

            diskpartScript = “C:\Windows\Setup\Scripts\extend_max.txt”

            Set oShell = CreateObject(“Wscript.Shell”)
            Set oShellExec = oShell.Exec("cmd /c diskpart -s " & diskpartScript)
            set oStdOutputText = oShellExec.StdOut

            Do While Not oStdOutputText.AtEndOfStream
            diskpartOutput = oStdOutputText.ReadLine
            LogFile.writeline diskpartOutput
            Loop[/CODE]

            [B][U]extend_max.txt[/U][/B]:
            [CODE]select disk 0
            detail disk
            list disk
            select volume c
            extend disk 0
            list disk
            exit[/CODE]

            I call this script by adding a line to my SetupComplete.vbs script. Something like:

            REG ADD %KEY%\005 /VE /D “Extending disk partition size to max” /f
            REG ADD %KEY%\005 /V 1 /D “%systemroot%\Setup\Scripts\extend_max.vbs” /f

            astrouga[/quote]

            I modified my image to include this and it seems work on those pesky advance format drives

            Fog 1.5.9 running currently on all servers

            1 Reply Last reply Reply Quote 0
            • G
              golpemortal
              last edited by

              I am having hard time implementing this tutor on Windows 7 ent…
              I trying to make it part of the image and follow steps from astrouga and no success

              added this to the script

              REG ADD %KEY%\005 /VE /D “Extending disk partition size to max” /f
              REG ADD %KEY%\005 /V 1 /D “%systemroot%\Setup\Scripts\extend_max.vbs” /f

              added exactly the same but got error on the command prompt

              1 Reply Last reply Reply Quote 0
              • T
                The Dealman
                last edited by

                [quote=“golpemortal, post: 9246, member: 2653”]I am having hard time implementing this tutor on Windows 7 ent…
                I trying to make it part of the image and follow steps from astrouga and no success

                added this to the script

                REG ADD %KEY%\005 /VE /D “Extending disk partition size to max” /f
                REG ADD %KEY%\005 /V 1 /D “%systemroot%\Setup\Scripts\extend_max.vbs” /f

                added exactly the same but got error on the command prompt[/quote]

                What error did you get?

                Fog 1.5.9 running currently on all servers

                1 Reply Last reply Reply Quote 0
                • G
                  golpemortal
                  last edited by

                  Dealman can you give me a steps by steps on implenting this tutoral from A to Z.
                  the error message that I got was when I ran the setupcomplete.cmd on the command prompt and was complanning about REG ADD format…

                  could it been that I was not doing it right , since this is my first time messing with fog cloning I would like some help…

                  1 Reply Last reply Reply Quote 0
                  • T
                    The Dealman
                    last edited by

                    [quote=“golpemortal, post: 9293, member: 2653”]Dealman can you give me a steps by steps on implenting this tutoral from A to Z.
                    the error message that I got was when I ran the setupcomplete.cmd on the command prompt and was complanning about REG ADD format…

                    could it been that I was not doing it right , since this is my first time messing with fog cloning I would like some help…[/quote]

                    I didn’t do the whole reg add part. i called the disk part from SetupComplete.cmd script like what David suggested

                    Fog 1.5.9 running currently on all servers

                    1 Reply Last reply Reply Quote 0
                    • G
                      golpemortal
                      last edited by

                      ok can you point me out to a good tutorial… this one here is a bit complicated for newbee like me

                      1 Reply Last reply Reply Quote 0
                      • T
                        The Dealman
                        last edited by

                        [quote=“golpemortal, post: 9308, member: 2653”]ok can you point me out to a good tutorial… this one here is a bit complicated for newbee like me[/quote]

                        I dont believe a guide exists but
                        Go into the c:\Windows\Setup\Scripts folder (if you dont see a scripts folder then make one) in the scripts folder you should have 2 files to make this work. You need a diskpart.txt file that has the code below in it
                        select disk 0
                        select partition 2
                        extend

                        then in the SetupComplete.cmd file add this

                        diskpart /s C:\Windows\Setup\Scripts\diskpart.txt
                        del /Q /F C:\Windows\Setup\Scripts\diskpart.txt

                        make any other changes that you need to then sysprep and upload your image. When you go to deploy
                        it should work.

                        that’s all you need to make this work

                        Fog 1.5.9 running currently on all servers

                        1 Reply Last reply Reply Quote 0
                        • G
                          golpemortal
                          last edited by

                          thanks I will try this Monday morning I post results

                          1 Reply Last reply Reply Quote 0
                          • A
                            Alex M1
                            last edited by

                            EDIT: Haha. Well after long last I managed to get the script to work with just a few clicks and no errors. Thanks anyways, and thank you astrouga. (if you still visit here)

                            I know this is an old post, but I was using astrouga’s Script and it works great, however, I get a Error: Object Required “Log Script”

                            It says it’s on the last line character 1

                            The script actually runs all of the way through and extends the hard drive, but I am very very new to scripting ( like maybe a week ago I started ) and was wondering if this would ever be a problem.

                            Thanks!

                            1 Reply Last reply Reply Quote 0
                            • 1 / 1
                            • First post
                              Last post

                            162

                            Online

                            12.0k

                            Users

                            17.3k

                            Topics

                            155.2k

                            Posts
                            Copyright © 2012-2024 FOG Project