[pve-devel] Bug? Resize is not possible

Wolfgang Bumiller w.bumiller at proxmox.com
Tue Sep 1 13:32:32 CEST 2015


Please use the 'Reply-All' button in your mail-client or otherwise make
sure you include the 'Cc: pve-devel at pve.proxmox.com' part.

On Tue, Sep 01, 2015 at 12:13:28PM +0200, Detlef Bracker wrote:
> Dear:
> 
> root at localhost:~# fdisk -l /dev/vdb
> 
> Disk /dev/vdb: 64.4 GB, 64424509440 bytes
> 4 heads, 32 sectors/track, 983040 cylinders, total 125829120 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 identifier: 0x000c3fb3
> 
>    Device Boot      Start         End      Blocks   Id  System
> /dev/vdb1            2048    41943039    20970496   83  Linux
> root at localhost:~#
> 
> I have too tested with parted to resize the partition, but I get every an
> error

parted won't let you resize the partition while it is mounted as it
wants to resize the underlying filesystem as well afaik.

In order to resize it with fdisk you have to delete and create the
partition in a single fdisk session (dangerous!).

Here's an example session, and a few things to keep in mind:
*) Make sure you have a backup!
*) The 'start' block of the partition MUST stay the same! (Otherwise all
   your data WILL be lost!)
*) Make sure you have a backup!

Step 1 - resize partition: ('Start' must stay the same!)

    # fdisk /dev/zvol/tank/testvol
    
    Welcome to fdisk (util-linux 2.25.2).
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.
    
    
    Command (m for help): p
    Disk /dev/zvol/tank/testvol: 60 GiB, 64424509440 bytes, 125829120 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 8192 bytes
    I/O size (minimum/optimal): 8192 bytes / 8192 bytes
    Disklabel type: dos
    Disk identifier: 0xc44a5da5
    
    Device                  Boot Start      End  Sectors Size Id Type
    /dev/zvol/tank/testvol1       2048 41945087 41943040  20G 83 Linux
**----------------------> NOTE___/^^^^
    
    
    Command (m for help): d
    Selected partition 1
    Partition 1 has been deleted.
    
    Command (m for help): n
    Partition type
       p   primary (0 primary, 0 extended, 4 free)
       e   extended (container for logical partitions)
    Select (default p): p
    Partition number (1-4, default 1): 1
** double check the next line!
    First sector (2048-125829119, default 2048): 2048
    Last sector, +sectors or +size{K,M,G,T,P} (2048-125829119, default 125829119): 
** in your case you can probably use defaults on the two lines above
    
    Created a new partition 1 of type 'Linux' and of size 60 GiB.
    
    Command (m for help): p
    Disk /dev/zvol/tank/testvol: 60 GiB, 64424509440 bytes, 125829120 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 8192 bytes
    I/O size (minimum/optimal): 8192 bytes / 8192 bytes
    Disklabel type: dos
    Disk identifier: 0xc44a5da5
    
    Device                  Boot Start       End   Sectors Size Id Type
    /dev/zvol/tank/testvol1       2048 125829119 125827072  60G 83 Linux
**----------------------> NOTE___/^^^^
    
    
    Command (m for help): w
    The partition table has been altered.
    Calling ioctl() to re-read partition table.
    Syncing disks.

Step 2 - Reload partition table:

    # partprobe

Step 3 - Resize filesystem:

    # resize2fs /dev/zvol/tank/testvol-part1
    resize2fs 1.42.12 (29-Aug-2014)
    Resizing the filesystem on /dev/zvol/tank/testvol-part1 to 15728384 (4k) blocks.
    The filesystem on /dev/zvol/tank/testvol-part1 is now 15728384 (4k) blocks long.

