We use XenServer 6.5

Here is an “ext4” filesystem on RedHat family 7.x :

[root@xenserver_vm ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[root@xenserver_vm data]# df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvdb1      991M  396M  529M  43% /data

We would like to extend this filesystem without loosing data …

Extend XenServer virtual disk

It’s not possible to extend a virtual drive when it is used :

xenextenddisk

 

 

 

 

 

 

 

 

 

 

 

 

So, umount the filesystem :

[root@xenserver_vm ~]# umount /data

Using XenCenter, we can deactivate the virtual drive :

xenextenddisk1

 

 

 

 

 

 

 

 

 

And extend the disk size :

  • click on “properties” :

xenextenddisk2

 

 

 

 

 

 

 

 

 

 

 

 

Enter your new size and validate …

Don’t forget to active this disk :

xenextenddisk3

 

 

 

 

 

 

 

 

Extend the filesystem

Using “fdisk” utility,

[root@xenserver_vm ~]# fdisk -l /dev/xvdb

Disk /dev/xvdb: 4294 MB, 4294967296 bytes, 8388608 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: 0x28759f76

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdb1            2048     2097151     1047552   83  Linux
[root@xenserver_vm ~]# fdisk /dev/xvdb
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.
  • We have 1 partition only :
Command (m for help): p

Disk /dev/xvdb: 4294 MB, 4294967296 bytes, 8388608 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: 0x28759f76

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdb1            2048     2097151     1047552   83  Linux
  • Delete this partition :
Command (m for help): d
Selected partition 1
Partition 1 is deleted
  • To recreate it with default values :
Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-8388607, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-8388607, default 8388607):
Using default value 8388607
Partition 1 of type Linux and of size 4 GiB is set
  • Commit this change :
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

Launch “kpartx” :

[root@xenserver_vm ~]# kpartx /dev/xvdb
xvdb1 : 0 8386560 /dev/xvdb 2048

Once again, umount this filesystem :

[root@xenserver_vm ~]# umount /data

Launch fdisk once again to write the new partition table :

[root@xenserver_vm ~]# fdisk /dev/xvdb
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.


Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Check this filesystem :

[root@xenserver_vm ~]# e2fsck -f /dev/xvdb1
e2fsck 1.42.9 (28-Dec-2013)
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
data: 14/65536 files (0.0% non-contiguous), 109486/261888 blocks

Extend this filesystem :

[root@xenserver_vm ~]# resize2fs /dev/xvdb1
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/xvdb1 to 1048320 (4k) blocks.
The filesystem on /dev/xvdb1 is now 1048320 blocks long.

Remout this filesystem :

[root@xenserver_vm ~]# mount /data

The filesystem size is now 4 GB :

[root@xenserver_vm ~]# df -hT /data
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/xvdb1     ext4  4.0G  4.0M  3.8G   1% /data

 

www.pdf24.org    Send article as PDF   

Leave a Reply

Your email address will not be published. Required fields are marked *


*