linuxsec23

New Member
Joined
Apr 10, 2019
Messages
4
Reaction score
1
Credits
0
Hello Linux community

I will write this in english to get more requests.

I have a big problem. One of our customers wanted to extend the harddisk for his server. This was extended a lot of times but one of our colleagues did this before. I never

In VMWare Vsphere i have extended the storage from 540 to 640 GB. Done
In linux i have done the rescan of the scsi devices. Done
Creation and Extension of the new diskspace . Not possible without reboot

ls -la /sys/class/scsi_host/
##############################################
lrwxrwxrwx 1 root root 0 Apr 9 15:50 host0 -> ../../devices/pci0000:00/0000:00:07.1/ata1/host0/scsi_host/h ost0
lrwxrwxrwx 1 root root 0 Apr 9 15:50 host1 -> ../../devices/pci0000:00/0000:00:07.1/ata2/host1/scsi_host/h ost1
lrwxrwxrwx 1 root root 0 Apr 9 15:50 host2 -> ../../devices/pci0000:00/0000:00:10.0/host2/scsi_host/host2
##############################################

##############################################
echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan
##############################################




Here he is now able to show me the new diskspace which i can use but when i want to add a new disk (extended or primary) he is only able to add a 1024000Kb partition WHY??
fdisk -l
##############################################
Disk /dev/sda: 640 GiB, 687194767360 bytes, 1342177280 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
Disklabel type: dos
Disk identifier: 0x151722cb

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 1001470 1132462079 1131460610 539.5G 5 Extended
/dev/sda5 1001472 629145600 628144129 299.5G 8e Linux LVM
/dev/sda6 629149696 713031679 83881984 40G 8e Linux LVM
/dev/sda7 713033728 817889279 104855552 50G 8e Linux LVM
/dev/sda8 817891328 922746879 104855552 50G 8e Linux LVM
/dev/sda9 922748928 1027604479 104855552 50G 8e Linux LVM
/dev/sda10 1027606528 1132462079 104855552 50G 8e Linux LVM
##############################################


This is the output of my volume group display

vgdisplay -v
##############################################
Using volume group(s) on command line.
--- Volume group ---
VG Name 01-vg
System ID
Format lvm2
Metadata Areas 6
Metadata Sequence No 15
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 6
Act PV 6
VG Size 539.50 GiB
PE Size 4.00 MiB
Total PE 138112
Alloc PE / Size 138112 / 539.50 GiB
Free PE / Size 0 / 0
VG UUID

--- Logical volume ---
LV Path /dev/01-vg/root
LV Name root
VG Name 01-vg
LV UUID
LV Write Access read/write
LV Creation host, time 01, 2017-08-15 12:23:25 +0200
LV Status available
# open 1
LV Size 538.50 GiB
Current LE 137857
Segments 7
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0

--- Logical volume ---
LV Path /dev/01-vg/swap_1
LV Name swap_1
VG Name ....-vg
LV UUID
LV Write Access read/write
LV Creation host, time , 2017-08-15 12:23:25 +0200
LV Status available
# open 2
LV Size 1020.00 MiB
Current LE 255
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:1

--- Physical volumes ---
PV Name /dev/sda5
PV UUID
PV Status allocatable
Total PE / Free PE 76677 / 0

PV Name /dev/sda6
PV UUID
PV Status allocatable
Total PE / Free PE 10239 / 0

PV Name /dev/sda7
PV UUID
PV Status allocatable
Total PE / Free PE 12799 / 0

PV Name /dev/sda8
PV UUID
PV Status allocatable
Total PE / Free PE 12799 / 0

PV Name /dev/sda9
PV UUID
PV Status allocatable
Total PE / Free PE 12799 / 0

PV Name /dev/sda10
PV UUID
PV Status allocatable
Total PE / Free PE 12799 / 0
##############################################

Unfortunately there is no information in the internet to solve this without a reboot. Only entries like yes its pretty ease only 2 steps or entries like yes this 100% working fine but not for this solution i have.

When i calculate the sectors and sector size it should look like this
##############################################
/dev/sda11
100GB -> 209715201 Sektoren

START END
1132464128 - 1342179329
##############################################


But in real life thats not possible.


fdisk /dev/sda
##############################################
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
Partition type
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): l

Adding logical partition 11
First sector (629147649-1132462079, default 629147649): 1132464128
Value out of range. -> how i can add this new sda11 and extend the volume group of this server. Looks like he is in a half half modus and nothing is working.

the extension of the volume group should work after the creation. but creating the diskpartition /dev/sda11 is a pain with this.