> ### /DEV/VDB not possible:
> 
> root at localhost:~# parted /dev/vdb
> GNU Parted 2.3
> Using /dev/vdb
> Welcome to GNU Parted! Type 'help' to view a list of commands.
> (parted) print
> Model: Virtio Block Device (virtblk)
> Disk /dev/vdb: 64.4GB
> Sector size (logical/physical): 512B/512B
> Partition Table: msdos
> 
> Number  Start   End     Size    Type     File system  Flags
>  1      1049kB  21.5GB  21.5GB  primary  ext4
> 
> (parted) resize 1
> WARNING: you are attempting to use parted to operate on (resize) a file
> system.
> parted's file system manipulation code is not as robust as what you'll
> find in
> dedicated, file-system-specific packages like e2fsprogs.  We recommend
> you use parted only to manipulate partition tables, whenever possible.
> Support for performing most operations on most types of file systems
> will be removed in an upcoming release.
> Error: Partition /dev/vdb1 is being used. You must unmount it before you
> modify it with Parted.
> (parted) quit
> 
> root at localhost:~# parted /dev/vdb1
> GNU Parted 2.3
> Using /dev/vdb1
> Welcome to GNU Parted! Type 'help' to view a list of commands.
> 
> (parted) print
> Model: Virtio Block Device (virtblk)
> Disk /dev/vdb1: 21.5GB
> Sector size (logical/physical): 512B/512B
> Partition Table: loop
> 
> ### NOW parted ON /dev/vdb1:
> 
> Number  Start  End     Size    File system  Flags
>  1      0.00B  21.5GB  21.5GB  ext4
> 
> (parted) resize 1
> WARNING: you are attempting to use parted to operate on (resize) a file
> system.
> parted's file system manipulation code is not as robust as what you'll
> find in
> dedicated, file-system-specific packages like e2fsprogs.  We recommend
> you use parted only to manipulate partition tables, whenever possible.
> Support for performing most operations on most types of file systems
> will be removed in an upcoming release.
> Start? 0
> End?  [21.5GB]? 60GB
> Error: The location 60GB is outside of the device /dev/vdb1.
> (parted)
> (parted) resize 1
> WARNING: you are attempting to use parted to operate on (resize) a file
> system.
> parted's file system manipulation code is not as robust as what you'll
> find in
> dedicated, file-system-specific packages like e2fsprogs.  We recommend
> you use parted only to manipulate partition tables, whenever possible.
> Support for performing most operations on most types of file systems
> will be removed in an upcoming release.
> Start? 0
> End?  [21.5GB]? 30GB
> Error: The location 30GB is outside of the device /dev/vdb1.
> 
> Regards
> 
> Detlef
> 
> Am 01.09.2015 um 11:53 schrieb Wolfgang Bumiller:
> > On Tue, Sep 01, 2015 at 11:45:11AM +0200, Detlef Bracker wrote:
> >> Dear,
> >>
> >> I can doe what I will, the /vdb1 in qcow2 OR now in raw-Format has 61,4 GB
> >> They use 512 Byte Blocks:
> >>
> >> root at localhost:~# fdisk -l
> >>
> > (...)
> >> Disk /dev/vdb: 64.4 GB, 64424509440 bytes
> >> 4 heads, 32 sectors/track, 983040 cylinders, total 125829120 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 identifier: 0x000c3fb3
> > I don't see a partition list for vdb here, only vda above. Is that all
> > you get from `fdisk -l /dev/vdb`? If so, what kind of partition table is
> > used on vdb?
> >
> >> root at localhost:~# e2fsck -f /dev/vdb1
> >> e2fsck 1.42.5 (29-Jul-2012)
> >> Pass 1: Checking inodes, blocks, and sizes
> >> Pass 2: Checking directory structure
> >> Pass 3: Checking directory connectivity
> >> Pass 4: Checking reference counts
> >> Pass 5: Checking group summary information
> >> root: 31286/983040 files (0.1% non-contiguous), 277080/3932160 blocks
> >> root at localhost:~# resize2fs /dev/vdb1 60G
> > Note that you can leave out the size argument completely if you want to
> > make it use the entire partition.
> >
> >> resize2fs 1.42.5 (29-Jul-2012)
> >> The containing partition (or device) is only 5242624 (4k) blocks.
> >> You requested a new size of 15728640 blocks.
> > So the partition isn't big enough. Maybe you only resized the disk but
> > not the partition table of vdb. As mentioned above, your output only
> > includes the partition table of vda.
> >
> > Did you resize the disk while the machine is running? If that's the case
> > make sure to send a `block_resize` qemu-monitor command, otherwise the
> > running VM won't see the change in size. (You can use the vm's 'Monitor'
> > tab in the GUI.)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.proxmox.com/pipermail/pve-devel/attachments/20150901/7f5b71aa/attachment.sig>


More information about the pve-devel mailing list