NIT.CAT

nit.cat

13/10 - 00:42 CEST

inici
El Cercador :: GNU/Linux :: Radioafició :: El Temps

ARTICLES

Com redimensionar particions ReiserFS - (Impresora) - (PDF)


Taula de continguts

Com redimensionar particions ReiserFS

Reduïr partició ReiserFS
Ampliar partició ReiserFS

Enllaços relacionats


Potser és un dels processos més complicats per un administrador de sistemes, el de tocar les particions. Si més no és arriscat i et pot fer perdre molt de temps si passa res. Explicaré les meves experiències amb ReiserFS amb una partició normal.

Sobretot és obligatori una COPIA DE SEGURETAT de les dades que continguin les particions que modificarem.

L'autor de l'article declina quasevol responsabilitat derivat d'aquest.



Com reduir (shrink) una partició amb ReiserFS

Ara desmuntarem totes les particions del disc que volem modificar

wks1:~ # umount /dev/hdc1
wks1:~ #

Ara procedirem a redimensionar només el sistemes de fitxers ReiserFS amb l'utilitat resize_reiserfs.

Haurem de calcular quina tamany de partició volem.Valor_actual_partició - Valor_partició_desitjat = Paràmetre -s de resize_reiserfs.

Volem una partició de 20G per tant seria 80G - 20G = 60G que hem de restar a la partició actual.

wks1:~ # resize_reiserfs -s -60G /dev/hdc1
resize_reiserfs 3.6.4 (2002 www.namesys.com)
You are running BETA version of reiserfs shrinker.
This version is only for testing or VERY CAREFUL use.
Backup of you data is recommended.

Do you want to continue? [y/N]:y
Processing the tree: 0%....20%....40%....60%....80%....100%                     
left 0, 0 /sec

nodes processed (moved):
int        0 (0),
leaves     1 (0),
unfm       0 (0),
total      1 (0).

check for used blocks in truncated region

ReiserFS report:
blocksize             4096
block count           4375912 (20104552)
free blocks           4367567 (20095727)
bitmap block count    134 (614)

Syncing..done
wks1:~ # 

Bé ara tenim un sistema de fitxers que hem reduit però ara s'ha de reduir la partició perquè resize_reiserfs no ho fa automàticament

Per fer això utilitzarem les dades que ens ha proporcionat resize_reiserfs al final sobre el tamany del sistema de fitxers.

blocksize 4096
block count 4375912 (20104552)

La fórmula seria block count * blocksize / 512 = numero_de_sectors

El resultat seria (4375912 * 4096) / 512 = 35007296 sectors

Aquesta dada l'utilitzarem amb la comanda sfdisk per modificar la partició.

Volcarem l'estat de partició del disc hdc a un fitxer per a la seva modificació posterior.

wks1:/ # sfdisk -d /dev/hdc >particio_hdc
wks1:/ #

Ara editarem el fitxer particio_hdc per exemple amb vi i canviarem el valor del camp size per resultat obtingut del càlcul de sectors del sistema de fitxers. Quedant de la forma següent:

# partition table of /dev/hdc
unit: sectors

/dev/hdc1 : start=       63, size=35007296, Id=83
/dev/hdc2 : start=        0, size=        0, Id= 0
/dev/hdc3 : start=        0, size=        0, Id= 0
/dev/hdc4 : start=        0, size=        0, Id= 0

Ara només queda sobreescriure la partició amb l'ordre:

wks1:/ # sfdisk /dev/hdc  <particio_hdc
Checking that no-one is using this disk right now ...
OK

Disk /dev/hdc: 159560 cylinders, 16 heads, 63 sectors/track
Old situation:
Units = cylinders of 516096 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/hdc1          0+ 159559  159560-  80418208+  83  Linux
/dev/hdc2          0       -       0          0    0  Empty
/dev/hdc3          0       -       0          0    0  Empty
/dev/hdc4          0       -       0          0    0  Empty
New situation:
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/hdc1            63  35007358   35007296  83  Linux
/dev/hdc2             0         -          0   0  Empty
/dev/hdc3             0         -          0   0  Empty
/dev/hdc4             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 ...

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).)
wks1:/ # 

