Mengubah ukuran partisi filesystem REISERFS

DISCLAIMER:
INI ADALAH TUTORIAL STEP BY STEP. HARAP MEMBACA PETUNJUK DENGAN JELAS!
JANGAN PERNAH COPY DAN PASTE, KARENA ANDA AKAN KEHILANGAN DATA YANG TIDAK PERNAH MUNGKIN DI-RECOVER SEKALIPUN!!
JIKA ANDA MEMILIKI HARDISK DENGAN DATA YANG LUMAYAN BANYAK DAN PENTING, SANGAT DISARANKAN UNTUK BERKONSULTASI DI FORM KOMENTAR DI BAWAH.
SELALU BACKUP DATA ANDA!!
PENULIS TIDAK BERTANGGUNGJAWAB ATAS KEHILANGAN DATA ANDA. DO AT YOUR OWN RISK!!!

Linux yang dipakai adalah Slackware 13.1. Namun demikian semua linux standar-pun bisa digunakan, asalkan sudah diinstal dengan base-package lengkap.

OS : Slackware 13.1 (base package console)
PC/Router : DELL Optiplex Pentium III 450 Mhz, 512MB SDRAM

Saya memiliki sebuah hardisk ATA kapasitas 120GB. Cuma ada 1 partisi di dalamnya (sdb1) yang diformat full dengan filesystem reiserfs.

root@arc:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root              6353464   3212884   3140580  51% /
tmpfs                   188196         0    188196   0% /dev/shm
/dev/sdb1            117214656  67196272  50018384  58% /mnt/hd
root@arc:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/root             6.1G  3.1G  3.0G  51% /
tmpfs                 184M     0  184M   0% /dev/shm
/dev/sdb1             112G   65G   48G  58% /mnt/hd

Rencananya, disk ini akan di-split menjadi 2 partisi. Partisi kedua besarnya 30GB. Jadi, pertama akan di-ambil space-nya sebesar 30GB.

Skenario yang akan dilakukan ada 3 tahap:
1. check filesystem dengan reiserfsck
2. Me-resize filesystem dengan resize_reiserfs
3. Me-resize partisi dengan fdisk / cfdisk.
4. Membuat dan memformat partisi baru (sdb2)

STEP 1. Check Filesystem
1. Pastikan partisi yang akan diproses dalam posisi tidak di-mount.
root@arc:~# umount /mnt/hd/
2. eksekusi command reiserfsck

root@arc:~# reiserfsck /dev/sdb1
reiserfsck 3.6.21 (2009 www.namesys.com)

*************************************************************
** If you are using the latest reiserfsprogs and  it fails **
** please  email bug reports to reiserfs-list@namesys.com, **
** providing  as  much  information  as  possible --  your **
** hardware,  kernel,  patches,  settings,  all reiserfsck **
** messages  (including version),  the reiserfsck logfile, **
** check  the  syslog file  for  any  related information. **
** If you would like advice on using this program, support **
** is available  for $25 at  www.namesys.com/support.html. **
*************************************************************

Will read-only check consistency of the filesystem on /dev/sdb1
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 Mon Dec 20 00:43:51 2010
###########
Replaying journal: Done.
Reiserfs journal '/dev/sdb1' in blocks [18..8211]: 0 transactions replayed
Checking internal tree.. finished
Comparing bitmaps..finished
Checking Semantic tree:
finished
No corruptions found
There are on the filesystem:
Leaves 21848
Internal nodes 150
Directories 26963
Other files 49887
Data block pointers 16798005 (29144 of them are zero)
Safe links 0
###########
reiserfsck finished at Mon Dec 20 00:46:24 2010
###########

3. Jika tidak ada errors, lanjut ke step berikutnya.

STEP 2. Resize Filesystem
Ekseskusi command resize_reiserfs, dengan parameter “-v” untuk verbose, “-s” untuk set resize, dan “-30G” untuk mengurangi besar partisi sebesar 30GB.