I know that after the steps i should run partprobe -s to scan for the newly created partition and if this does not work i should run partx -v -a /dev/sda
I also know how to extend the physical volume with pvcreate /dev/sda11 and how to extend the volume group with vgextend VolGrup00 /dev/sda11
Logical Volume extend with lvextend and then the last step with resize2fs

Is there any smooth solution for this and not the quick and dirty stuff like (German Informatiksystembastelei
icon_sad.gif


Thanks for all who can help me with that
 


That's great news @linuxsec23 and welcome to linux.org :)

I am moving this Thread to Linux Server so that those who use Servers can benefit, and help if needed.

Enjoy your Linux.

Chris Turner
wizardfromoz
 
German Step by Step but i can also write it in english if someone is interested in

Schritte die ausgeführt werden müssen, um das Logical Volume und die virtuelle Festplatte im Speicherplatz zu erhöhen.


1. Festplatte im Vsphere Center auf die gewünschte Grösse erhöhen


2. Danach einen Snapshot der VM machen falls etwas bei der Partitionierung schief läuft


3. Auf die VM einloggen per ssh und mit dem Dirty Guide beginnen


4. Da wir die Maschine nicht neustarten oder herunterfahren können während dem Betrieb, muss ein rescan der SCSI Devices ausgeführt werden.


5. Hierzu müssen wir die SCSI Devices auflisten welche wir rescannen wollen mit dem Befehl

ls -la /sys/class/scsi_device/

total 0

drwxr-xr-x 2 root root 0 Apr 10 15:24 .

drwxr-xr-x 65 root root 0 Apr 10 08:59 ..

lrwxrwxrwx 1 root root 0 Feb 7 11:27 1:0:0:0 -> ../../devices/pci0000:00/0000:00:07.1/ata2/host1/target1:0:0/1:0:0:0/scsi_device/1:0:0:0

lrwxrwxrwx 1 root root 0 Feb 7 11:27 2:0:0:0 -> ../../devices/pci0000:00/0000:00:10.0/host2/target2:0:0/2:0:0:0/scsi_device/2:0:0:0



6. tailf /var/log/syslog& Befehl für die Live View des syslogs in einem extra Terminalfenster öffnen, damit man während der rescan sieht, ob es auch funktioniert hat.

7. Dieser Logeintrag gibt uns die Information, dass er auf dem SCSI Device den neuen Speicher auf /dev/sda festgestellt hat.

Apr 9 15:54:26 server01 kernel: [34828159.084587] sd 2:0:0:0: [sda] 1342177280 512-byte logical blocks: (687 GB/640 GiB)

Apr 9 15:54:26 server01 kernel: [34828159.084694] sda: detected capacity change from 579820584960 to 687194767360


8. Nun muss der rescan der SCSI Devices ausgeführt werden.

Dieser Befehl ist notwendig wenn die Disk um Space erweitert wurde

echo 1 > /sys/class/scsi_device/0\:0\:0\:0\:0/device/

echo 1 > /sys/class/scsi_device/1\:0\:0\:0/device/rescan

echo 1 > /sys/class/scsi_device/2\:0\:0\:0/device/rescan


9. Notwendig wenn eine neue Disk hinzugefügt wurde

:~# echo "- - -" > /sys/class/scsi_host/host0/scan

:~# echo "- - -" > /sys/class/scsi_host/host1/scan

:~# echo "- - -" > /sys/class/scsi_host/host2/scan


10. Wenn der neue oder bestehende SCSI Bus erkannt wurde geht es zu den weiteren Schritten weiter


11. Mit fdisk -l können wir den neuen Diskspace anzeigen lassen, jedoch werden hier noch die alten Partitionen angezeigt.


Vor dem Change

:~# fdisk -l

Disk /dev/sda: 540 GiB, 579820584960 bytes, 1132462080 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

Disklabel type: dos

Disk identifier: 0x151722cb


Device Boot Start End Sectors Size Id Type

/dev/sda1 * 2048 999423 997376 487M 83 Linux

/dev/sda2 1001470 1132462079 1131460610 539.5G 5 Extended

/dev/sda5 1001472 629145600 628144129 299.5G 8e Linux LVM

/dev/sda6 629149696 713031679 83881984 40G 8e LinuxLVM

/dev/sda7 713033728 817889279 104855552 50G 8e Linux LVM

/dev/sda8 817891328 922746879 104855552 50G 8e Linux LVM

/dev/sda9 922748928 1027604479 104855552 50G 8e Linux LVM

/dev/sda10 1027606528 1132462079 104855552 50G 8e Linux LVM


Nach dem Change

Disk /dev/sda: 640 GiB, 687194767360 bytes, 1342177280 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

Disklabel type: dos

Disk identifier: 0x151722cb


Device Boot Start End Sectors Size Id Type

/dev/sda1 * 2048 999423 997376 487M 83 Linux

/dev/sda2 1001470 1132462079 1131460610 539.5G 5 Extended

/dev/sda5 1001472 629145600 628144129 299.5G 8e Linux LVM

/dev/sda6 629149696 713031679 83881984 40G 8e Linux LVM

/dev/sda7 713033728 817889279 104855552 50G 8e Linux LVM

/dev/sda8 817891328 922746879 104855552 50G 8e Linux LVM

/dev/sda9 922748928 1027604479 104855552 50G 8e Linux LVM

/dev/sda10 1027606528 1132462079 104855552 50G 8e Linux LVM


12. Wie wir sehen, wurde der Diskspace erweitert. Nun müssen wir eine neue Partition /dev/sda11 anlegen und in der extended Partition (Logical Volume) hinzufügen, damit der Plattenplatz auch wirklich benutzt werden kann.


13. Zurzeit sind wir noch auf dem Stand, dass der Mountpoint / mit einer Grösse von 530G nicht mehr ausreicht. 98% belegt und bevor das System garnicht mehr startet muss die Partition erweitert werden.

:~# df -h

Filesystem Size Used Avail Use% Mounted on

udev 12G 0 12G 0% /dev

tmpfs 2.4G 221M 2.2G 10% /run

/dev/mapper/server01--vg-root 530G 494G 13G 98% /

tmpfs 12G 4.0K 12G 1% /dev/shm

tmpfs 5.0M 0 5.0M 0% /run/lock

tmpfs 12G 0 12G 0% /sys/fs/cgroup

/dev/sda1 472M 106M 343M 24% /boot

tmpfs 2.4G 0 2.4G 0% /run/user/0

tmpfs 2.4G 0 2.4G 0% /run/user/1000


14. Die bestehende Volumegroup

:~# vgs

VG #PV #LV #SN Attr VSize VFree

server01-vg 6 2 0 wz--n- 539.50g 0


15. Physische Volumes Anzeige

:~# pvs

PV VG Fmt Attr PSize PFree

/dev/sda10 server01-vg lvm2 a-- 50.00g 0

/dev/sda5 server01-vg lvm2 a-- 299.52g 0

/dev/sda6 server01-vg lvm2 a-- 40.00g 0

/dev/sda7 server01-vg lvm2 a-- 50.00g 0

/dev/sda8 server01-vg lvm2 a-- 50.00g 0

/dev/sda9 server01-vg lvm2 a-- 50.00g 0


16. Logical Volumeanzeige

:~# lvs

LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert

root server01-vg -wi-ao---- 538.50g

swap_1 server01-vg -wi-ao---- 1020.00m


17. Logical Volume display muss später erweitert werden

:~# lvdisplay

--- Logical volume ---

LV Path /dev/server01-vg/root

LV Name root

VG Name server01-vg

LV UUID Iatbx4-cnOy-4t2e-CqiU-fx5j-cm1Q-G0GvAj

LV Write Access read/write

LV Creation host, time server01, 2017-08-15 12:23:25 +0200

LV Status available

# open 1

LV Size 538.50 GiB

Current LE 137857

Segments 7

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 252:0



--- Logical volume ---

LV Path /dev/server01-vg/swap_1

LV Name swap_1

VG Name server01-vg

LV UUID mbwbIF-EmFy-oYan-dv70-Te7b-fjUH-KshxGA

LV Write Access read/write

LV Creation host, time server01, 2017-08-15 12:23:25 +0200

LV Status available

# open 2

LV Size 1020.00 MiB

Current LE 255

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 252:1



18. Physical Volume Anzeige muss später erweitert werden


root@server1:~# pvdisplay

--- Physical volume ---

PV Name /dev/sda5

VG Name server01-vg

PV Size 299.52 GiB / not usable 2.00 MiB

Allocatable yes (but full)

PE Size 4.00 MiB

Total PE 76677

Free PE 0

Allocated PE 76677

PV UUID zJi7iD-u9j5-UoAM-TY0H-ebaO-2nTC-wKVFsH



--- Physical volume ---

PV Name /dev/sda6

VG Name server01-vg

PV Size 40.00 GiB / not usable 0

Allocatable yes (but full)

PE Size 4.00 MiB

Total PE 10239

Free PE 0

Allocated PE 10239

PV UUID rBzuS9-073J-7IMr-1aZa-rVFf-BGtZ-faCiN4



--- Physical volume ---

PV Name /dev/sda7

VG Name server01-vg

PV Size 50.00 GiB / not usable 3.00 MiB

Allocatable yes (but full)

PE Size 4.00 MiB

Total PE 12799

Free PE 0

Allocated PE 12799

PV UUID NWRFgL-Y5bh-NDet-Vqae-RaWd-oa6N-yeFYKc



--- Physical volume ---

PV Name /dev/sda8

VG Name server01-vg

PV Size 50.00 GiB / not usable 3.00 MiB

Allocatable yes (but full)

PE Size 4.00 MiB

Total PE 12799

Free PE 0

Allocated PE 12799

PV UUID BSzwiw-JfU7-inRA-ESZC-wvav-yzCx-xKzlf8



--- Physical volume ---

PV Name /dev/sda9

VG Name server01-vg

PV Size 50.00 GiB / not usable 3.00 MiB

Allocatable yes (but full)

PE Size 4.00 MiB

Total PE 12799

Free PE 0

Allocated PE 12799

PV UUID ncHVss-3kqJ-7zCy-ziSd-Qw6J-0FvZ-mTu6uD



--- Physical volume ---

PV Name /dev/sda10

VG Name server01-vg

PV Size 50.00 GiB / not usable 3.00 MiB

Allocatable yes (but full)

PE Size 4.00 MiB

Total PE 12799

Free PE 0

Allocated PE 12799

PV UUID C6HNAX-CnhJ-sNwK-KfAF-1rr0-ahfw-YEq718




19. Volume Group display muss später erweitert werden

root@server1:~# vgdisplay

--- Volume group ---

VG Name server01-vg

System ID

Format lvm2

Metadata Areas 6

Metadata Sequence No 15

VG Access read/write

VG Status resizable

MAX LV 0

Cur LV 2

Open LV 2

Max PV 0

Cur PV 6

Act PV 6

VG Size 539.50 GiB

PE Size 4.00 MiB

Total PE 138112

Alloc PE / Size 138112 / 539.50 GiB

Free PE / Size 0 / 0

VG UUID C6VdtY-eI2Y-zNZM-8iDP-p96L-mJqW-CAGbh4


20. Mit dem Befehl fdisk /dev/sda müssen wir als erstes die extended Partition komplett löschen. Alle logischen Partitionen in dieser werden dann mitgelöscht und müssen später neu erstellt werden. Am besten man hinterlegt sich die Angaben zu den Sektoren (Start, Ende) da diese benötigt werden um das gleiche Partitionsschema wiederaufzubauen und die neue miteinzubinden.


21. Im Partitionsmenü von fdisk entfernen wir als erstes die 2. Partition (extended)

Command (m for help): d

Partition number (1,2,5-10, default 10): 2


Partition 2 has been deleted.


22. Mit p können wir uns nun die aktuelle Partitionsschemata anschauen

Command (m for help): p

Disk /dev/sda: 640 GiB, 687194767360 bytes, 1342177280 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

Disklabel type: dos

Disk identifier: 0x151722cb


Device Boot Start End Sectors Size Id Type

/dev/sda1 * 2048 999423 997376 487M 83 Linux


23. Nun erstellen wir die extended Partition wieder, jedoch mit dem neuen Speicher und der höheren Sektorenanzahl.

Hier ist DRINGEND zu beachten, dass wir nicht als vorgeschlagenen First Sector die 999424 hernehmen sondern 1001470, da dies der alte Sektorenstart ist. Das System kann sonst später nicht mehr auf die Daten zugreifen, wenn das Partitionsschema nicht dem enspricht wie es vorher war. Daten könnten korrupt werden, da das System diese nicht mehr auslesen kann.

Command (m for help): n

Partition type

p primary (1 primary, 0 extended, 3 free)

e extended (container for logical partitions)

Select (default p): e

Partition number (2-4, default 2): 2

First sector (999424-1342177279, default 999424): 1001470

Last sector, +sectors or +size{K,M,G,T,P} (1001470-1342177279, default 1342177279):



Created a new partition 2 of type 'Extended' and of size 639.5 GiB.
 
24. Die 2. Partition wurde nun angelegt mit dem neuen Space.


25. Nun müssen wir die verschiedenen Logischen Partition anlegen, was sehr tricky werden kann, wenn man die genauen Schritte nicht beachtet.


26. Die Partition 5 wird als allererstes erstellt mit den default Wert als Start Sektor, jedoch mit dem alten Endsektor (gespeicherte Übersicht des alten Partitionsschematas)

Command (m for help): n

All space for primary partitions is in use.

Adding logical partition 5

First sector (1003518-1342177279, default 1003520): 1001472

Value out of range.

Der alte Startsektor kann hier nicht verwendet werden und muss in der Advanced Option von fdisk auf die alten Stand 1001472 verschoben werden, was in den standard optionen wie hier nicht funktioniert. -> Fehler Value out of range.

First sector (1003518-1342177279, default 1003520):

Last sector, +sectors or +size{K,M,G,T,P} (1003520-1342177279, default 1342177279): 629145600

Hier ist der Last Sector genau der identische wie in der alten Partition. Er erkennt automatisch, dass dies eine 299.5 GiB Partition war.

Created a new partition 5 of type 'Linux' and of size 299.5 GiB.


27. Nun muss im erweiterten Modus der Startsektor verschoben werden damit wir mit den weiteren Partitionierungsschema weitermachen können.


28. Dies ist bis jetzt der aktuelle Status. Die neue Partition wurde als Linux Partitionstyp angelegt was noch falsch ist, da dies eine linux lvm mit dem Code 8e war. Dies wird später nach der Erstellung der verschiedenen Partitionen noch angepasst.

Command (m for help): p

Disk /dev/sda: 640 GiB, 687194767360 bytes, 1342177280 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

Disklabel type: dos

Disk identifier: 0x151722cb


Device Boot Start End Sectors Size Id Type

/dev/sda1 * 2048 999423 997376 487M 83 Linux

/dev/sda2 1001470 1342177279 1341175810 639.5G 5 Extended

/dev/sda5 1003520 629145600 628142081 299.5G 83 Linux


29. Nun wechseln wir in den Advanced Modus von fdisk, um die Partition 5 zu verändern.

Command (m for help): x


30. Danach wechseln wir in den b mode um den Anfang eines Sektors in der Partition zu ändern

DOS (MBR)

b move beginning of data in a partition


31. Hier wählen wir die 5. Partition aus und geben den alten Wert der Sektorenübersicht ein, sodass wir wieder das alte Partitionsschemate besitzen. 1001472

Partition number (1,2,5, default 5): 5

New beginning of data (1001471-629145600, default 1003520): 1001472


Expert command (m for help): p


Disk /dev/sda: 640 GiB, 687194767360 bytes, 1342177280 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

Disklabel type: dos

Disk identifier: 0x151722cb


Device Boot Start End Sectors Id Type Start-C/H/S End-C/H/S Attrs

/dev/sda1 * 2048 999423 997376 83 Linux 0/33/32 62/55/53 80

/dev/sda2 1001470 1342177279 1341175810 5 Extended 62/23/86 602/17/171

/dev/sda5 1001472 629145600 628144129 83 Linux 62/57/118 250/7/128


32. Nachdem dies geändert wurde wechseln wir wieder in den Standardmodus und erstellen die restlichen Partitionen. Mit r Return

Expert command (m for help): r


33. Nun beginnen wir mit der Erstellung. Hier ist es ratsam die alte Partitionstabelle herzunehmen, um die alten Sektorenwerte einzugeben.

Command (m for help): n

All space for primary partitions is in use.

Adding logical partition 6

First sector (629147649-1342177279, default 629149696): 629149696

Last sector, +sectors or +size{K,M,G,T,P} (629149696-1342177279, default 1342177279): 713031679


Created a new partition 6 of type 'Linux' and of size 40 GiB.


Command (m for help): n

All space for primary partitions is in use.

Adding logical partition 7

First sector (629147649-1342177279, default 713033728): 713033728

Last sector, +sectors or +size{K,M,G,T,P} (713033728-1342177279, default 1342177279): 817889279


Created a new partition 7 of type 'Linux' and of size 50 GiB.


Command (m for help): n

All space for primary partitions is in use.

Adding logical partition 8

First sector (629147649-1342177279, default 817891328): 817891328

Last sector, +sectors or +size{K,M,G,T,P} (817891328-1342177279, default 1342177279): 922746879


Created a new partition 8 of type 'Linux' and of size 50 GiB.


Command (m for help): n

All space for primary partitions is in use.

Adding logical partition 9

First sector (629147649-1342177279, default 922748928): 922748928

Last sector, +sectors or +size{K,M,G,T,P} (922748928-1342177279, default 1342177279): 1027604479


Created a new partition 9 of type 'Linux' and of size 50 GiB.


Command (m for help): n

All space for primary partitions is in use.

Adding logical partition 10

First sector (629147649-1342177279, default 1027606528): 1027606528

Last sector, +sectors or +size{K,M,G,T,P} (1027606528-1342177279, default 1342177279): 1132462079


Created a new partition 10 of type 'Linux' and of size 50 GiB.


34. Nun erstellen wir auch die erforderliche neue Partition mit den hinzugefügten 100 GB und geben die übrigen Sektoren an. Hier können die defaults benutzt werden.

Command (m for help): n

All space for primary partitions is in use.

Adding logical partition 11

First sector (629147649-1342177279, default 1132464128):

Last sector, +sectors or +size{K,M,G,T,P} (1132464128-1342177279, default 1342177279):


Created a new partition 11 of type 'Linux' and of size 100 GiB.


Command (m for help): p

Disk /dev/sda: 640 GiB, 687194767360 bytes, 1342177280 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

Disklabel type: dos

Disk identifier: 0x151722cb


Device Boot Start End Sectors Size Id Type

/dev/sda1 * 2048 999423 997376 487M 83 Linux

/dev/sda2 1001470 1342177279 1341175810 639.5G 5 Extended

/dev/sda5 1001472 629145600 628144129 299.5G 83 Linux

/dev/sda6 629149696 713031679 83881984 40G 83 Linux

/dev/sda7 713033728 817889279 104855552 50G 83 Linux

/dev/sda8 817891328 922746879 104855552 50G 83 Linux

/dev/sda9 922748928 1027604479 104855552 50G 83 Linux

/dev/sda10 1027606528 1132462079 104855552 50G 83 Linux

/dev/sda11 1132464128 1342177279 209713152 100G 83 Linux


35. Nachdem alles erfolgreich erstellt wurde müssen wir noch die Partitionstypen ändern. Diese besitzen noch den Linux Typ, jedoch muss Linux LVM ausgewählt werden, damit dies wieder mit der alten Konfiguration übereinstimmt.

8e Linux LVM

Device Boot Start End Sectors Size Id Type

/dev/sda1 * 2048 999423 997376 487M 83 Linux

/dev/sda2 1001470 1342177279 1341175810 639.5G 5 Extended

/dev/sda5 1001472 629145600 628144129 299.5G 8e Linux LVM

/dev/sda6 629149696 713031679 83881984 40G 83 Linux

/dev/sda7 713033728 817889279 104855552 50G 83 Linux

/dev/sda8 817891328 922746879 104855552 50G 83 Linux

/dev/sda9 922748928 1027604479 104855552 50G 83 Linux

/dev/sda10 1027606528 1132462079 104855552 50G 83 Linux

/dev/sda11 1132464128 1342177279 209713152 100G 83 Linux


Command (m for help): t

Partition number (1,2,5-11, default 11): 6

Partition type (type L to list all types): 8e


Changed type of partition 'Linux' to 'Linux LVM'.


Command (m for help): t

Partition number (1,2,5-11, default 11): 7

Partition type (type L to list all types): 8e


Changed type of partition 'Linux' to 'Linux LVM'.


Command (m for help): t

Partition number (1,2,5-11, default 11): 8

Partition type (type L to list all types): 8e


Changed type of partition 'Linux' to 'Linux LVM'.


Command (m for help): t

Partition number (1,2,5-11, default 11): 9

Partition type (type L to list all types): 8e


Changed type of partition 'Linux' to 'Linux LVM'.


Command (m for help): t

Partition number (1,2,5-11, default 11): 10

Partition type (type L to list all types): 8e


Changed type of partition 'Linux' to 'Linux LVM'.


Command (m for help): t

Partition number (1,2,5-11, default 11): 11

Partition type (type L to list all types): 8e


Changed type of partition 'Linux' to 'Linux LVM'.


Command (m for help): p

Disk /dev/sda: 640 GiB, 687194767360 bytes, 1342177280 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

Disklabel type: dos

Disk identifier: 0x151722cb


Device Boot Start End Sectors Size Id Type

/dev/sda1 * 2048 999423 997376 487M 83 Linux

/dev/sda2 1001470 1342177279 1341175810 639.5G 5 Extended

/dev/sda5 1001472 629145600 628144129 299.5G 8e Linux LVM

/dev/sda6 629149696 713031679 83881984 40G 8e Linux LVM

/dev/sda7 713033728 817889279 104855552 50G 8e Linux LVM

/dev/sda8 817891328 922746879 104855552 50G 8e Linux LVM

/dev/sda9 922748928 1027604479 104855552 50G 8e Linux LVM

/dev/sda10 1027606528 1132462079 104855552 50G 8e Linux LVM

/dev/sda11 1132464128 1342177279 209713152 100G 8e Linux LVM


36. Nachdem nun alle Partitionen wieder den alten Stand besitzen und die neue Partition hinzugefügt wurde muss der Stand auch gespeichert werden damit der Kernel die neue Tabelle benutzen kann. Diese speichern wir mit w.

Command (m for help): w

The partition table has been altered.

Calling ioctl() to re-read partition table.

Re-reading the partition table failed.: Device or resource busy


37. Da dies einen Neustart benötigt laut der Meldung und ein Neustart nicht möglich ist, da das System kontinuierlich laufen muss, gibt es nur zwei Optionen dies zu ermöglichen.

Mit partprobe -s kann ein Scan für die neue neue kreierte Partitionstabelle ausgeführt werden. Wenn dies nicht hilft kann auch der Befehl partx -v -a /dev/sda eingegeben werden


The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8)


