Wie kann ich zusätzlichen Festplattenspeicher unter Linux hinzufügen?

Loggen Sie sich mit SSH auf Ihren Server als User "

root

" ein.


Um Ihr Dateisystem anzuzeigen, verwenden Sie den Befehl "

df -h

":



 s123456789:~ # df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda1             9.2G  235M  8.5G   3% /
udev                  496M  112K  496M   1% /dev
/dev/hda5             9.4G  2.1G  7.3G  22% /usr
/dev/hda6             9.4G  148M  9.2G   2% /var
/dev/hda7             221G   22M  221G   1% /srv
none                  1.0G     0  1.0G   0% /tmp 

Ihre Partitionierung zeigen Sie mit dem Befehl "

fdisk -l

" an:



> s123456789:~ # fdisk -l
Disk /dev/hda: 343.5 GB, 343597383680 bytes
255 heads, 63 sectors/track, 41773 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000c8b23

    Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1        1217     9775521   83  Linux
/dev/hda2            1218        1461     1959930   82  Linux swap / Solaris
/dev/hda4            1462       32636   250408517+   5  Extended
/dev/hda5            1462        2678     9775521   83  Linux
/dev/hda6            2679        3895     9775521   83  Linux
/dev/hda7            3896       32635   230854018+  83  Linux 

Bitte beachten Sie:
  Vor einer Veränderung an der Partitionierung wird dringend empfohlen, eine Sicherung aller auf dem Server gespeicherten Daten anzulegen.

* Extended Partition erweitern:

In den Partitions-Modus gelangen Sie mit dem Befehl "

parted /dev/hda

". In der weiteren Eingabeaufforderung wählen Sie "

unit s

" aus und lassen sich die momentane Partitionstabelle mit "

print

" anzeigen.


Die zu vergrößernde Partition (immer die Partition vom Typ "

extended

" auswählen) wird mit ihrem Startpunkt ausgewählt, z.B. "

resize 4 23470965s -1

":



> s123456789:~ # parted /dev/hda
GNU Parted 1.8.8
Using /dev/had
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit s
(parted) print
Model: QEMU HARDDISK (ide)
Disk /dev/hda: 671088640s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start      End         Size        Type     File system  Flags
1      63s        19551104s   19551042s   primary   ext3         , , , , , , , , , type=83, ,
2      19551105s  23470964s   3919860s    primary   linux-swap   , , , , , , , , , type=82, ,
4      23470965s  524287999s  500817035s  extended               , , , , , , , , , type=05, ,
5      23471028s  43022069s   19551042s   logical   xfs          , , , , , , , , , type=83, ,
6      43022133s  62573174s   19551042s   logical   xfs          , , , , , , , , , type=83, , 
7      62573238s  524281274s  461708037s  logical   xfs          , , , , , , , , , type=83, ,

(parted) resize 4 23470965s -1
(parted) print
Model: QEMU HARDDISK (ide)
Disk /dev/hda: 671088640s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start      End         Size       Type     File system  Flags
1      63s        19551104s   19551042s   primary   ext3         , , , , , , , , , type=83, ,
2      19551105s  23470964s   3919860s    primary   linux-swap   , , , , , , , , , type=82, ,
4      23470965s  671088639s  647617675s  extended               , , , , , , , , , type=05, ,
5      23471028s  43022069s   19551042s   logical   xfs          , , , , , , , , , type=83, ,
6      43022133s  62573174s   19551042s   logical   xfs          , , , , , , , , , type=83, ,
7      62573238s  524281274s  461708037s  logical   xfs          , , , , , , , , , type=83, , 

Mit "

fdisk -l

" können Sie ihre vergrößerte Partition überprüfen.




Letzte Partition löschen und mit gleichem Startpunkt vergrößert wieder anlegen:


Rufen Sie den Befehl "

fdisk

" mit dem Parameter "

/dev/hda

" auf:


> s123456789:~ # fdisk /dev/hda
The number of cylinders for this disk is set to 41773.
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/2FDISK)
Command (m for help): 

Mit "

p

" geben Sie die Partitionstabelle aus:


> Command (m for help): p
		
Disk /dev/hda: 343.5 GB, 343597383680 bytes
255 heads, 63 sectors/track, 41773 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000c8b23
		
    Device Boot      Start        End      Blocks   Id  System
/dev/hda1               1        1217     9775521   83  Linux
/dev/hda2            1218        1461     1959930   82  Linux swap /Solaris
/dev/hda4            1462       41774   323808837+   5  Extended
/dev/hda5            1462        2678     9775521   83  Linux
/dev/hda6            2679        3895     9775521   83  Linux
/dev/hda7            3896       32635   230854018+  83  Linux
		
Command (m for help): 

