Archive for novembre, 2009

Howto Raid1 with LVM ubuntu

I’ve 2 disk 1T.
I partitioned the disk in this way:

fdisk /dev/sdx
x is letter of your disk (check it with command fdisk -l)
This is a sequence of command in fdisk
n
p
1
+500G
t
8e
… ecc … and in this way i created 3 partition primary and 3 partition in the extended area
500G 256G 124G 64G 32G 32G

Now i must clone the partition table in the second disk
sfdisk -d /dev/sdx | sfdisk /dev/sdy

I crete the device raid md0
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdx /dev/sdy
add the md0 in phisical lvm
pvcreate /dev/md0
group lvm
vgcreate backup-raid /dev/md0
logical volume
lvcreate -L+500G -n backupRaid backup-raid
format the new raid area
mkfs.ext4 -j /dev/backup-raid/backupRaid

Configure mdadm.conf
mdadm --detail --scan >> /etc/mdadm/mdadm.conf

Create a mount point
mkdir /media/backup
and modify /etc/fstab
/dev/mapper/backup--raid-backup--raid /media/backup ext4 rw 0 0

and now…
reboot for check if all this ok

Troubleshiting

Create swap space with lvm (Creare swap con lvm)

This is a sequence of command that i use in “chimera” for create a swap space variable with lvm.
Turnoff swap area
swapoff -a
I prepare my swap space with lvm

fdisk /dev/sdx
(x is letter of your disk) … ecc ecc…
pvcreate /dev/sdxy (x is letter of your disk and y is number partition)
vgcreate swap /dev/sdxy
lvcreate -L+4G swap swap

now format partition

mkswap /dev/swap/swap

Turn on swap area
swapon -a

Check free memory swap
free -m

If the area swap not turn on i resolved in this way
I check the UUID for new swap area
blkid -c /dev/null | grep swap
Write in /etc/fstab the uuid mount the swap area

UUID=ff049cd2-b1a9-ff4a-9722-651b52beeda1 none swap sw 0 0

Write in /etc/initramfs-tools/conf.d/resume
RESUME=UUID=ff049cd2-b1a9-ff4a-9722-651b52beeda1

now
update-initramfs -u
and……
reboot

Bye bye bye
Sorry for my english…… You feel free for correct any word of this article.