[Eisfair] Software-Raid-1 mit ext4

Thomas Bork tom at eisfair.org
So Jul 6 21:07:50 CEST 2014


Am 06.07.2014 15:56, schrieb ich:

> Nö, stimmt dann.

Nach diesem Muster funktioniert das bei mir:

sata # sgdisk -p /dev/sda
Disk /dev/sda: 8388608 sectors, 4.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 225A5478-5E44-4F29-A07B-C5237D2C8D0A
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 8388574
Partitions will be aligned on 2048-sector boundaries
Total free space is 22494 sectors (11.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
    1            2048          100351   48.0 MiB    8300  boot
    2          100352          362495   128.0 MiB   8200  swap
    3          362496         2459647   1024.0 MiB  8300  root
    4         2459648         8368094   2.8 GiB     8300  data
sata # sgdisk -p /dev/sdb
Creating new GPT entries.
Disk /dev/sdb: 8388608 sectors, 4.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 64A8CE74-7CE2-400A-BCA3-09392C7C8114
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 8388574
Partitions will be aligned on 2048-sector boundaries
Total free space is 8388541 sectors (4.0 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name

sata # for i in 1 2 3 4; do sgdisk -t ${i}:fd00 /dev/sda; done
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.

Reboot, da der Kernel die neue Tabelle erst nach einem Reboot nutzt.

sata # sgdisk -p /dev/sda
Disk /dev/sda: 8388608 sectors, 4.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 225A5478-5E44-4F29-A07B-C5237D2C8D0A
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 8388574
Partitions will be aligned on 2048-sector boundaries
Total free space is 22494 sectors (11.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
    1            2048          100351   48.0 MiB    FD00  boot
    2          100352          362495   128.0 MiB   FD00  swap
    3          362496         2459647   1024.0 MiB  FD00  root
    4         2459648         8368094   2.8 GiB     FD00  data
sata # sgdisk -R/dev/sdb /dev/sda
The operation has completed successfully.
sata # sgdisk -G /dev/sdb
The operation has completed successfully.
sata # sgdisk -p /dev/sda
Disk /dev/sda: 8388608 sectors, 4.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 225A5478-5E44-4F29-A07B-C5237D2C8D0A
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 8388574
Partitions will be aligned on 2048-sector boundaries
Total free space is 22494 sectors (11.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
    1            2048          100351   48.0 MiB    FD00  boot
    2          100352          362495   128.0 MiB   FD00  swap
    3          362496         2459647   1024.0 MiB  FD00  root
    4         2459648         8368094   2.8 GiB     FD00  data
sata # sgdisk -p /dev/sdb
Disk /dev/sdb: 8388608 sectors, 4.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): D2ADEFB9-7DD6-4942-BB4B-3EAAF84DA137
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 8388574
Partitions will be aligned on 2048-sector boundaries
Total free space is 22494 sectors (11.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
    1            2048          100351   48.0 MiB    FD00  boot
    2          100352          362495   128.0 MiB   FD00  swap
    3          362496         2459647   1024.0 MiB  FD00  root
    4         2459648         8368094   2.8 GiB     FD00  data
sata # for i in 1 2 3 4; do mdadm --zero-superblock /dev/sdb${i}; done
mdadm: Unrecognised md component device - /dev/sdb1
mdadm: Unrecognised md component device - /dev/sdb2
mdadm: Unrecognised md component device - /dev/sdb3
mdadm: Unrecognised md component device - /dev/sdb4
sata # mdadm --create /dev/md1 --bitmap=internal --level=1 
--metadata=0.90 --raid-disks=2 missing /dev/sdb1
mdadm: array /dev/md1 started.
sata # mdadm --create /dev/md2 --bitmap=internal --level=1 
--raid-disks=2 missing /dev/sdb2
mdadm: Note: this array has metadata at the start and
     may not be suitable as a boot device.  If you plan to
     store '/boot' on this device please ensure that
     your boot-loader understands md/v1.x metadata, or use
     --metadata=0.90
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md2 started.
sata # mdadm --create /dev/md3 --bitmap=internal --level=1 
--raid-disks=2 missing /dev/sdb3
mdadm: Note: this array has metadata at the start and
     may not be suitable as a boot device.  If you plan to
     store '/boot' on this device please ensure that
     your boot-loader understands md/v1.x metadata, or use
     --metadata=0.90
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md3 started.
sata # mdadm --create /dev/md4 --bitmap=internal --level=1 
--raid-disks=2 missing /dev/sdb4
mdadm: Note: this array has metadata at the start and
     may not be suitable as a boot device.  If you plan to
     store '/boot' on this device please ensure that
     your boot-loader understands md/v1.x metadata, or use
     --metadata=0.90
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md4 started.
sata # cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] 
[raid4] [multipath]
md4 : active raid1 sdb4[1]
       2952128 blocks super 1.2 [2/1] [_U]
       bitmap: 0/1 pages [0KB], 65536KB chunk

md3 : active raid1 sdb3[1]
       1048000 blocks super 1.2 [2/1] [_U]
       bitmap: 0/1 pages [0KB], 65536KB chunk

md2 : active raid1 sdb2[1]
       130944 blocks super 1.2 [2/1] [_U]
       bitmap: 0/1 pages [0KB], 65536KB chunk

md1 : active raid1 sdb1[1]
       49088 blocks [2/1] [_U]
       bitmap: 0/1 pages [0KB], 65536KB chunk

unused devices: <none>
sata # mkfs.ext4 /dev/md1
mke2fs 1.42.8 (20-Jun-2013)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
12288 inodes, 49088 blocks
2454 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=50331648
6 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
         8193, 24577, 40961

Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

sata # mkfs.ext4 /dev/md3
mke2fs 1.42.8 (20-Jun-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262000 blocks
13100 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
         32768, 98304, 163840, 229376

Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

sata # mkfs.ext4 /dev/md4
mke2fs 1.42.8 (20-Jun-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
184736 inodes, 738032 blocks
36901 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=759169024
23 block groups
32768 blocks per group, 32768 fragments per group
8032 inodes per group
Superblock backups stored on blocks:
         32768, 98304, 163840, 229376, 294912

Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

sata # mkswap /dev/md2
Setting up swapspace version 1, size = 130940 KiB
no label, UUID=30231248-4bf2-40c9-a09c-d69cc4ffc53a
sata #

mcedit /etc/init.d/boot (fsck auskommentieren)

mount -t ext4 /dev/md3 /mnt
mkdir -p /mnt/boot
mount -t ext4 /dev/md1 /mnt/boot
cd /
find . -xdev | cpio -pmv /mnt
cd /boot
find . -xdev | cpio -pmv /mnt/boot
mcedit /mnt/etc/fstab
sata # cat /mnt/etc/fstab
/dev/md3 / ext4 defaults,errors=remount-ro 0 1
/dev/md1 /boot ext4 defaults,errors=remount-ro 0 1
/dev/md2 none swap sw 0 0
/dev/md4 /data ext4 defaults 0 2
proc        /proc          proc      defaults                 0 0
/dev/fd0    /media/floppy  auto      defaults,user,noauto     0 0
/dev/cdrom  /media/cdrom   iso9660   defaults,ro,user,noauto  0 0
devpts      /dev/pts       devpts    defaults                 0 0
usbfs       /proc/bus/usb  usbfs     defaults                 0 0
/sys        /sys           sysfs     defaults                 0 0

cd /
umount /boot
mount /dev/sda1 /mnt/boot

mcedit /mnt/etc/lilo.conf
sata # cat /mnt/etc/lilo.conf
lba32
disk = /dev/sda
   bios = 0x80
boot = /dev/sda
read-only
prompt
timeout = 50
vga = normal
image = /boot/kernel
root = /dev/md3
label = eis
initrd = /boot/initrd.gz
append = "raid=noautodetect"


mkdir -p /tmp/initrd/init
cd /tmp/initrd
cp -a /mnt/boot/initrd.gz .
gzip -d initrd.gz
modprobe loop
mount -o loop initrd init
cp /sbin/mdadm /tmp/initrd/init/sbin
echo "DEVICE /dev/[sh]d*" >/tmp/initrd/init/etc/mdadm.conf
mdadm --examine --scan >>/tmp/initrd/init/etc/mdadm.conf
echo "/sbin/mdadm --assemble --scan" >>/tmp/initrd/init/linuxrc
cat /tmp/initrd/init/etc/mdadm.conf
DEVICE /dev/[sh]d*
ARRAY /dev/md1 UUID=a9122c09:2ff170b5:4f3afcde:20a4b3b5
ARRAY /dev/md/2  metadata=1.2 UUID=c5d86e56:e47496ec:8d844599:d532dfb9 
name=sata:2
ARRAY /dev/md/3  metadata=1.2 UUID=83471d3d:3396af34:0e259d1a:809798dc 
name=sata:3
ARRAY /dev/md/4  metadata=1.2 UUID=e9eb7e17:4406065d:59c6fd4a:f89ff45e 
name=sata:4
sata # cat /tmp/initrd/init/linuxrc
#! /bin/sh
/bin/echo -e "\033[32m\033[49mLoading Input/USB/SCSI/SATA/RAID drivers 
...\033[0m"
/sbin/insmod /lib/modules/2.6.32-eisfair-1-SMP/psmouse.ko
/sbin/insmod /lib/modules/2.6.32-eisfair-1-SMP/usbcore.ko
/sbin/insmod /lib/modules/2.6.32-eisfair-1-SMP/ehci-hcd.ko
/sbin/insmod /lib/modules/2.6.32-eisfair-1-SMP/uhci-hcd.ko
/sbin/insmod /lib/modules/2.6.32-eisfair-1-SMP/ssb.ko
/sbin/insmod /lib/modules/2.6.32-eisfair-1-SMP/ohci-hcd.ko
/sbin/insmod /lib/modules/2.6.32-eisfair-1-SMP/xhci.ko
/sbin/insmod /lib/modules/2.6.32-eisfair-1-SMP/hid.ko
/sbin/insmod /lib/modules/2.6.32-eisfair-1-SMP/usbhid.ko
/sbin/insmod /lib/modules/2.6.32-eisfair-1-SMP/scsi_mod.ko
/sbin/insmod /lib/modules/2.6.32-eisfair-1-SMP/sd_mod.ko
/sbin/insmod /lib/modules/2.6.32-eisfair-1-SMP/scsi_transport_spi.ko
/sbin/insmod /lib/modules/2.6.32-eisfair-1-SMP/mptbase.ko
/sbin/insmod /lib/modules/2.6.32-eisfair-1-SMP/mptscsih.ko
/sbin/insmod /lib/modules/2.6.32-eisfair-1-SMP/mptctl.ko
/sbin/insmod /lib/modules/2.6.32-eisfair-1-SMP/mptspi.ko
/bin/echo -e "\\033[32m\\033[49mWaiting for SCSI-/SATA-/USB-STORAGE 
devices coming up ...\\033[0m"
/bin/sleep 10
/sbin/mdadm --assemble --scan


umount init
gzip -9 initrd
cp initrd.gz /mnt/boot

cd /
sata # lilo -r /mnt

umount /dev/sda1
mount /dev/sda1 /boot
cp -a /boot/initrd.gz /mnt/boot


Reboot


Welcome to eisfair!
base     : 2.3.0
eiskernel: 2.4.3 (2.6.32-eisfair-1-SMP)

sata # mount
/dev/md3 on / type ext4 (rw,errors=remount-ro,acl,user_xattr)
/dev/md1 on /boot type ext4 (rw,errors=remount-ro)
/dev/md4 on /data type ext4 (rw,acl,user_xattr)
devpts on /dev/pts type devpts (rw)
usbfs on /proc/bus/usb type usbfs (rw)
/sys on /sys type sysfs (rw)
sata # cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] 
[raid4] [multipath]
md4 : active raid1 sdb4[1]
       2952128 blocks super 1.2 [2/1] [_U]
       bitmap: 1/1 pages [4KB], 65536KB chunk

md3 : active raid1 sdb3[1]
       1048000 blocks super 1.2 [2/1] [_U]
       bitmap: 1/1 pages [4KB], 65536KB chunk

md2 : active raid1 sdb2[1]
       130944 blocks super 1.2 [2/1] [_U]
       bitmap: 1/1 pages [4KB], 65536KB chunk

md1 : active raid1 sdb1[1]
       49088 blocks [2/1] [_U]
       bitmap: 1/1 pages [4KB], 65536KB chunk

unused devices: <none>
sata # mdadm /dev/md1 --add  /dev/sda1
mdadm: added /dev/sda1
sata # mdadm /dev/md2 --add  /dev/sda2
mdadm: added /dev/sda2
sata # mdadm /dev/md3 --add  /dev/sda3
mdadm: added /dev/sda3
sata # mdadm /dev/md4 --add  /dev/sda4
mdadm: added /dev/sda4
sata # watch cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] 
[raid4] [multipath]
md4 : active raid1 sda4[2] sdb4[1]
       2952128 blocks super 1.2 [2/1] [_U]
         resync=DELAYED
       bitmap: 1/1 pages [4KB], 65536KB chunk

md3 : active raid1 sda3[2] sdb3[1]
       1048000 blocks super 1.2 [2/1] [_U]
       [========>............]  recovery = 40.9% (429504/1048000) 
finish=0.3min speed=28633K/sec
       bitmap: 1/1 pages [4KB], 65536KB chunk

md2 : active raid1 sda2[2] sdb2[1]
       130944 blocks super 1.2 [2/2] [UU]
       bitmap: 0/1 pages [0KB], 65536KB chunk

md1 : active raid1 sda1[0] sdb1[1]
       49088 blocks [2/2] [UU]
       bitmap: 0/1 pages [0KB], 65536KB chunk

unused devices: <none>

Warten bis synchron

mcedit /etc/init.d/boot (fsck einkommentieren)

mcedit /etc/lilo.conf
sata # cat /etc/lilo.conf
lba32
disk = /dev/sda
   bios = 0x80
boot = /dev/md1
raid-extra-boot = /dev/sda,/dev/sdb
read-only
prompt
timeout = 50
vga = normal
image = /boot/kernel
root = /dev/md3
label = eis
initrd = /boot/initrd.gz
append = "raid=noautodetect"

sata # lilo
Added eis  *
The boot record of  /dev/md1  has been updated.
The boot record of  /dev/sda  has been updated.
Warning: /dev/sdb is not on the first disk
The boot record of  /dev/sdb  has been updated.
One warning was issued.

Reboot

-- 
der tom
[eisfair-team]


Mehr Informationen über die Mailingliste Eisfair