2013年5月16日木曜日

KURO-BOX/T4(Wheezy)でファイルサーバー

3TBでも起動させることが出来たので、もうちょっとちゃんと使ってみることにします。
といっても、u-bootはRAID対応してないようですし、パーティションリサイズしたりするのも面倒なので、結局もともと付いていた250GBのHDD2台(sdaとsdb)と3TBのディスク2台(sdcとsdd)使うことにしました。

/dev/sda1 /boot
/dev/sda2 /root
/dev/sda3 Swap用
(/dev/sdbはsdaのバックアップ用) /dev/md0 (/dev/sdc1 /dev/sdd1) 共有フォルダ用

となるようにします。

1. システムのインストール

/dev/sdaにシステムのインストールをします(LennyからWheezyまであげます)。
2. システムの設定
日本語(UTF-8)が正しく見えるように設定します。
KURO-NAS-T4:~# vi /etc/locale.gen
#ja_JP.UTF-8 UTF-8
 ↓に変更
ja_JP.UTF-8 UTF-8
KURO-NAS-T4:~# locale-gen
KURO-NAS-T4:~# update-locale LANG=ja_JP.UTF-8 LANGUAGE="ja_JP:ja"
KURO-NAS-T4:~# source /etc/default/locale
IPv6を無効にして、IPアドレスをDHCPから固定に設定します。
KURO-NAS-T4:~# vi /etc/network/interfaces
# The primary network interface
auto eth0
iface eth0 inet dhcp
 ↓に変更
# The primary network interface
auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 192.168.1.233
network 192.168.1.0
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameservers 192.168.1.1

KURO-NAS-T4:~# echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf
KURO-NAS-T4:~# sysctl -p
KURO-NAS-T4:~# ifdown eth0
KURO-NAS-T4:~# ifup eth0
ホスト名も変更しておきます。
KURO-NAS-T4:~# vi /etc/hostname
KURO-NAS-T4
 ↓新しいホスト名に変更
snoopy
KURO-NAS-T4:~# vi /etc/hosts
127.0.1.1 KURO-NAS-T4
 ↓新しいホスト名に変更
127.0.1.1 snoopy
KURO-NAS-T4:~# service networking restart
3. バックアップディスクの準備
2台目のHDD(sdb)にパーティションを作成します。各パーティションのサイズは1台目に合わせます。
KURO-NAS-T4:~# parted /dev/sdb
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit s
(parted) mklabel gpt
(parted) mkpart /boot 34 1000000
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? i
(parted) mkpart / 1000001 11000000
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? i
(parted) mkpart swap linux-swap 11000001 15000000
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? i
(parted) quit
パーティションの設定が終わったら、ファイルシステムを作成します。
KURO-NAS-T4:~# mkfs.ext3 /dev/sdb1
KURO-NAS-T4:~# mkfs.ext3 /dev/sdb2
KURO-NAS-T4:~# mkswap /dev/sdb3
次にバックアップの設定をします。
KURO-NAS-T4:~# apt-get install rsync
KURO-NAS-T4:~# mkdir /mnt/sdb
KURO-NAS-T4:~# mount /dev/sdb2 /mnt/sdb
KURO-NAS-T4:~# mkdir /mnt/sdb/boot
KURO-NAS-T4:~# mkdir /mnt/sdb/proc
KURO-NAS-T4:~# mkdir /mnt/sdb/sys
KURO-NAS-T4:~# mount /dev/sdb1 /mnt/sdb/boot
KURO-NAS-T4:~# rsync -a --delete --exclude=/proc/ --exclude=/mnt/ --exclude=/sys/ / /mnt/sdb/
問題なく終わったら毎日実行するようにします。
KURO-NAS-T4:~# crontab -e
0 5 * * * /usr/bin/rsync -a --delete --exclude=/dev/ --exclude=/proc/ --exclude=/mnt/ --exclude=/proc/ --exclude=/mnt/ --exclude=/sys/ / /mnt/sdb/ > /dev/null 2>&1
KURO-NAS-T4:~# vi /etc/fstab
 ↓最後に追加
/dev/sdb2 /mnt/sdb ext3 defaults 0 2
/dev/sdb1 /mnt/sdb/boot ext3 defaults 0 2
KURO-NAS-T4:~# mount /dev/sdb2 /mnt/sdb
KURO-NAS-T4:~# mkdir /mnt/sdb/boot
KURO-NAS-T4:~# mkdir /mnt/sdb/proc
KURO-NAS-T4:~# mkdir /mnt/sdb/sys
KURO-NAS-T4:~# mount /dev/sdb1 /mnt/sdb/boot
KURO-NAS-T4:~# rsync -a --delete --exclude=/proc/ --exclude=/mnt/ --exclude=/sys/ / /mnt/sdb/
4. 共有フォルダの設定
共有フォルダ用のディスク(sdcとsdd)のパーティションの設定をします。
KURO-NAS-T4:~# parted /dev/sdc
(parted) mklabel gpt
Warning: The existing disk label on /dev/sdc will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? y
(parted) unit s
(parted) mkpart share 2048 -1
Warning: You requested a partition from 2048s to 5860533167s.
The closest location we can manage is 2048s to 5860533134s.
Is this still acceptable to you?
Yes/No? y
(parted) set 1 raid on
(parted) select /dev/sdd
Using /dev/sdd
(parted) mklabel gpt
Warning: The existing disk label on /dev/sdd will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? y
(parted) mkpart share 2048 -1
Warning: You requested a partition from 2048s to 5860533167s.
The closest location we can manage is 2048s to 5860533134s.
Is this still acceptable to you?
Yes/No? y
(parted) set 1 raid on
(parted) quit
KURO-NAS-T4:~# apt-get install mdadm
KURO-NAS-T4:~# mdadm -C /dev/md0 -l1 -n2 /dev/sdc1 /dev/sdd1
KURO-NAS-T4:~# mkfs.ext4 /dev/md0
KURO-NAS-T4:~# vi /etc/fstab
 ↓最後に追加
/dev/md0 /mnt/share ext4 defaults 0 2
KURO-NAS-T4:~# mkdir /mnt/share
KURO-NAS-T4:~# chown nobody:nogroup /mnt/share
KURO-NAS-T4:~# chmod 777 /mnt/share
KURO-NAS-T4:~# mount /dev/md0 /mnt/share
ディスクの設定が終わったらSambaの設定をします。
KURO-NAS-T4:~# vi /etc/samba/smb.conf
[global]の下に追加。
[global]
dos charset = CP932
unix charset = utf-8
display charset = utf-8
map to guest = Bad User


####### Authentication ####### 辺りに下記を追加
security = share
[homes][printers][print$]関連はコメント化。
最後に下記を追加

[share]
path=/mnt/share
writeable = yes
force create mode = 0666
force directory mode = 0777
guest ok = yes
guest only = yes
編集し終わったらSambaを再起動します。
KURO-NAS-T4:~# service samba restart

0 件のコメント:

コメントを投稿