NAMEvirt- resize - Resize a virtual machine disk. SYNOPSIS virt- resize [- -resize /dev/sda. N=[+/- ]< size> [%]]. N] [- -shrink /dev/sda. N]. [- -ignore /dev/sda. N] [- -delete /dev/sda. N] [..] indisk outdisk. DESCRIPTIONVirt- resize is a tool which can resize a virtual machine disk, making it larger or smaller overall, and resizing or deleting any partitions contained within. Virt- resize cannot resize disk images in- place. Virt- resize should not be used on live virtual machines - for consistent results, shut the virtual machine down before resizing it. If you are not familiar with the associated tools: virt- filesystems(1) and virt- df(1), we recommend you go and read those manual pages first. EXAMPLESCopy olddisk to newdisk, extending one of the guest’s partitions to fill the extra 5. My suggestion is for Debian OS, but I think it would work also for Ubuntu and others. One possible way to solve a problem that occurs with lot of motherboards not. Statistical Techniques | Statistical Mechanics. GB of space. virt- filesystems - -long - h - -all - a olddisk. G newdisk. # Note "/dev/sda. As above, but make the /boot partition 2. MB bigger, while giving the remaining space to /dev/sda. M - -expand /dev/sda. ![]()
As in the first example, but expand a logical volume as the final step. This is what you would typically use for Linux guests that use LVM: virt- resize - -expand /dev/sda. LV- expand /dev/vg_guest/lv_root \. ![]() As in the first example, but the output format will be qcow. G. virt- resize - -expand /dev/sda. DETAILED USAGEEXPANDING A VIRTUAL MACHINE DISK1. Shut down the virtual machine. Locate input disk image. Locate the input disk image (ie. If the guest is managed by libvirt, you can use virsh dumpxml like this to find the disk image name: # virsh dumpxml guestname | xpath /domain/devices/disk/source. Found 1 nodes. < source dev="/dev/vg/lv_guest" /> 3. Look at current sizing. Use virt- filesystems(1) to display the current partitions and sizes: # virt- filesystems - -long - -parts - -blkdevs - h - a /dev/vg/lv_guest. Name Type Size Parent. M /dev/sda. /dev/sda. G /dev/sda. /dev/sda device 8. G - (This example is a virtual machine with an 8 GB disk which we would like to expand up to 1. GB). 4. Create output disk. Virt- resize cannot do in- place disk modifications. You have to have space to store the resized output disk. To store the resized disk image in a file, create a file of a suitable size: # rm - f outdisk. G outdisk. Or use lvcreate(1) to create a logical volume: # lvcreate - L 1. G - n lv_name vg_name. Or use virsh(1) vol- create- as to create a libvirt storage volume: # virsh pool- list. G5. Resizevirt- resize takes two mandatory parameters, the input disk and the output disk (both can be e. URI to a remote disk). The output disk is the one created in the previous step. This command just copies disk image indisk to disk image outdiskwithout resizing or changing any existing partitions. If outdisk is larger, then an extra, empty partition is created at the end of the disk covering the extra space. If outdisk is smaller, then it will give an error. More realistically you'd want to expand existing partitions in the disk image by passing extra options (for the full list see the "OPTIONS" section below)."- -expand" is the most useful option. It expands the named partition within the disk to fill any extra space: # virt- resize - -expand /dev/sda. In this case, an extra partition is not created at the end of the disk, because there will be no unused space)."- -resize" is the other commonly used option. The following would increase the size of /dev/sda. M, and expand /dev/sda. M - -expand /dev/sda. If the expanded partition in the image contains a filesystem or LVM PV, then if virt- resize knows how, it will resize the contents, the equivalent of calling a command such as pvresize(8), resize. However virt- resize does not know how to resize some filesystems, so you would have to online resize them after booting the guest. The input disk can be a URI, in order to use a remote disk as the source. The URI format is compatible with guestfish. See "ADDING REMOTE STORAGE" in guestfish(1). Other options are covered below. Test. Thoroughly test the new disk image before discarding the old one. If you are using libvirt, edit the XML to point at the new disk: # virsh edit guestname. Change < source ..> , see http: //libvirt. Disks. Then start up the domain with the new, resized disk: # virsh start guestnameand check that it still works. See also the "NOTES" section below for additional information. Resize LVs etc inside the guest(This can also be done offline using guestfish(1))Once the guest has booted you should see the new space available, at least for filesystems that virt- resize knows how to resize, and for PVs. The user may need to resize LVs inside PVs, and also resize filesystem types that virt- resize does not know how to expand. SHRINKING A VIRTUAL MACHINE DISKShrinking is somewhat more complex than expanding, and only an overview is given here. Firstly virt- resize will not attempt to shrink any partition content (PVs, filesystems). The user has to shrink content before passing the disk image to virt- resize, and virt- resize will check that the content has been shrunk properly.(Shrinking can also be done offline using guestfish(1))After shrinking PVs and filesystems, shut down the guest, and proceed with steps 3 and 4 above to allocate a new disk image. Then run virt- resize with any of the - -shrink and/or - -resize options. IGNORING OR DELETING PARTITIONSvirt- resize also gives a convenient way to ignore or delete partitions when copying from the input disk to the output disk. Ignoring a partition speeds up the copy where you don't care about the existing contents of a partition. Deleting a partition removes it completely, but note that it also renumbers any partitions after the one which is deleted, which can leave some guests unbootable. QCOW2 AND NON- SPARSE RAW FORMATSIf the input disk is in qcow. Alternately, virt- resize can convert the format on the fly. The output format is simply determined by the format of the empty output container that you provide. Thus to create qcow. Similarly, to get non- sparse raw output use: fallocate - l size outdisk(on older systems that don’t have the fallocate(1) command use dd if=/dev/zero of=outdisk bs=1. M count=.)LOGICAL PARTITIONSLogical partitions (a. DOS partition tables) cannot be resized. To understand what is going on, firstly one of the four partitions /dev/sda. MBR partition type 0. This is called the extended partition. Use virt- filesystems(1) to see the MBR partition type. Logical partitions live inside the extended partition. The extended partition can be expanded, but not shrunk (unless you force it, which is not advisable). When the extended partition is copied across, all the logical partitions contained inside are copied over implicitly. Virt- resize does not look inside the extended partition, so it copies the logical partitions blindly. You cannot specify a logical partition (/dev/sda. Doing so will give an error. OPTIONS- -help. Display help.- -align- firstauto- -align- firstnever- -align- firstalways. Align the first partition for improved performance (see also the - -alignment option). The default is - -align- first auto which only aligns the first partition if it is safe to do so. That is, only when we know how to fix the bootloader automatically, and at the moment that can only be done for Windows guests.- -align- first never means we never move the first partition. This is the safest option. Try this if the guest does not boot after resizing.- -align- first always means we always align the first partition (if it needs to be aligned). For some guests this will break the bootloader, making the guest unbootable.- -alignment NSet the alignment of partitions to N sectors. The default in virt- resize < 1. Assuming 5. 12 byte sector size inside the guest, here are some suitable values for this: -- alignment 1 (5. The partitions would be packed together as closely as possible, but would be completely unaligned. In some cases this can cause very poor performance. See virt- alignment- scan(1) for further details.- -alignment 8 (4. K)This would be the minimum acceptable alignment for reasonable performance on modern hosts.- -alignment 1. K)This alignment provides good performance when the host is using high end network storage.- -alignment 2. M)This is the standard alignment used by all newly installed guests since around 2. Use ANSI colour sequences to colourize messages. This is the default when the output is a tty.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
October 2017
Categories |