root@server1:~# partprobe -s

/dev/sda: msdos partitions 1 2 <5 6 7 8 9 10 11>

/dev/mapper/server01--vg-swap_1: loop partitions 1

/dev/mapper/server01--vg-root: loop partitions 1


38. Der neue erweiterte Speicher ist jedoch noch nicht ganz fertig konfiguriert und erkannt. Jetzt muss das Logical Volume noch erweitert werden.

root@server1:~# df -h

Filesystem Size Used Avail Use% Mounted on

udev 12G 0 12G 0% /dev

tmpfs 2.4G 228M 2.2G 10% /run

/dev/mapper/server01--vg-root 530G 494G 12G 98% /

tmpfs 12G 4.0K 12G 1% /dev/shm

tmpfs 5.0M 0 5.0M 0% /run/lock

tmpfs 12G 0 12G 0% /sys/fs/cgroup

/dev/sda1 472M 106M 343M 24% /boot

tmpfs 2.4G 0 2.4G 0% /run/user/1000

tmpfs 2.4G 0 2.4G 0% /run/user/0


39. Partx wurde in dem Fall nur als Test ausgeführt was aber fehlschlägt laut der Ausgabe. Mit Partprobe hatte dies geklappt.

root@server1:~# partx -v -a /dev/sda

partition: none, disk: /dev/sda, lower: 0, upper: 0

