ここでの換装は、LS-HGLのroot取得ができていることを前提に実施する。
root取得についてはこちらを参照。
2年半ほど前、購入した直後にRAIDできるやつにしなかったことを激しく後悔する。
オレの中ではHDDというハードウェアは信頼性が極めて低い。単独ディスクのNASなんて恐すぎてとてもホームサーバとしてなんか使えない。
HDDはいつか必ず絶対に壊れる、これは100%間違いない。
とはいえ買ってしまった以上、なんとかまともに活用したい。調べてみると、中はlinuxで動作していることがわかる。
ゴニョゴニョしてroot取得し、USBドライブへのフルミラーリング化できるようにしてとりあえず利用に耐える状態にはした。
ちなみにメインがトラブル時はバックアップのUSBのディスクを抜いて物理的に差し替えるだけでそのまま今まで通り起動して今まで通り利用可能としている。いわゆるコールドスタンバイってやつね。
このあたりのことはこちらを参照。
前置きが長くなったけど、500GBの容量が逼迫してきたので、今回2TBに容量アップしようと思う。
バックアップも含め2TBを2台用意。
換装手順は以下の流れ。
■手順概要 (root権限必須)
・現在のUSBドライブをumount
・USBディスクを取り外し入れ替え
・USBドライブパーティション削除(あれば)
・USBドライブパーティション作成
・システムパーティションのコピー
換装だけならこの状態でもディスクを入れ替えて起動できるはず
・データ領域コピー
・換装動作確認
・バックアップ設定
各手順の詳細は以下の通り。
■現在接続されているUSBドライブをumount
# umount /mnt/usbdisk1
# umount /mnt/bkup
usbdisk1はシステムが勝手にマウントするUSB領域。web管理画面から見える領域。
bkupはUSBドライブのデータ領域へのマウントポイントとしている。(オレ独自設定)
■USBディスクを取り外し入れ替え
USBドライブを取り外し、新しい2TBのドライブに付け替え。
■USBドライブパーティションの削除(あれば)
#fdisk /dev/sdb
もし見つからないと言われたら、
#fdisk /dev/usbdisk1
まずは既存のパーティションを確認する。
Command (m for help): p
パーティションを全て削除(新品であれば無いはずなのでこの操作は不要)
Command (m for help): d
Partition number (1-4): 1 以下順に全て削除
書き込み(新品であれば不要)
Command (m for help): d
/dev/sdbにアクセスできない場合は一旦リブート
# shutdown -r now
■USBドライブパーティションの作成
オリジナル500GBのパーティションテーブルは以下の通りなのでこれに合わせるのが基本。
Device Boot Start End Blocks Id System
/dev/sda1 1 125 1004031 83 Linux
/dev/sda2 126 748 5004247+ 83 Linux
/dev/sda4 749 60801 482375722+ 5 Extended
/dev/sda5 749 873 1004031 82 Linux swap
/dev/sda6 874 60801 481371628+ 83 Linux
ここからパーティションの作成
# fdisk /dev/sdb
The number of cylinders for this disk is set to 121601.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
とりあえずパーティション確認
Command (m for help): p
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
◆パーティション1作成
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-121601, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-121601, default 121601): 125
Command (m for help): p
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 125 1004031 83 Linux
◆パーティション2作成
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (126-121601, default 126):
Using default value 126
Last cylinder or +size or +sizeM or +sizeK (126-121601, default 121601): 748
Command (m for help): p
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 125 1004031 83 Linux
/dev/sdb2 126 748 5004247+ 83 Linux
◆パーティション4作成 ※3はないので4
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e ← ■■ e を指定
Partition number (1-4): 4
First cylinder (749-121601, default 749):
Using default value 749
Last cylinder or +size or +sizeM or +sizeK (749-121601, default 121601): 全部
Using default value 121601
Command (m for help): p
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 125 1004031 83 Linux
/dev/sdb2 126 748 5004247+ 83 Linux
/dev/sdb4 749 121601 970751722+ 5 Extended
◆swapの作成
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (749-121601, default 749):
Using default value 749
Last cylinder or +size or +sizeM or +sizeK (749-121601, default 121601): 873
Command (m for help): p
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 125 1004031 83 Linux
/dev/sdb2 126 748 5004247+ 83 Linux
/dev/sdb4 749 121601 970751722+ 5 Extended
/dev/sdb5 749 873 1004031 83 Linux
Command (m for help): t
Partition number (1-5): 5
Hex code (type L to list codes): 82
Changed system type of partition 5 to 82 (Linux swap)
Command (m for help):
Command (m for help): p
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 125 1004031 83 Linux
/dev/sdb2 126 748 5004247+ 83 Linux
/dev/sdb4 749 121601 970751722+ 5 Extended
/dev/sdb5 749 873 1004031 82 Linux swap
◆残りボリュームの作成
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (874-121601, default 874):
Using default value 874
Last cylinder or +size or +sizeM or +sizeK (874-121601, default 121601): 全部
Using default value 121601
Command (m for help): p
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 125 1004031 83 Linux
/dev/sdb2 126 748 5004247+ 83 Linux
/dev/sdb4 749 121601 970751722+ 5 Extended
/dev/sdb5 749 873 1004031 82 Linux swap
/dev/sdb6 874 121601 969747628+ 83 Linux
◆パーティションの確定(書き込み)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
◆各パーティションをフォーマット(すぐ終わる)
mkfs.ext3 /dev/sdb1
mkfs.xfs /dev/sdb2
mkswap /dev/sdb5
mkfs.xfs /dev/sdb6
■システムパーティションのコピー
# dd if=/dev/sda1 of=/dev/sdb1 bs=4096 conv=noerror
1〜2分ぐらい
# dd if=/dev/sda2 of=/dev/sdb2 bs=4096 conv=noerror
2時間以上6時間未満 2時間経っても終わらなかったので放置していた。
ちなみに、フォアグラウンドの処理をバックグラウンドとして継続する場合は以下のコマンドね。
ctrl-zで中断し、
# bg 1
心配なら
#jobs
でバックグラウンドで実行中の処理が確認できる。
これでsshなりtelnetなりからログアウトしても処理が継続される。
■データ領域コピー
sdb6をどっかにmountしてオリジナルsda6よりrsync等でファイルコピー
ただしコピー速度はすごく遅い。
5〜6MB(メガバイト)/s ≒ 330MB/m ≒ 20GB/h
500GBコピーするのに約25時間。
■換装動作確認
できあがった2TBのディスクとオリジナル500GBを入れ替えて再起動。
起動できれば換装成功。
■バックアップ設定
バックアップ用に2TBのもう1台をUSB接続し、フルコピー。
# dd if=/dev/sda of=/dev/sdb bs=4096 conv=noerror
2TBなので超絶時間がかかる。
面倒くさくなければ換装手順と同じことをやったほうが速いと思われる。
確認のため、USBドライブをメインに入れ替えて起動するか確認。
後はシステム領域のバックアップは毎回やる必要はないので、データ領域だけrsyncとcronで定期的に同期設定して完了。
バックアップについて詳しくはこちら。
タグ:LS-HGL