📜 ⬆️ ⬇️

system migration to RAID + LVM (short summary)

A little bit about working with soft RAID (mdadm) and LVM, perhaps with a lot of free time, THIS will turn into some decent article ... for now, just a bunch of commands with brief comments.

So, once it took me more space for a virtualbox folder ...

create fs on the LVM partition on top of the raid0 array of 3 disks:
root@ws:~# mdadm -C /dev/md0 -l0 -n3 /dev/sd[abc]
root@ws:~# mdadm --detail --scan >> /etc/mdadm/mdadm.conf
root@ws:~# pvcreate /dev/md0
Physical volume "/dev/md0" successfully created
root@ws:~# vgcreate -s 64K raid0 /dev/md0
Volume group "raid0" successfully created
root@ws:~# lvcreate -n vbox -L200G raid0
Logical volume "vbox" created
root@ws:~# mkfs.ext4 -b 4096 -E stride=16,stripe-width=48 -L vbox /dev/raid0/vbox

================================================= ==
Later, I decided to transfer the entire system from the / dev / sdd disk to reyd0:

# Transfer the system completely on 3 disks to RAID0 (except for / boot):
# Unmount a partition:
umount /dev/raid0/vbox

# Deletes volume group to unlock reed
vgremove raid0

# Stop reid
mdadm --manage /dev/md0 --stop

# Removing labels (superblocks) from disks:
mdadm --zero-superblock /dev/sd[abc]

# Breakdown of the first disk
fdisk /dev/sda
- Id
/dev/sda1 1 132 1060258+ 83 Linux
/dev/sda2 133 26241 209720542+ fd Linux raid

# Copying the partition table to other disks:
sfdisk -d /dev/sda | sfdisk /dev/sdb
sfdisk -d /dev/sda | sfdisk /dev/sd

# do boot
mkfs.ext2 -L boot /dev/sda1

# doing swap
mkswap /dev/sdb1
mkswap /dev/sdc1

# I collect an array
mdadm -C /dev/md0 -l0 -n 3 /dev/sd[abc]2

# I do that, a group with a fragment size of 64Kb, partitions.
pvcreate /dev/md0
vgcreate -s 64K raid0 /dev/md0
lvcreate -n VirtualBox -L100G raid0
lvcreate -n root -L10G raid0
lvcreate -n var -L10G raid0
lvcreate -n usr -L10G raid0
lvcreate -n tmp -L1G raid0
lvcreate -n home -L100G raid0
lvcreate -n media -L100G raid0

I copy data from old partitions to new ones:
# create snapshot section:
lvcreate -s /dev/main/root -n snap_root -L10G
mount /dev/main/snap_root /mnt/tmp/
mount /dev/raid0/root /mnt/target/

I copy the data:
cp -a /mnt/tmp/* /mnt/target/
#
# fstab
# /boot; grub MBR
#. . =)

')

Source: https://habr.com/ru/post/67287/


All Articles