/dev/sda: partition table type 'dos' detected

partx: /dev/sda: adding partition #1 failed: Device or resource busy

partx: /dev/sda: adding partition #2 failed: Device or resource busy

partx: /dev/sda: adding partition #5 failed: Device or resource busy

partx: /dev/sda: error adding partitions 1-2

partx: /dev/sda: adding partition #6 failed: Device or resource busy

partx: /dev/sda: adding partition #7 failed: Device or resource busy

partx: /dev/sda: adding partition #8 failed: Device or resource busy

partx: /dev/sda: adding partition #9 failed: Device or resource busy

partx: /dev/sda: adding partition #10 failed: Device or resource busy

partx: /dev/sda: adding partition #11 failed: Device or resource busy

partx: /dev/sda: error adding partitions 5-11


root@server1:~# fdisk -l

Disk /dev/sda: 640 GiB, 687194767360 bytes, 1342177280 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

Disklabel type: dos

Disk identifier: 0x151722cb


Device Boot Start End Sectors Size Id Type

/dev/sda1 * 2048 999423 997376 487M 83 Linux

/dev/sda2 1001470 1342177279 1341175810 639.5G 5 Extended

/dev/sda5 1001472 629145600 628144129 299.5G 8e Linux LVM

/dev/sda6 629149696 713031679 83881984 40G 8e Linux LVM

