This part is automatic and comparable to the Gandi AI procedure
Important:
All virtual disks created in France after April 2011 (in the USA since December 2010) are on the new storage platform, you should not follow the procedural descrived below.Just type as root the following command to "hot-resize" your disks, system, data or backup : "resize2fs /dev/xvdX".
This procedure applies to data disks, without partitions.
First of all, it is necessary to verify the file system, to correct any existing errors on the disk, so that it can then be marked as "clean" and thus resized. The following example is based on the disk /dev/xvdb:
# umount /dev/xvdb # e2fsck -f /dev/xvdb e2fsck 1.40.2 (12-Jul-2007) Passe 1 : vérification des i-noeuds, des blocs et des tailles Passe 2 : vérification de la structure des répertoires Passe 3 : vérification de la connectivité des répertoires Passe 4 : vérification des compteurs de référence Passe 5 : vérification de l'information du sommaire de groupe disque2: 11/3014656 files (9.1% non-contiguous), 134435/6029312 blocks
If e2fsck indicates that there are problems, it is necessary to correct them before continuing.
Once the disk has been verified, and any errors corrected, it is possible to change the size of the file system so that it corresponds to the size of the disk:
# resize2fs /dev/xvdb Resizing the filesystem on /dev/xvdb to 6815744 (4k) blocks. Le système de fichiers /dev/xvdb a maintenant une taille de 6815744 blocs.
Resizing a system disk is a delecate and risky procedure. In the event that an error occurs during the deletion and the creation of partitions, it is possible to loose its system disk. Please, therefore, proceed with extreme care.
First of all, it is imperitive to deactivate the Swap, as the partition that contains it will be deleted.
# swapoff /dev/xvda2
Next, you will need to launch an fdisk to change the partitions. There are two partitions, the system partition and the one used for swap. The two will be deleted, the system partition will be enlarged.
# fdisk /dev/xvda
The number of cylinders for this disk is set to 5221.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/xvda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/xvda1 1 312 2506108+ 83 Linux
/dev/xvda2 313 391 634567+ 82 Linux swap / Solaris
The display is changed to sectors:
Command (m for help): u Changing display/entry units to sectors
The swap is deleted:
Command (m for help): d
Partition number (1-4): 2
Command (m for help): p
Disk /dev/xvda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System
/dev/xvda1 63 5012279 2506108+ 83 Linux
Next, the system partition is deleted:
Command (m for help): d Selected partition 1
Now that the two partitions have been deleted, they need to be created again. First, re-create the system partition with the correct size. In our example, it is 40 GB.
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First sector (63-83886079, default 63):
Using default value 63
Last sector or +size or +sizeM or +sizeK (63-83886079, default 83886079): +40G
Command (m for help): p
Disk /dev/xvda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System
/dev/xvda1 63 78125063 39062500+ 83 Linux
Next, it is necessary to recreate the Swap partition.
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First sector (78125064-83886079, default 78125064): Using default value 78125064 Last sector or +size or +sizeM or +sizeK (78125064-83886079, default 83886079): Using default value 83886079
Then, give the swap partition the type, "Linux swap":
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 82
Changed system type of partition 2 to 82 (Linux swap / Solaris)
Command (m for help): p
Disk /dev/xvda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System
/dev/xvda1 63 78125063 39062500+ 83 Linux
/dev/xvda2 78125064 83886079 2880508 82 Linux swap / Solaris
Finally, save all the modifications
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: Périphérique ou ressource occupé. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks.
You will eventually need to force the fsck on rebooting, according to the distribution, and reboot:
# touch /forcefsck # reboot
If the fsck did not occur during the boot, it will be necessary to perform it. For this, you will first need to perform a "lsof" and "kill" any processes that have w/u in / :
# mount -o remount,ro / # fsck -f /dev/xvda1 fsck 1.40-WIP (14-Nov-2006) e2fsck 1.40-WIP (14-Nov-2006) Passe 1 : vérification des i-noeuds, des blocs et des tailles Passe 2 : vérification de la structure des répertoires Passe 3 : vérification de la connectivité des répertoires Passe 4 : vérification des compteurs de référence Passe 5 : vérification de l'information du sommaire de groupe DEBIAN4: 20503/313600 files (2.2% non-contiguous), 156236/626527 blocks
If the corrections occurred during the fsck it will be necessary to reboot. Otherwise, all that remains is resizing the file system.
For this, we use resize2fs:
# resize2fs /dev/xvda1 resize2fs 1.40-WIP (14-Nov-2006) Filesystem at /dev/xvda1 is mounted on /; on-line resizing required old desc_blocks = 1, new_desc_blocks = 3 Performing an on-line resize of /dev/xvda1 to 9765625 (4k) blocks. Le système de fichiers /dev/xvda1 a maintenant une taille de 9765625 blocs.
It is possible to check the size of the disk with the df command:
# df -h Sys. de fich. Tail. Occ. Disp. %Occ. Monté sur /dev/xvda1 37G 576M 36G 2% /
Last modified: 28 Nov 2011 at 11:02 by Romuald B. (Gandi)