Mit dem Befehl "

d

" und der Partitionsnummer löschen Sie eine vorhandene Partition



>Command (m for help): d
Partition number (1-7): 7 

und erstellen mit "

n

" eine neue logische (Befehl "

l

") Partition mit einem Start- und Endpunkt (beide Anfragen durch Enter auf Default setzen):


> Command (m for help): n
Command action
    l   logical (5 or over) 
    p   primary partition (1-4)
l		
First cylinder (3896-41774, default 3896):
Using default value 3896
Last cylinder or +size or +sizeM or +sizeK (3896-41774, default 41774):
Using default value 41774
	
Command (m for help): 

Mit "

p

" überprüfen Sie nun wieder die vergrößerte Partition und schreiben die Änderungen mit "

w

" fest:


> Command (m for help): p
		
Disk /dev/hda: 343.5 GB, 343597383680 bytes
255 heads, 63 sectors/track, 41773 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000c8b23
		
    Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1        1217     9775521   83  Linux
/dev/hda2            1218        1461     1959930   82  Linux swap /	 Solaris	
/dev/hda4            1462       41774   323808837+   5  Extended
/dev/hda5            1462        2678     9775521   83  Linux
/dev/hda6            2679        3895     9775521   83  Linux
/dev/hda7            3896       41774   304257701   83  Linux
		
Command (m for help): w 

Nach einem Reboot wird die geänderte Partitionstabelle neu eingelesen und das Dateisystem kann mit "

xfs_growfs

" und dem Mount "

/srv

" vergrößert werden:


> s123456789:~ # df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda1             9.2G  235M  8.5G   3% /
udev                  496M  112K  496M   1% /dev
/dev/hda5             9.4G  2.1G  7.3G  22% /usr
/dev/hda6             9.4G  148M  9.2G   2% /var
/dev/hda7             221G   22M  221G   1% /srv
none                  1.0G     0  1.0G   0% /tmp
s123456789:~ # xfs_growfs /srv
meta-data=/dev/hda7              isize=256    agcount=16, agsize=3607094 
blks		
          =                       sectsz=512   attr=0
data      =                       bsize=4096   blocks=57713504, imaxpct=25
          =                       sunit=0      swidth=0 blks 
naming    =version 2              bsize=4096
log       =internal               bsize=4096   blocks=28180, version=1
          =                       sectsz=512   sunit=0 blks, lazy-count=0
realtime  =none                   extsz=65536  blocks=0, rtextents=0
data blocks changed from 57713504 to 76064425
s123456789:~ # df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda1             9.2G  235M  8.5G   3% /
udev                  496M  112K  496M   1% /dev
/dev/hda5             9.4G  2.1G  7.3G  22% /usr
/dev/hda6             9.4G  148M  9.2G   2% /var
/dev/hda7             291G   22M  291G   1% /srv
none                  1.0G     0  1.0G   0% /tmp 



* Eine neue Partition erstellen

Eine neue Partition erstellen Sie ähnlich, wie eine neue, größere Partition, nur das Sie keine bestehende löschen. Sie gelangen in den Partitions-Modus mit dem Befehl "

parted /dev/hda

" und geben in der weiteren Eingabeaufforderung "

n

" für eine neue logische (Parameter "

l

") Partition an (Mit "

p

" sehen Sie die bestehenden Partitionen). Setzen Sie die folgenden Anfragen mit Enter auf Default:



> s123456789:~ # fdisk /dev/hda
		
The number of cylinders for this disk is set to 52216.
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): n
Command action
    l   logical (5 or over)
    p   primary partition (1-4)
l		
First cylinder (41775-52217, default 41775):
Using default value 41775
Last cylinder or +size or +sizeM or +sizeK (41775-52217, default 52217):
Using default value 52217 

Mit "

w

" schreiben Sie die Änderungen fest.


Mit den Befehlen "

mkfs.xfs /dev/hda8

", "

mkdir /srv2

" und anschließendem "

mount /dev/hda8 /srv2

" erstellen Sie eine neue Partition mit einem Verzeichnis "

srv2

" und mounten die neue Partition:



> s123456789:~ # mkfs.xfs /dev/hda8
meta-data=/dev/hda8              isize=256    agcount=4, agsize=5242545 blks		
          =                       sectsz=512   attr=2
data      =                       bsize=4096   blocks=20970178, imaxpct=25
          =                       sunit=0      swidth=0 blks
naming    =version 2              bsize=4096
log       =internal log           bsize=4096   blocks=10239, version=2
          =                       sectsz=512   sunit=0 blks, lazy-count=0
realtime  =none                   extsz=4096   blocks=0, rtextents=0
s123456789:~ # mkdir /srv2
s123456789:~ # mount /dev/hda8 /srv2