Jika partisi pada harddisk anda penuh, bisa di resize secara online, artinya ditambah pada saat server sedang online atau produksi. Ini dilakukan pada sistem operasi linux yang memiliki partisi jenis ext3.
Tujuan saya adalah menambah partisi root yang sebelumnya hanya 2 GB dan sudah penuh, untuk ini saya mau jadikan 4 GB. Caranya menggunakan fdisk dan resize2fs, jangan takut kehilangan data, kalau mau backup dulu bisa juga, tapi dalam pekerjaan ini saya tidak backup.
[root@ID41-ND013 gtoms]# /sbin/fdisk -l
Disk /dev/xvda: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/xvda1 * 1 261 2096451 83 Linux
Disk /dev/xvdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/xvdb doesn’t contain a valid partition table
Disk /dev/xvdc: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/xvdc doesn’t contain a valid partition table
[root@ID41-ND013 gtoms]# /sbin/fdisk /dev/xvda
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): p
Disk /dev/xvda: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/xvda1 * 1 261 2096451 83 Linux
Command (m for help): d
Selected partition 1
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-522, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-522, default 522):
Using default value 522
Command (m for help): a
Partition number (1-4): 1
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.
Syncing disks.
[root@ID41-ND013 gtoms]# reboot
Broadcast message from root (pts/1) (Mon May 10 13:35:54 2010):
The system is going down for reboot NOW!
[root@ID41-ND013 gtoms]# Connection to 10.62.41.13 closed by remote host.
Connection to 10.62.41.13 closed.
[root@ID41-ND201 ~]# ssh 10.62.41.13 -l root
root@10.62.41.13’s password:
Setelah direboot bisa dicek partisi masih 2 GB
[root@ID41-ND013 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/xvda1 2030736 1783504 142412 93% /
tmpfs 262144 0 262144 0% /dev/shm
/dev/xvdc 2064208 68684 1890668 4% /opt
Kita mulai resize partisi :
[root@ID41-ND013 ~]# resize2fs /dev/xvda1
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/xvda1 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/xvda1 to 1048233 (4k) blocks.
The filesystem on /dev/xvda1 is now 1048233 blocks long.
Cek kembali dan voila partisi sudah menjadi 4 GB :
[root@ID41-ND013 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 3.9G 1.8G 2.0G 47% /
tmpfs 256M 0 256M 0% /dev/shm
/dev/xvdc 2.0G 68M 1.9G 4% /opt
selesai.