/dev/sda7 713033728 817889279 104855552 50G 8e Linux LVM

/dev/sda8 817891328 922746879 104855552 50G 8e Linux LVM

/dev/sda9 922748928 1027604479 104855552 50G 8e Linux LVM

/dev/sda10 1027606528 1132462079 104855552 50G 8e Linux LVM

/dev/sda11 1132464128 1342177279 209713152 100G 8e Linux LVM



Disk /dev/mapper/server01--vg-root: 538.5 GiB, 578214166528 bytes, 1129324544 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 /dev/mapper/server01--vg-swap_1: 1020 MiB, 1069547520 bytes, 2088960 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


40. Als erstes muss das Physische Volume erstellt werden, hier wählen wir die neue Partition /dev/sda11 aus

root@server1:~# pvcreate /dev/sda11

Physical volume "/dev/sda11" successfully created


41. Nun für den nächsten Schritt müssen wir den Volumegroupnamen herausfinden, um diesem dann das neue erstellte physische Volume sda11 hinzuzufügen.

root@server1:~# vgdisplay

--- Volume group ---

VG Name server01-vg

System ID

Format lvm2

Metadata Areas 6

Metadata Sequence No 15

VG Access read/write

VG Status resizable

MAX LV 0

Cur LV 2

Open LV 2

