linux: added further guides for disk management and for raid

master
tiyn 3 years ago
parent fcf184fea9
commit ac33388db2

@ -1,15 +1,22 @@
# Disk Management # Disk Management
This entry focusses on non-LVM and non-MDADM storage.
For [LVM](lvm.md) and [MDADM](./mdadm.md) there are separate entries.
## Create Partition
In the following it is assumed that the disk is `/dev/sda`
- open up parted with `parted /dev/sdd`
- if not already done create a partition table with `mklabel GPT`
- create a primary partition (ext4 format) with `mkpart primary 2048s 100%`
- `quit` parted
## Grow non-LVM ext4 partition ## Grow non-LVM ext4 partition
ATTENTION: Please note that the partition to enlarge has to be the last one with ATTENTION: Please note that the partition to enlarge has to be the last one with
the free space after it. the free space after it.
SSH into the VM.
- run `lsblk` check if the disk size has changed
- if not `reboot` the machine
In the following it is assumed that the partition to enlarge is `/dev/sda2` In the following it is assumed that the partition to enlarge is `/dev/sda2`
- change the size of the partition with `parted /dev/sda` - change the size of the partition with `parted /dev/sda`

@ -2,14 +2,44 @@
`mdadm` is a utility to create and manage raid devices. `mdadm` is a utility to create and manage raid devices.
## Get information about a raid
To get an info for a running raid (assuming it is `/dev/md0`) run
`mdadm -D /dev/md0`.
### Add disk/partition to raid device
You can add a disk or partition to a raid device by running the following.
It is assumed you are adding a partition called `/dev/sdd1` but it could also
be a whole drive and the mdadm drive is called `/dev/md0`.
`mdadm --add /dev/md0 /dev/sdd1`
## Raid 1 ## Raid 1
Raid 1 creates a mirror with even amount of drives. Raid 1 creates a mirror with even amount of drives.
### Create Raid 0 device ### Create raid 1 device
You can create a Raid 0 device with You can create a Raid 1 device with
`mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda /dev/sdb` `mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda /dev/sdb`
where `sda` and `sdb` are the disks you want to include in your raid. where `sda` and `sdb` are the disks you want to include in your raid.
You can increase the number of raid devices, but they have to be at least 2. You can increase the number of raid devices, but they have to be at least 2.
If it is an uneven amount of disks in the raid, a disk will act as a spare disk. If it is an uneven amount of disks in the raid, a disk will act as a spare disk.
### Convert raid 1 to raid 5
Assuming the raid device is called `/dev/md0`.
All other drives are part of the `md0` raid device.
- Remove all drives but 2 by running `mdadm /dev/md0 --fail /dev/sda1` and
`mdadm /dev/md0 --remove /dev/sda1` where `sda1` is the drive to remove
- Make sure your raid 1 array has only 2 active drives by running
`mdadm --grow /dev/md0 -n 2`
- Now convert your raid 1 to a raid 5 device with `mdadm --grow /dev/md0 -l5`
- Add the disks you removed back to the raid with
`mdadm /dev/md0 --add /dev/sda1`
- Finally grow the active drive number to your needs (in this example 4)
`mdadm --grow /dev/md0 -n4`
- `mdadm` now reshapes the raid. You can monitor it by running
`watch cat /proc/mdstat`

@ -14,6 +14,9 @@ After that follow the instructions and fill in the fields to your liking.
### Enlarging disk of a VM ### Enlarging disk of a VM
Make sure there is enough disk space available.
For further information see [the disk management entry](./disk-management.md)
SSH into Proxmox. SSH into Proxmox.
Enlarge a disk by using: Enlarge a disk by using:
@ -27,7 +30,7 @@ For example (100G is 100GibiByte):
qm resize 100 ide0 +100G qm resize 100 ide0 +100G
``` ```
After that grow the filesystem as described in [the disk-management article](disk-management.md). After that grow the filesystem as described in [the disk management article](./disk-management.md).
## Remove local-lvm and add its size to local ## Remove local-lvm and add its size to local

Loading…
Cancel
Save