• Willkommen im Linux Club - dem deutschsprachigen Supportforum für GNU/Linux. Registriere dich kostenlos, um alle Inhalte zu sehen und Fragen zu stellen.

Systempartition online erweitern?

Hallo,

mein Webserver geht so langsam der Platz aus. Der Server ist ein Suse SLES 11 SP11 in der VMWare virtualisiert und ich habe hier schonmal 100G draufgepackt.

fdisk -l zeigt auch schon die größere Platte an:

Code:
Disk /dev/sda: 214.7 GB, 214748364800 bytes

Device Boot   Start    End    Blocks        Id   System
/dev/sda1         1      262    2104483+   82   Linux swap / Solaris
/dev/sda2      263    13054  102751740  83   Linux

Aber die /dev/sda2 muss noch vergrößert werden.

df -H zeigt
Code:
Filesystem    Size    Used    Avail    Use%    Mounted on
/dev/sda2    104G    87G     12G     89%     /
udev           2.1G     91k      2.1G   1%       /dev
tmpfs          2.1G     0         2.1G   0%       /dev/shm


Ich hatte es zuerst mit yast versucht, aber das funktioniert nicht,
weil /dev/sda2 gemountet ist.
umount geht leider auch nicht, weil ja System-Partition.

Im Single User Mode, wo ich unmounten kann, funktioniert aber yast nicht.

Und wenn ich resize2fs /dev/sda2 aufrufe:
Code:
The filesystem is already 25687935 block long. Nothing to do.

Was muss ich machen, damit ich die Partition um den freien Platz erweitern kann?
 
Boote von der SLES-DVD bzw deren ISO und geh auf die repair-Option. Dort im Experts-Teil findest Du den von yast bekannten Partitionierer.
 
OP
K

kschroeder

Newbie
Also geht es nicht direkt online? Auch nicht im Single User Mode?
Ich muss zwingend von der DVD booten?
 

josef-wien

Ultimate Guru
Voraussetzung für resize2fs ist natürlich, daß die Partition groß genug ist (und die wirst Du im laufenden Betrieb nicht vergrößern können).

P. S. Wenn Dir Deine Daten auch nur ein bißchen wichtig sind, sollstest Du Deine Aktion mit parted ausreichend üben (ich würde daher die GParted-Live-CD nehmen und trotzdem vorher alle Daten sichern). Im übrigen solltest Du über LVM nachdenken.
 
A

Anonymous

Gast
josef-wien schrieb:
Voraussetzung für resize2fs ist natürlich, daß die Partition groß genug ist (und die wirst Du im laufenden Betrieb nicht vergrößern können).
es ist mindestens ein reboot notwendig, ganz online geht es nicht.

hier mal der Konsolausdruck eines Tests mit SLES11 SP2 auf einer virtuellen Maschine. Diese hier vorgestellte Konsol-Methode ist aber nichts für Weicheier, es kommt mit nur einem reboot und damit kürzeste Ausfallzeit für den Rechner aus, die maximale Patitionsgröße wird hier manuell berechnet. Und wie schon erwähnt, ohne ein funktionierendes Backup im Hintergrund zu haben geht da schon mal gar nichts in die Tüte.

Code:
VM-SLES:~ # uname -a
Linux VM-SLES 3.0.13-0.27-pae #1 SMP Wed Feb 15 13:33:49 UTC 2012 (d73692b) i686 i686 i386 GNU/Linux
VM-SLES:~ # cat /etc/SuSE-release 
SUSE Linux Enterprise Server 11 (i586)
VERSION = 11
PATCHLEVEL = 2

VM-SLES:~ # fdisk -l

Disk /dev/sda: 17.2 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders, total 33554432 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: 0x00035ced

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048     2105343     1051648   82  Linux swap / Solaris
/dev/sda2   *     2105344    16787455     7341056   83  Linux
VM-SLES:~ # sfdisk -d /dev/sda > /tmp/sda.txt
VM-SLES:~ # cat /tmp/sda.txt
# partition table of /dev/sda
unit: sectors

/dev/sda1 : start=     2048, size=  2103296, Id=82
/dev/sda2 : start=  2105344, size= 14682112, Id=83, bootable
/dev/sda3 : start=        0, size=        0, Id= 0
/dev/sda4 : start=        0, size=        0, Id= 0

