Le but du jeu ici est, comme le titre l'indique, d'augmenter la taille d'une partition ext3, et ce sans que tu perdes tes données.
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 129G 54G 69G 45% /
none 2.0G 188K 2.0G 1% /dev
none 2.0G 0 2.0G 0% /dev/shm
none 2.0G 64K 2.0G 1% /var/run
none 2.0G 0 2.0G 0% /var/lock
none 2.0G 0 2.0G 0% /lib/init/rw
/dev/sdb1 247G 234G 0 100% /mnt/iscsi
oula !!! ta partition /dev/sdb1 a les dents du fond qui baignent...
# fdisk -l
Disk /dev/sda: 146.2 GB, 146163105792 bytes
255 heads, 63 sectors/track, 17769 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000ee61d
Device Boot Start End Blocks Id System
/dev/sda1 * 1 17044 136898560 83 Linux
/dev/sda2 17044 17770 5835777 5 Extended
/dev/sda5 17044 17770 5835776 82 Linux swap / Solaris
Disk /dev/sdb: 594.9 GB, 594852971008 bytes
255 heads, 63 sectors/track, 72320 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x3258a148
Device Boot Start End Blocks Id System
/dev/sdb1 1 32635 262140606 83 Linux
Si tu te referes a ces données tu t'aperçois que tu n'utilise que la moitié de l'espace disque disponible.
Avant tout chose, lance une réparation du ton disque :
# fsck -n /dev/sdb1
fsck from util-linux-ng 2.17.2
e2fsck 1.41.11 (14-Mar-2010)
/dev/sdb1 contains a file system with errors, check forced.
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
/dev/sdb1: 154359/16384000 files (9.9% non-contiguous), 62258410/65535151 blocks
Pour effectuer l'extension de ta partition, tu vas devoir utiliser
resize2fs. Petit problème ta partition est en ext3,
donc une des etapes va consister a convertir ta partition ext3 en ext2 en supprimant son journal :
# tune2fs -O ^has_journal /dev/sdb1
tune2fs 1.41.11 (14-Mar-2010)
Mieux vaux être prudent, check a nouveau ta partoche une fois la conversion en ext2 effectuée...
# e2fsck -f /dev/sdb1
e2fsck 1.41.11 (14-Mar-2010)
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
/dev/sdb1: 154359/16384000 files (9.9% non-contiguous), 62225609/65535151 blocks
Don't panic jusqu'ici tu n'as toujours pas perdu tes données
Maintenant tu es prêt a étendre ta partition like this... :
# resize2fs /dev/sdb1 540000M
resize2fs 1.41.11 (14-Mar-2010)
The containing partition (or device) is only 65535151 (4k) blocks.
You requested a new size of 138240000 blocks.
"540000M" dans notre cas on imagine que l'on souhaite doubler la taille de notre partition...
il ne te reste plus qu'à détruire ta partition /dev/sdb1 et a la recréer
# fdisk /dev/sdb
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
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): 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-72320, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-72320, default 72320):
Using default value 72320
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Allez, fais moi plaisir check la partition a nouveau
# fsck -n /dev/sdb1
fsck from util-linux-ng 2.17.2
e2fsck 1.41.11 (14-Mar-2010)
/dev/sdb1: clean, 154359/34562048 files, 63369250/138240000 blocks
Ta partition passe de 65535151 a 138240000 bloques c'est plutôt bon signe :-)
Il ne reste plus qu'a reconstruire le journal :
# tune2fs -j /dev/sdb1
tune2fs 1.41.11 (14-Mar-2010)
Creating journal inode: done
This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
et à remonter ta partition :
# mount /dev/sdb1 /mnt/iscsi
Et roulement de tambour, tadaaaaammmm incredible magical :
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 129G 54G 69G 45% /
none 2.0G 188K 2.0G 1% /dev
none 2.0G 0 2.0G 0% /dev/shm
none 2.0G 64K 2.0G 1% /var/run
none 2.0G 0 2.0G 0% /var/lock
none 2.0G 0 2.0G 0% /lib/init/rw
/dev/sdb1 520G 234G 260G 48% /mnt/iscsi
tu es un winner...