root@arc:~# resize_reiserfs -v -s -30G /dev/sdb1
resize_reiserfs 3.6.21 (2009 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, 6465 /sec

nodes processed (moved):
int        150 (30),
leaves     21848 (4836),
unfm       16768861 (4610953),
total      16790859 (4615819).

check for used blocks in truncated region

ReiserFS report:
blocksize             4096
block count           21440240 (29304560)
free blocks           4640516 (12504596)
bitmap block count    655 (895)

Syncing..done

resize_reiserfs: Resizing finished successfully.

root@arc:~#

Proses ini akan memakan waktu lebih kurang 30 Menit, sesuai ukuran hardisk dan partisinya.
Jadi PASTIKAN LISTRIK anda JANGAN DAN TIDAK BOLEH MATI selama proses ini. Interupsi apapun beresiko membuat DATA HILANG.

Jika tidak ada error, sekarang coba mount kembali partisi sdb1 untuk melihat ukurannya:

root@arc:~# mount /dev/sdb1 /mnt/hd/
root@arc:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/root             6.1G  3.1G  3.0G  51% /
tmpfs                 184M     0  184M   0% /dev/shm
/dev/sdb1              82G   65G   18G  79% /mnt/hd
root@arc:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root              6353464   3212896   3140568  51% /
tmpfs                   188196         0    188196   0% /dev/shm
/dev/sdb1             85758336  67196272  18562064  79% /mnt/hd
root@arc:~# umount /mnt/hd/

Perhatikan, ukuran partisi nya sudah berubah dari 112G menjadi 82G.

lanjutkan ke tahap berikutnya:

STEP 3. Resize Partisi dengan fdisk

Sebenarnya, selain fdisk bisa juga menggunakan aplikasi linux lainnya untuk mengubah partisi, seperti cfdisk.
Disini penulis akan mendemokan menggunakan fdisk.

Pertanyaannya adalah, berapakah besar ukuran partisi (dalam satuan hardisk sectors) yang harus dialokasikan untuk ukuran filesystem sebesar “85758336″ ?
NB : Angka 85758336 adalah besar 1K-blocks /dev/sdb1 pada step sebelumnya.

Pengetahuan dasar untuk hardisk:
1 Sector adalah 2 Blocks
Akhir sectors untuk suatu blocks unit = ( blocks unit * 2 ) + StartSectors – 1

Bagaimana dengan hardisk kita:

root@arc:~# fdisk /dev/sdb

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

Command (m for help): u
Changing display/entry units to sectors

Command (m for help): p

Disk /dev/sdb: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders, total 234441648 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: 0x0c690c68

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              63   234436544   117218241   83  Linux

Command (m for help): q

Perhatikan, Start sector di atas adalah 63.
Kemudian, untuk amannya, saya akan menambahkan 100MB lebih besar pada ukuran partisi dibandingkan ukuran filesystem.
INGAT: Lebih baik melebihkan ukuran Partisi daripada kekurangan. Kekurangan jumlah size partisi = DATA CORRUPT!

Jadi, sekarang kita memiliki variabel :
Start Sector : 63
Blocks yang diinginkan : 85758336
Tambahan size : 100MB

Solusi :
Akhir sectors untuk suatu blocks unit = ( blocks unit * 2 ) + StartSectors – 1
Akhir sectors untuk 85758336 = (85758336 * 2) + 63 – 1
Akhir sectors untuk 85758336 = 171516734

Tambahan size dikonversi ke sectors :
100MB = 100 * 1024 * 1024 = 104857600 bytes
sectors = 104857600 bytes / 512 bytes = 204800 sectors
blocks = 1/2 * sectors
blocks = 204800 = 102400 blocks

Karena ada tambahan 100MB ini, maka perhitungan berubah:
Total Blocks yang dibutuhkan = 85758336 + 102400 = 85860736
Akhir sectors dari block 85860736 = (85860736 * 2) + 63 – 1 = 171721534

Selanjutnya, mengubah partisi menggunakan fdisk dengan cara delete partisi lama, dan recreate partisi baru dengan start sectors yang sama dan menggunakan end sectors sesuai perhitungan.
INGAT : START SECTORS harus SAMA dengan Partisi Lama.

root@arc:~# fdisk /dev/sdb

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

Command (m for help): u
Changing display/entry units to sectors

Command (m for help): p

Disk /dev/sdb: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders, total 234441648 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: 0x0c690c68

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              63   234436544   117218241   83  Linux

Command (m for help): d
Selected partition 1

Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (63-234441647, default 63):
Using default value 63
Last sector, +sectors or +size{K,M,G} (63-234441647, default 234441647): 171721534

Command (m for help): p

Disk /dev/sdb: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders, total 234441648 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: 0x0c690c68

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              63   171721534    85860736   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Pastikan dengan pengecekan reiserfsck bahwa TIDAK ADA DATA CORRUPT :

root@arc:~# reiserfsck /dev/sdb1
reiserfsck 3.6.21 (2009 www.namesys.com)

*************************************************************
** If you are using the latest reiserfsprogs and  it fails **
** please  email bug reports to reiserfs-list@namesys.com, **
** providing  as  much  information  as  possible --  your **
** hardware,  kernel,  patches,  settings,  all reiserfsck **
** messages  (including version),  the reiserfsck logfile, **
** check  the  syslog file  for  any  related information. **
** If you would like advice on using this program, support **
** is available  for $25 at  www.namesys.com/support.html. **
*************************************************************

Will read-only check consistency of the filesystem on /dev/sdb1
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 Mon Dec 20 02:08:31 2010
###########
Replaying journal: Done.
Reiserfs journal '/dev/sdb1' in blocks [18..8211]: 0 transactions replayed
Checking internal tree.. finished
Comparing bitmaps..finished
Checking Semantic tree:
finished
No corruptions found
There are on the filesystem:
Leaves 21848
Internal nodes 150
Directories 26963
Other files 49887
Data block pointers 16798005 (29144 of them are zero)
Safe links 0
###########
reiserfsck finished at Mon Dec 20 02:11:03 2010
###########
root@arc:~#

Selamat! Anda sudah berhasil me-resize filesystem dan partisi Reiserfs. :)

