LAB - Resizing Partitions



Resizing Partitions

Ky laborator do te ilustroje skenarin e meposhtem:

Shenim:
Ky laborator nenkupton qe keni bere paraprakisht backup te te dhenave te particionit te cilin doni te ridimensiononi, per shkak se ka rrezik te humbjes se te dhenave

Ne server RHEL 6+ kemi nje disk SCSI me dimension 10GB ne te cilin ka vetem nje particion me dimension 5GB te formatuar me FS ext4.
Duam te rrisim dimensionin e particionit nga 5 GB ne 10 GB.
Ne kete shembull disku eshte /dev/sdk1 i cili ngarkohet ne dosjen /sdk1.

Permbajtja aktuale e /sdk1 eshte:

[root@localhost student]# ls /sdk1/ -l
total 24
-rw-r--r--. 1 root root   124 Mar 28 05:52 hello.world
drwx------. 2 root root 16384 Mar 28 05:50 lost+found
-rw-r--r--. 1 root root    87 Mar 28 05:53 Yes.I.Can
[root@localhost student]#

hello.world
[root@localhost student]# cat /sdk1/hello.world
This file is for illustrative purposes.
We will see if this file will survive the deletion and recreation of the partition.
[root@localhost student]#

Yes.I.Can
[root@localhost student]# cat /sdk1/Yes.I.Can
If you can see this file it means that I did survived the recreation of the partition.
[root@localhost student]#


Se pari do ta shkepusim particionin /dev/sdk1

[root@localhost student]# mount | grep sdk1
/dev/sdk1 on /sdk1 type ext4 (rw)
[root@localhost student]#umount /sdk1


[root@localhost student]# mount | grep sdk1
[root@localhost student]#


Do ta hapim diskun me parted  :

[root@localhost student]# parted /dev/sdk
GNU Parted 2.1
Using /dev/sdk
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print free
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdk: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
        32.3kB  1049kB  1016kB           Free Space
 1      1049kB  5000MB  4999MB  primary  ext4
        5000MB  10.7GB  5738MB           Free Space

(parted)

Bazuar ne diskun me lart :

  • Do te shenojme ne leter piken e fillimit te particionit 1 (1049kB)
  • Do te sigurohemi qe pas mbarimit te ketij particioni(5000MB) ka hapesire te lire per te zgjeruar particionin
  • Do te fshijme particionin /dev/sdk1
  • Do te rikrijojme diskun /dev/sdk1 me:
    •  tipin primar ( i njejti sic ishte),
    •  FS ext4 ( i njejti sic ishte) dhe
    •  fillim 1049kB ( eshte shume e rendesishme qe ta fillojme particionin ne te njejten pike ne te kundert mund te humbasim te dhenat)
    •  fund 10GB

Fshime particionin /dev/sdk1 , (nuk humbasin te dhenat , per me teper keni backup)

(parted) rm 1
(parted) print free                                                      
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdk: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type  File system  Flags
        32.3kB  10.7GB  10.7GB        Free Space

(parted)                 
                                                
Ta rikrijojme particionin duke nisur nga pika ku fillonte particioni i pare : 1049 kB

(parted) mkpart                                                          
Partition type?  primary/extended? primary                               
File system type?  [ext2]? ext4                                          
Start? 1049kB                                                            
End? 10gb                                                                
(parted) print free                                                      
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdk: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
        32.3kB  1049kB  1016kB           Free Space
 1      1049kB  10.0GB  9999MB  primary  ext4
        10.0GB  10.7GB  737MB            Free Space

(parted)   
  


Ne kete pike kemi nje particion i cili ka nje filesistem ext4 qe shenon ne 5gb ndersa particioni nen te eshte 19 gb.
Do te na duhet te shkojme dhe te ridimensionojme sistemin e skedareve me fs2resize.

[root@localhost student]# resize2fs /dev/sdk1
resize2fs 1.41.12 (17-May-2010)
Please run 'e2fsck -f /dev/sdk1' first.

[root@localhost student]#


Do te kerkoje nje disk check paraprakisht:

[root@localhost student]# e2fsck -f /dev/sdk1
e2fsck 1.41.12 (17-May-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/sdk1: 13/305216 files (0.0% non-contiguous), 54320/1220352 blocks
[root@localhost student]#


Tani mund te ridimensionojme sistemin e skedareve ext4 qe te zere te gjithe hapesiren e particionit

[root@localhost student]# resize2fs /dev/sdk1
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/sdk1 to 2441216 (4k) blocks.
The filesystem on /dev/sdk1 is now 2441216 blocks long.

[root@localhost student]#

Verifikimi i te dhenave.
Ne kete pike mund te jemi ne merak per te dhenat. Ta ringarkojme serish /dev/sdk1 ne dosjen /sdk1 dhe te verifikojme nese te dhenat jane ende aty.

[root@localhost student]# mount /dev/sdk1 /sdk1
[root@localhost student]# ls /sdk1
hello.world  lost+found  Yes.I.Can
[root@localhost student]# cat /sdk1/hello.world
This file is for illustrative purposes.
We will see if this file will survive the deletion and recreation of the partition.
[root@localhost student]# cat /sdk1/Yes.I.Can
If you can see this file it means that I did survived the recreation of the partition.
[root@localhost student]#


















Shenim:
Ky skenar eshte sjelle si shembull per te ofruar nje zgjidhje per nje situate te caktuar megjithate duhet te sqarojme qe menyra e rekomanduar do te ishte qe te perdorej LVM ne nje server ku mendojme qe mund te kemi nevoje te ndryshojme dimensiont e particioneve ( volumeve)