ひさびさに、技術系の話…
最近メインのサーバの/var があふれ気味だったので、容量を増加させることに…
うちのサーバ達は、すべてVMware Server2.0の上で動いてるんだけど、
結構はまったので、簡単な手順を書いておく。
メインのサーバはFreeBSDで、/varはUFS。
VMwareの仮想ディスクなので、容量追加は簡単。
ホストOSにログインして、vmware-vdiskmanager でサイズの変更
# vmware-vdiskmanager -x [サイズ] [仮想ディスクファイル名]
(ex. # vmware-vdiskmanager -x 15GB CentOS4.vmdk
次に、ゲストOSをシングルユーザーモードで起動。
bsdlabelとか使うときに、/が書き込み不可だとまずいので、とりあえずおまじない。
# mount -f /
まずは、fdiskでパーティション情報を書き換え。
# fdisk -i [書き換えるディスクデバイス名]
(ex. # fdisk -i da1
これで、該当のスライスの値を変更していく。
デフォルトの値で答えていけば、最大値まで増やせる(はず)
確認(例は/dev/da0の場合)
# fdisk da0
******* Working on device /dev/da0 *******
parameters extracted from in-core disklabel are:
cylinders=40 heads=64 sectors/track=32 (2048 blks/cyl)
parameters to be used for BIOS calculations are:
cylinders=40 heads=64 sectors/track=32 (2048 blks/cyl)
Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
start 32, size 81888 (39 Meg), flag 80 (active) ←ここの「size」をメモしておく
beg: cyl 0/ head 1/ sector 1;
end: cyl 39/ head 63/ sector 32
The data for partition 2 is:
<UNUSED>
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
<UNUSED>
次にbsdlabelでサイズの拡張
#bsdlabel -e da0s1
# bsdlabel da0s1
# /dev/da0s1:
8 partitions:
# size offset fstype [fsize bsize bps/cpg]
c: 61408 0 unused 0 0 # "raw" part, don't edit
d: 61408 0 4.2BSD 2048 16384 3840
sizeを先ほどメモした値に変更
# /dev/da0s1:
8 partitions:
# size offset fstype [fsize bsize bps/cpg]
c: 81888 0 unused 0 0 # "raw" part, don't edit
d: 81888 0 4.2BSD 2048 16384 3840
これで保存して終了。
最後にgrowfsコマンドでファイルシステムを拡張。
# growfs /dev/da0s1d
We strongly recommend you to make a backup before growing the Filesystem
Did you backup your data (Yes/No) ? Yes
ここで必ず「Yes」と答えること
頭のYは大文字。小文字のyesやYだけだと何もせず終了。
これで結構悩みました。
new file systemsize is: 20472 frags
Warning: 5088 sector(s) cannot be allocated.
growfs: 37.5MB (76800 sectors) block size 16384, fragment size 2048
using 5 cylinder groups of 7.50MB, 480 blks, 960 inodes.
with soft updates
super-block backups (for fsck -b #) at:
61600
最後にmountしてサイズが拡張されてることを確認
# mount /test
# df -k
Filesystem 1024-blocks Used Avail Capacity Mounted on
/dev/ad0s1a 3932862 250848 3367386 7% /
devfs 1 1 0 100% /dev
/dev/da0s1d 36958 6 33996 0% /test
これでリブートして完了。