OPTIONAL
Anda bisa me-resize agar filesystem di sdb1 menggunakan seluruh partisi sdb1 (termasuk alokasi 100MB) yang kita persiapkan di awal:

root@arc:~# resize_reiserfs /dev/sdb1
resize_reiserfs 3.6.21 (2009 www.namesys.com)

ReiserFS report:
blocksize             4096
block count           21465184 (21440240)
free blocks           4665459 (4640516)
bitmap block count    656 (655)

Syncing..done

resize_reiserfs: Resizing finished successfully.

root@arc:~#
root@arc:~# mount /dev/sdb1 /mnt/hd/
root@arc:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root              6353464   3212912   3140552  51% /
tmpfs                   188196         0    188196   0% /dev/shm
/dev/sdb1             85858108  67196272  18661836  79% /mnt/hd
root@arc:~# umount /mnt/hd/

Sekarang, seluruh partisi sdb1 sudah dipergunakan dengan format filesystem reiserfs.

STEP 4. Membuat partisi baru sdb2
Tetap menggunakan aplikasi fdisk, kita akan membuat partisi baru dengan starting sectornya adalah ending sector partisi sdb1 dan endingnya adalah sampai sector terakhir.

root@arc:~# fdisk /dev/sdb

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

Command (m for help): u
Changing display/entry units to sectors

Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 2
First sector (171721535-234441647, default 171721535):
Using default value 171721535
Last sector, +sectors or +size{K,M,G} (171721535-234441647, default 234441647):
Using default value 234441647

Command (m for help): p

Disk /dev/sdb: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders, total 234441648 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: 0x0c690c68

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              63   171721534    85860736   83  Linux
/dev/sdb2       171721535   234441647    31360056+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
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)
Syncing disks.
root@arc:~#

Disini, partisi sudah sukses dibuat. Tetapi system Linux/Kernel belum bisa mengenali dan memproses partisi ini. Pada beberapa hardware PC dibutuhkan restart mesin agar system bisa membaca perubahan baru.
Namun, pada beberapa mesin server kelas terbaru, restart tidak lagi dibutuhkan. Linux bisa mengenali perubahan ini langsung.

Ok, sekarang kita lanjut dengan restart system.

root@arc:~# reboot

setelah reboot, kita lanjutkan dengan memformat sdb2 yang telah kita buat:

root@arc:~# mkreiserfs /dev/sdb2
mkreiserfs 3.6.21 (2009 www.namesys.com)

A pair of credits:
Jeremy  Fitzhardinge  wrote  the  teahash.c  code  for  V3.  Colin  Plumb  also
contributed to that.

Chris Mason wrote the journaling code for V3,  which was enormously more useful
to users than just waiting until  we could create a wandering log filesystem as
Hans would have unwisely done without him.
Jeff Mahoney optimized the bitmap  scanning code for V3,  and performed the big
endian cleanups.

Guessing about desired format.. Kernel 2.6.33.4 is running.
Format 3.6 with standard journal
Count of blocks on the device: 7840000
Number of blocks consumed by mkreiserfs formatting process: 8451
Blocksize: 4096
Hash function used to sort names: "r5"
Journal Size 8193 blocks (first block 18)
Journal Max transaction length 1024
inode generation number: 0
UUID: b76c8370-6769-4720-b340-efdfe539a1b8
ATTENTION: YOU SHOULD REBOOT AFTER FDISK!
ALL DATA WILL BE LOST ON '/dev/sdb2'!
Continue (y/n):y
Initializing journal - 0%....20%....40%....60%....80%....100%
Syncing..ok
ReiserFS is successfully created on /dev/sdb2.
root@arc:~# mount /dev/sdb2 /mnt/hd/
root@arc:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root              6353464   3212968   3140496  51% /
tmpfs                   188196         0    188196   0% /dev/shm
/dev/sdb2             31359036     32840  31326196   1% /mnt/hd
root@arc:~# umount /mnt/hd/

DONE.
Selamat mencoba.

REF : – http://en.wikipedia.org/wiki/Cylinder-head-sector
- http://linux.about.com/library/cmd/blcmdl8_resize_reiserfs.htm
- Pengalaman Penulis.

Tags: , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*


* 7 = fourteen

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>