Max PV 0

Cur PV 6

Act PV 6

VG Size 539.50 GiB

PE Size 4.00 MiB

Total PE 138112

Alloc PE / Size 138112 / 539.50 GiB

Free PE / Size 0 / 0

VG UUID C6VdtY-eI2Y-zNZM-8iDP-p96L-mJqW-CAGbh4


Mit diesem Befehl fügen wir das neue Volume der Gruppe hinzu

root@server1:~# vgextend server01-vg /dev/sda11

Volume group "server01-vg" successfully extended


42. Hier sehen wir nun, dass das neue Volume hinzugefügt wurde und der Speicher erweitert wurde.

root@server1:~# pvscan

PV /dev/sda5 VG server01-vg lvm2 [299.52 GiB / 0 free]

PV /dev/sda6 VG server01-vg lvm2 [40.00 GiB / 0 free]

PV /dev/sda7 VG server01-vg lvm2 [50.00 GiB / 0 free]

PV /dev/sda8 VG server01-vg lvm2 [50.00 GiB / 0 free]

PV /dev/sda9 VG server01-vg lvm2 [50.00 GiB / 0 free]

PV /dev/sda10 VG server01-vg lvm2 [50.00 GiB / 0 free]

PV /dev/sda11 VG server01-vg lvm2 [100.00 GiB / 100.00 GiB free]