# hier wird jetzt die Größe berechnet aus den Angaben von  "total sectors" von fsdisk und  von "start" von sda2 aus dem sfdisk-Dump
# die daraus errechnet maximale Größe wird dann in der Dump-Datei-Ausabe von fsdisk ersetzt.
# und anschließend diese geänderten Partitionsdaten auf die Platte geschrieben. 

VM-SLES:~ # echo "33554432 - 2105344" | bc
31449088
VM-SLES:~ # sed -i 's/14682112/31449088/' /tmp/sda.txt 
VM-SLES:~ # cat /tmp/sda.txt 
# partition table of /dev/sda
unit: sectors

/dev/sda1 : start=     2048, size=  2103296, Id=82
/dev/sda2 : start=  2105344, size= 31449088, Id=83, bootable
/dev/sda3 : start=        0, size=        0, Id= 0
/dev/sda4 : start=        0, size=        0, Id= 0
VM-SLES:~ # sfdisk -f /dev/sda < /tmp/sda.txt 
Checking that no-one is using this disk right now ...
BLKRRPART: Device or resource busy

This disk is currently in use - repartitioning is probably a bad idea.
Umount all file systems, and swapoff all swap partitions on this disk.
Use the --no-reread flag to suppress this check.

Disk /dev/sda: 2088 cylinders, 255 heads, 63 sectors/track
Old situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sda1          0+    131-    131-   1051648   82  Linux swap / Solaris
/dev/sda2   *    131+   1044-    914-   7341056   83  Linux
/dev/sda3          0       -       0          0    0  Empty
/dev/sda4          0       -       0          0    0  Empty
New situation:
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/sda1          2048   2105343    2103296  82  Linux swap / Solaris
/dev/sda2   *   2105344  33554431   31449088  83  Linux
/dev/sda3             0         -          0   0  Empty
/dev/sda4             0         -          0   0  Empty
Warning: partition 1 does not end at a cylinder boundary
Successfully wrote the new partition table

Re-reading the partition table ...
BLKRRPART: Device or resource busy
The command to re-read the partition table failed.
Run partprobe(8), kpartx(8) or reboot your system now,
before using mkfs

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)

# Partitionstabelle ist jetzt neu geschrieben, aber kann noch nicht vom Kernel benutzt werden, 
# wir versuchen es nocheinmal mit partprobe zu erwingen.

VM-SLES:~ # partprobe /dev/sda
Error: Partition(s) 2 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use.  As a result, the old partiti
on(s) will remain in use.  You should reboot now before making further changes.
VM-SLES:~ # cat /proc/partitions 
major minor  #blocks  name

   8        0   16777216 sda
   8        1    1051648 sda1
   8        2    7341056 sda2

# hier wird jetzt ein reboot notwendig, da sich Linux auch mit partpobe weigert die Partitionstabelle neu in den Kernel einzulesen solange sda1=swap und sda2=Rootfilesystem 
# nicht beides ausgehängt ist, was natürlich zumindestens bei sda2 nicht geht.

VM-SLES: ~ # init 6

............

VM-SLES:~ # sync
VM-SLES:~ # resize2fs /dev/sda2
resize2fs 1.41.9 (22-Aug-2009)
Filesystem at /dev/sda2 is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/sda2 to 3931136 (4k) blocks.
The filesystem on /dev/sda2 is now 3931136 blocks long.

# Ergebnis zeigt jetzt, das wir jetzt hier ein 15GB Dateisystem haben, vorher war es mindestens die Hälfte kleiner,
# habe leider vergessen das auch am Anfang entsprechend zu dokumentieren. ;-(

VM-SLES:~ # fdisk -l

Disk /dev/sda: 17.2 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders, total 33554432 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: 0x00035ced

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048     2105343     1051648   82  Linux swap / Solaris
/dev/sda2   *     2105344    33554431    15724544   83  Linux
VM-SLES:~ # df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda2       15477264 4724132   9966956  33% /
devtmpfs          250600     204    250396   1% /dev
tmpfs             250600    1076    249524   1% /dev/shm
VM-SLES:~ #

robi
 
Oben