Per comprovar que tot ha funcionat bé el millor és comprovar la integritat del sistema de fitxers amb reiserfsck

wks1:/ # reiserfsck  /dev/hdc1
reiserfsck 3.6.4 (2002 www.namesys.com)
Will read-only check consistency of the filesystem on /dev/hdc1
Will put log info to 'stdout'

Do you want to run this program?[N/Yes] (note need to type Yes if you do):Yes
###########
reiserfsck --check started at Wed Jul  9 20:38:20 2003
###########
Replaying journal..
0 transactions replayed
Checking internal tree..finished
Comparing bitmaps..finished
Checking Semantic tree:
finished           
No corruptions found
There are on the filesystem:
        Leaves 1
        Internal nodes 0
        Directories 2
        Other files 0
        Data block pointers 0 (0 of them are zero)
        Safe links 0
###########
reiserfsck finished at Wed Jul  9 20:38:22 2003
###########
wks1:/ # 

Ara ja podem muntar una altre vegada la partició




Com ampliar (grow) una partició amb ReiserFS

Bàsicament és el mateix procés que la reducció però a la inversa

Desmuntarem les particions del disc que volem modificar.

Modificarem la partició i assignarem els sectors que ocuparà el sistema de fitxers.

Utilitzarem l'ordre fdisk per saber els sectors totals del disc.

wks1:~ # fdisk -u -l /dev/hdc

Disk /dev/hdc: 82.3 GB, 82348277760 bytes
16 heads, 63 sectors/track, 159560 cylinders, total 160836480 sectors
Units = sectors of 1 * 512 = 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hdc1            63  35007358  17503648   83  Linux
wks1:~ #

Volcarem l'estat de partició del disc hdc a un fitxer per a la seva modificació posterior.

wks1:/ # sfdisk -d /dev/hdc >particio_hdc
wks1:/ #

Ara editarem el fitxer particio_hdc per exemple amb vi i canviarem el valor del camp size per resultat obtingut amb fdisk del total de sectors del disc menys el numero de sectors del camp start.

size = Sectors_totals_del_disc - Sectors_camp_start
size = 160836480 - 63 = 160836417

Quedant de la forma següent:

# partition table of /dev/hdc
unit: sectors

/dev/hdc1 : start=       63, size=160836417, Id=83
/dev/hdc2 : start=        0, size=        0, Id= 0
/dev/hdc3 : start=        0, size=        0, Id= 0
/dev/hdc4 : start=        0, size=        0, Id= 0

Ara només queda sobreescriure la partició amb l'ordre:

wks1:/ # sfdisk /dev/hdc  <particio_hdc
Checking that no-one is using this disk right now ...
OK

Disk /dev/hdc: 159560 cylinders, 16 heads, 63 sectors/track
Old situation:
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/hdc1            63  35007358   35007296  83  Linux
/dev/hdc2             0         -          0   0  Empty
/dev/hdc3             0         -          0   0  Empty
/dev/hdc4             0         -          0   0  Empty
New situation:
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/hdc1            63 160836479  160836417  83  Linux
/dev/hdc2             0         -          0   0  Empty
/dev/hdc3             0         -          0   0  Empty
/dev/hdc4             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 ...

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).)
wks1:/ # 

Ara redimensionarem el sistema de fitxers amb resize_reiserfs.

wks1:~ # resize_reiserfs /dev/hdc1
resize_reiserfs 3.6.4 (2002 www.namesys.com)
ReiserFS report:
blocksize             4096
block count           20104552 (4150558)
free blocks           20095727 (4142220)
bitmap block count    614 (127)

Syncing..done
wks1:~ #

Ara ja tenim la partició que ocupa tot el disc. Comprovem l'integritat del sistema de fitxers amb reiserfsck i després muntem la partició.


Última modificació / Last update: 10/07/03