Total: 7 [639.50 GiB] / in use: 7 [639.50 GiB] / in no VG: 0 [0 ]


43. Nun müssen wir das Logical Volume mit dem neuen Volume erweitern

root@server1:~# lvextend /dev/server01-vg/

/dev/server01-vg/root /dev/server01-vg/swap_1


root@server1:~# lvextend /dev/server01-vg/root /dev/sda11

Size of logical volume server01-vg/root changed from 538.50 GiB (137857 extents) to 638.50 GiB (163456 extents).

Logical volume root successfully resized.


44. Im letzten Schritt müssen wir noch das Filesystem erweitern.

root@server1:~# resize2fs /dev/server01-vg/root

resize2fs 1.42.13 (17-May-2015)

Filesystem at /dev/server01-vg/root is mounted on /; on-line resizing required

old_desc_blocks = 34, new_desc_blocks = 40

The filesystem on /dev/server01-vg/root is now 167378944 (4k) blocks long.

45. Finally sehen wir, dass nun die Root Partition wieder mehr freien Speicher besitzt

root@server1:~# df -h

Filesystem Size Used Avail Use% Mounted on

udev 12G 0 12G 0% /dev

tmpfs 2.4G 228M 2.2G 10% /run

/dev/mapper/server01--vg-root 629G 494G 106G 83% /

tmpfs 12G 4.0K 12G 1% /dev/shm

tmpfs 5.0M 0 5.0M 0% /run/lock

tmpfs 12G 0 12G 0% /sys/fs/cgroup

/dev/sda1 472M 106M 343M 24% /boot

tmpfs 2.4G 0 2.4G 0% /run/user/1000

tmpfs 2.4G 0 2.4G 0% /run/user/0


46. Volume Group wurde erfolgreich erweitert.

root@server1:~# vgdisplay

--- Volume group ---

VG Name server01-vg

System ID

Format lvm2

Metadata Areas 7

Metadata Sequence No 17

VG Access read/write

VG Status resizable

MAX LV 0

Cur LV 2

Open LV 2

Max PV 0

Cur PV 7

Act PV 7

VG Size 639.50 GiB

PE Size 4.00 MiB

Total PE 163711

Alloc PE / Size 163711 / 639.50 GiB

Free PE / Size 0 / 0

VG UUID C6VdtY-eI2Y-zNZM-8iDP-p96L-mJqW-CAGbh4

47. Snapshot der VM wieder löschen wenn alles wie gewünscht funktioniert und keine Probleme bestehen
 

Staff online

Members online


Latest posts

Top