قم بتكبير ... قم بزيادة القرص الظاهري في مكانه

بشكل دوري ، يجب عليك معالجة الأقراص الافتراضية لضيوف KVM.

ولكن نظرًا لأن هذا يجب أن يتم بشكل غير متكرر ، في كل مرة يتعين عليك إعادة كتابة RTFM ، لذلك كتبت مثل هذا الحافز.

لقد قمت اليوم بزيادة قرص NTFS لنظام Windows الضيف باستخدام مضيف CentOS 7 ، لذلك يوجد أدناه البث المباشر.



سنقوم بتنفيذ جميع العمليات يدويًا - بدون ماوس وتشغيل إضافي.



يجب أن يتم كل شيء بعناية فائقة ، قبل العملية ، قم بعمل نسخة احتياطية من القرص الهدف (إن أمكن ؛ لقد فعلت ذلك اليوم) أو أدعو الله جيدًا (إذا لم يكن هناك مكان ؛ آخر مرة كانت مثل هذه الحالة).

للعمل سوف تحتاج:

  • dd (coreutils)

  • fdisk (استخدام لينكس)

  • kpartx (kpartx)

  • نتفسريسيزي (نتفسبروجس)

سنزيد "القرص" ws_e.img من 64 كيلو بايت إلى 16 كيلو بايت (حتى 80 كيلو بايت).

ملاحظة : 1 KGB (kakbygigabyte) = 1008 ميغابايت (مضاعفات 63 لأسباب تاريخية ) ، حسنًا ، هذا مقبول بيني ولا يؤخذ بالضرورة في الاعتبار).

1. تكبير القرص الخاص بك

بادئ ذي بدء ، دعونا ننمي القرص الفعلي.

كانت:

[root@ext images]# ls -l ws_e.img 
-rw-r--r-- 1 root root 67645734912  25 14:31 ws_e.img

عملية:

[root@ext images]# dd if=/dev/zero of=ws_e.img bs=1008M count=16 oflag=append conv=notrunc
16+0  
16+0  
  16911433728  (17 GB), 69,638 c, 243 MB/c

أو خيار أكثر ذكاءً (لم أجربه بنفسي بعد):

fallocate -i -l 16128M -o 64512M ws_e.img

أصبح:

[root@ext images]# ls -l ws_e.img 
-rw-r--r-- 1 root root 84557168640  25 14:54 ws_e.img

ملاحظة : في حالة نقل البيانات بين الأقراص الحديدية ، يجب أن يكون هذا المكان مثلdd if=/dev/sdb of=/dev/sdc

2. تكبير القسم الخاص بك

man ntfsresize:

To enlarge an NTFS filesystem, first you must enlarge the size of the underlying partition. This can be done using fdisk(8) by deleting the partition and recreating it with a larger size.

:
[root@ext images]# fdisk ws_e.img 
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


 (m  ): p

Disk ws_e.img: 84.6 GB, 84557168640 bytes, 165150720 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xc617554d

-                       Id  
ws_e.img1            2048   132116479    66057216    7  HPFS/NTFS/exFAT

 (m  ): d
Selected partition 1
Partition 1 is deleted

 (m  ): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): 
Using default response p
  (1-4, default 1): 
 sector (2048-165150719,   2048): 
    2048
Last sector, +sectors or +size{K,M,G} (2048-165150719,   165150719): 
    165150719
Partition 1 of type Linux and of size 78,8 GiB is set

 (m  ): t
Selected partition 1
Hex code (type L to list all codes): 7
Changed type of partition 'Linux' to 'HPFS/NTFS/exFAT'

 (m  ): p

Disk ws_e.img: 84.6 GB, 84557168640 bytes, 165150720 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xc617554d

-                       Id  
ws_e.img1            2048   165150719    82574336    7  HPFS/NTFS/exFAT

 (m  ): w
   !

 .

.. fdisk , .

3. Enlarge your FS

, . ext? resize2fs ( ), NTFS - ntfsresize.

.. ntfsresize --, "":

[root@ext images]# kpartx -av ws_e.img 
add map loop0p1 (253:0): 0 165148672 linear /dev/loop0 2048

:

[root@ext images]# fdisk -l /dev/loop0
...
-                       Id  
/dev/loop0p1            2048   165150719    82574336    7  HPFS/NTFS/exFAT
[root@ext images]# ls /dev/mapper
control  loop0p1

enlarge:

[root@ext images]# ntfsresize /dev/mapper/loop0p1
ntfsresize v2017.3.23 (libntfs-3g)
Device name        : /dev/mapper/loop0p1
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 67642585600 bytes (67643 MB)
Current device size: 84556120064 bytes (84557 MB)
New volume size    : 84556116480 bytes (84557 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use       : 64255 MB (95,0%)
Collecting resizing constraints ...
WARNING: Every sanity check passed and only the dangerous operations left.
Make sure that important data has been backed up! Power outage or computer
crash may result major data loss!
Are you sure you want to proceed (y/[n])? y
Schedule chkdsk for NTFS consistency check at Windows boot time ...
Resetting $LogFile ... (this might take a while)
Updating $BadClust file ...
Updating $Bitmap file ...
Updating Boot record ...
Syncing device ...
Successfully resized NTFS on device '/dev/mapper/loop0p1'.

(Note: ( - 5- ), .)

:

[root@ext images]# kpartx -dv /dev/loop0
del devmap : loop0p1

حسنا وطار:

[root@ext images]# virsh start win2k8r2
 win2k8r2   

ملاحظة

  • يمكن إجراء العملية رقم 3 (أو ربما حتى # 2) باستخدام Windows نفسه (إدارة الأقراص - قم بتوسيع وحدة التخزين) ، ولكن أ) لن تعمل مع قرص النظام ، و ب) المقالة ليست عن ذلك.

  • يتم تقليص الأقراص الظاهرية بترتيب عكسي (FS → القسم → القرص) ، ولكن حتى أكثر حذراً.

  • معظم العمليات قابلة للتطبيق للنقل بين الأقراص الحديدية.




All Articles