Previous Entry Share Next Entry
RAID config
Linux
sanmai
Сколько раз можно выдумывать, надоело.

~# cd /mnt/
/mnt# mkdir debian
/mnt# cd debian/
/mnt/debian# cat > partitions
# partition table of /dev/sdb
unit: sectors

/dev/sdb1 : start=       63, size=   273042, Id=fd
/dev/sdb2 : start=   273105, size=  3919860, Id=fd
/dev/sdb3 : start=  4192965, size=  1012095, Id=fd
/dev/sdb4 : start=  5205060, size= 971563005, Id=fd
^D

/mnt/debian# cat partitions | sfdisk /dev/sdb

/mnt/debian# cd /dev/

/dev# MAKEDEV md
udev active, devices will be created in /dev/.static/dev/

/dev# modprobe raid1

/dev# for i in 1 2 3 4; do mdadm --create /dev/md$i --level=1 --raid-devices=2 missing /dev/sdb$i; done; 
mdadm: array /dev/md1 started.
mdadm: array /dev/md2 started.
mdadm: array /dev/md3 started.
mdadm: array /dev/md4 started.

/dev# mkfs.ext3 -L boot /dev/md1
mke2fs 1.41.3 (12-Oct-2008)
Filesystem label=boot
OS type: Linux

/dev# mkfs.ext3 -L root /dev/md3
mke2fs 1.41.3 (12-Oct-2008)
Filesystem label=root
OS type: Linux

/dev# mkswap /dev/md2
Setting up swapspace version 1, size = 1959804 KiB
no label, UUID=0002d500-d026-4100-0056-b5e0c0509050

/dev# swapon /dev/md2

/dev# pvcreate /dev/md4
  Physical volume "/dev/md4" successfully created
/dev# vgcreate 
  Please provide volume group name and physical volumes
  Run `vgcreate --help' for more information.
/dev# vgcreate raid /dev/md4
  Volume group "raid" successfully created

/dev# modprobe dm-mod

/dev# lvcreate -L512M -n usr raid
  Logical volume "usr" created
/dev# lvcreate -L1G -n home raid
  Logical volume "home" created
/dev# lvcreate -L512M -n var raid
  Logical volume "var" created
/dev# lvcreate -L128M -n vartmp raid
  Logical volume "vartmp" created
/dev# lvcreate -L1G -n cache raid
  Logical volume "cache" created
/dev# lvcreate -L1G -n backup raid
  Logical volume "backup" created

/dev# for i in usr home var vartmp cache backup; do mkfs.ext3 -L $i /dev/raid/$i; done;

/dev# mount /dev/md3 /mnt/debian/
/dev# cd /mnt/debian/

/mnt/debian# mkdir -p usr home var boot
/mnt/debian# for i in *; do mount /dev/raid/$i $i; done;
/mnt/debian# mkdir var/cache var/tmp
/mnt/debian# mount /dev/raid/vartmp var/tmp/
/mnt/debian# mount /dev/raid/cache var/cache/
/mnt/debian# mount /dev/md1 boot/

/mnt/debian# apt-get install debootstrap
/mnt/debian# debootstrap lenny .
Сидим, пьём чай. Или кто что любит.
I: Base system installed successfully.
/mnt/debian# mount proc proc -t proc
/mnt/debian# mount -o bind /dev dev
/mnt/debian# LC_ALL= LANG=C chroot .
/#
/# apt-get update

/# apt-get install netselect-apt
/# netselect-apt
/# cp ./sources.list /etc/apt/sources.list
/# apt-get update

/# apt-get install less openssh-server deborphan grub mdadm lvm2
/# dpkg --purge `deborphan`
/# echo hostname > /etc/hostname

/# cat > /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static

address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1
^D

/# cat > /etc/resolv.conf
nameserver 192.168.1.1
^D

/# echo -e "127.0.0.1\tlocalhost\thostname" > /etc/hosts

/# dpkg-reconfigure tzdata

/# apt-get install locales console-tools console-data
/# dpkg-reconfigure locales
Еще немного осталось:
/# apt-cache search linux-image
/# apt-get install linux-image-2.6-amd64
/# cat /proc/mounts > /etc/mtab
/# grub-install hd1
/# update-grub
Проверяем, что все там где и должно:
/# cat /boot/grub/menu.lst
/# ls /boot/
Вот такого там быть не должно:
/# grep \(md /boot/grub/menu.lst
# groot=(md1)
root		(md1)
root		(md1)
Исправляем и проверяем:
/# sed -i "s/groot=(md1)/groot=(hd0,0)/" /boot/grub/menu.lst
/# update-grub
/# grep root /boot/grub/menu.lst
Теперь ответственный момент, главное ничего не перепутать.
Иначе потом не загрузится.
/# cat > /etc/fstab 
# <fs>			<mountpoint>	<type>	<opts>	<dump/pass>
/dev/md1		/boot			ext3	noauto,noatime,ro 0 2
/dev/md2		none			swap	sw 0 0
/dev/md3		/				ext3	noatime 0 1
/dev/raid/usr	/usr			ext3	noatime 0 0
/dev/raid/home	/home			ext3	noatime,nosuid,nodev,noexec 0 0
/dev/raid/var	/var			ext3	noatime,nosuid,nodev 0 0
/dev/raid/vartmp	/var/tmp	ext3	noatime,nosuid,nodev 0 0
/dev/raid/cache	/var/cache	ext3	noatime,nosuid,nodev,noexec 0 0
/dev/raid/backup	/home/backup	ext3	noatime,nosuid,nodev,noexec 0 0
proc	/proc			proc	defaults 0 0
none	/tmp			tmpfs	size=128m,nosuid,nodev,noexec 0 0
shm	/dev/shm		tmpfs	nodev,nosuid,noexec 0 0
Проверяем, поправляем:
/# mount -a
mount: mount point /home/backup does not exist
/# mkdir -p /home/backup

/# exit
/mnt/debian# sfdisk -d /dev/sdb | sfdisk /dev/sda
/mnt/debian# for i in 1 2 3; do mdadm -a /dev/md$i /dev/sda$i; done;
Подождем синхронизации:
/mnt/debian# cat /proc/mdstat 
Personalities : [raid1] 
md4 : active raid1 sdb4[1]
      485781376 blocks [2/1] [_U]
      
md3 : active raid1 sda3[2] sdb3[1]
      505920 blocks [2/1] [_U]
      [=========>...........]  recovery = 48.8% (248768/505920) finish=0.3min speed=11846K/sec
      
md2 : active raid1 sda2[2] sdb2[1]
      1959808 blocks [2/1] [_U]
      	resync=DELAYED
      
md1 : active raid1 sda1[0] sdb1[1]
      136448 blocks [2/2] [UU]
      
unused devices: <none>
Или не ждем, и перезагружаемся.

  • 1
> "cat > partitions"
А что пишем-то?

  • 1
?

Log in

No account? Create an account