当前位置:网站首页>Disk partition extension using graphical interface and PowerShell code

Disk partition extension using graphical interface and PowerShell code

2022-06-24 03:26:00 shawyang

Offline , Buy a 1T The mobile hard disk , Divide up 250G The partition , Explorer display 250G, Where is the rest of the disk space ? Empty space displayed in disk manager .

On the cloud , Take a snapshot of the disk 250G, bought 300G Data disk , The explorer must show 250G, Open disk manager to view the remaining space .

For example, I had a piece before 100G The data disk takes a snapshot ( There are 49G、51G 2 Zones ), I bought it with this snapshot today 1 block 110G Data disk of , What you see in the disk manager is the previous 100G Partition , That is, a 49G、 One 51G, remainder 10G Open the disk manager to see , If I want to put the blank 10G Add to 51G Zoning , Then I am 51G Right click in the blank space of the partition " Expand volume "

If you use powershell If you order

# The above figure is an example to specify the disk number and its partition code , The first 2 Block disk (disk 1) Of the 2 Zones (part 2)

# The disk number and partition number here should correspond to your actual situation , Do not copy mechanically

# Corresponding to your actual situation , If your snapshot is 1 Primary partitions , The disk you bought is larger than the disk space you used for snapshots 、 Want to add the blank space to the previous partition , Then change the partition number to 1

$disknum=1

$partnum=2

$datapan = @"

sel disk $disknum

online disk NOERR

attr disk clear readonly NOERR

sel part $partnum

extend

san policy=onlineall

"@

$datapan >> C:\diskpart_log.txt;

"$(get-date -format "[yyyy-MM-dd HH:mm:ss:ffffff]") " >> C:\diskpart_log.txt;

$datapan|diskpart 2>&1 >> C:\diskpart_log.txt;

# Corresponding to your actual situation , If your snapshot is 1 Zones , The disk you bought is larger than the disk space you used for snapshots 、 Want to add the blank space to the previous partition , Then change the partition number to 1, as follows

$disknum=1

$partnum=1

$datapan = @"

sel disk $disknum

online disk NOERR

attr disk clear readonly NOERR

sel part $partnum

extend

san policy=onlineall

"@

$datapan >> C:\diskpart_log.txt;

"$(get-date -format "[yyyy-MM-dd HH:mm:ss:ffffff]") " >> C:\diskpart_log.txt;

$datapan|diskpart 2>&1 >> C:\diskpart_log.txt;

With Administrator Open as Administrator powershell, Copy the above code in powershell Just execute .

If it's multiple machines , Sure Use RDM Batch remote After that, copy and paste it on each machine .

原网站

版权声明
本文为[shawyang]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/10/20211007175100005K.html