Note:
nvme0 = disk ( nvme uses PCI interface )
sda = disk ( sda uses SATA III interface )
nvme0, nvme1 = nvme disk 1,nvme disk 2
sda,sdb,sdc,sdd = disk1,disk2,disk3,disk4
nvme0n1p1 = disk1 partition1
nvme0n1p2 = disk1 partition2
nvme1n1p1 = disk2 partition1
nvme1n1p2 = disk2 partition2
sda1 = disk1 partition1
sdb3 = disk2 partition3
sdc2 = disk3 partition2
md0 = raid
md1 = raid
muhammadshakeeb@test12:~$ lsblk -l
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
md0 9:0 0 255.7M 0 raid1 /boot
md0 9:0 0 255.7M 0 raid1 /boot
md1 9:1 0 953.5G 0 raid1
md1 9:1 0 953.5G 0 raid1
nvme0n1 259:0 0 953.9G 0 disk
nvme0n1p1 259:1 0 256M 0 part
nvme0n1p2 259:2 0 953.6G 0 part
nvme1n1 259:3 0 953.9G 0 disk
nvme1n1p1 259:4 0 256M 0 part
nvme1n1p2 259:5 0 953.6G 0 part
muhammadshakeeb@test23:~$ lsblk -l
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 477G 0 disk
sda1 8:1 0 32G 0 part
sda2 8:2 0 512M 0 part
sda3 8:3 0 40G 0 part
sda4 8:4 0 1K 0 part
sda5 8:5 0 404.4G 0 part
sdb 8:16 0 477G 0 disk
sdb1 8:17 0 32G 0 part
sdb2 8:18 0 512M 0 part
sdb3 8:19 0 40G 0 part
sdb4 8:20 0 1K 0 part
sdb5 8:21 0 404.4G 0 part
root@test34 ~ # lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 953.9G 0 disk
|-sda1 8:1 0 10G 0 part
| `-md0 9:0 0 10G 0 raid1 /boot
|-sda2 8:2 0 16.7G 0 part
| `-md1 9:1 0 50G 0 raid5 /
|-sda3 8:3 0 19.9G 0 part
| `-md2 9:2 0 59.7G 0 raid5
`-sda4 8:4 0 907.3G 0 part
`-md3 9:3 0 2.7T 0 raid5
cat /sys/block/sda/queue/rotational
If output is 1 then it is HDD if output is 0 then it is SSD.
muhammadshakeeb@test12:~$ sudo parted /dev/nvme1n1
Model: SAMSUNG MZVLB1T0HBLR-00000 (nvme)
Disk /dev/nvme1n1: 1024GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
(parted) mklabel msdos
(parted) print
Model: SAMSUNG MZVLB1T0HBLR-00000 (nvme)
Disk /dev/nvme1n1: 1024GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
Above you can see the Partiontable is msdos. Now you need to create 1st partition
(parted) mkpart primary 1049kB 269MB
(parted) print
Model: SAMSUNG MZVLB1T0HBLR-00000 (nvme)
Disk /dev/nvme1n1: 1024GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 269MB 268MB primary lba
Now 2nd partition.
(parted) mkpart primary 269MB 1024GB
(parted) print
Model: SAMSUNG MZVLB1T0HBLR-00000 (nvme)
Disk /dev/nvme1n1: 1024GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 269MB 268MB primary lba
2 269MB 1024GB 1024GB primary lba
(parted) quit
Information: You may need to update /etc/fstab.
(parted)
Below basically shows that there are two RAIDS [md0 and md1] ( RAID Level is 1 ) Currently single disk partition is attached on a raid md0 and raid md1.
For RAID 1, you should have two disk ( As it is mirroring )
muhammadshakeeb@test12:~$ sudo cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md1 : active raid1 nvme0n1p2[0]
999809344 blocks super 1.2 [2/1] [U_]
bitmap: 1/8 pages [4KB], 65536KB chunk
md0 : active raid1 nvme0n1p1[0]
261824 blocks super 1.2 [2/1] [U_]
unused devices: <none>
muhammadshakeeb@redis12:~$ sudo mdadm /dev/md0 --add /dev/nvme1n1p1
mdadm: added /dev/nvme1n1p1
muhammadshakeeb@redis12:~$ sudo mdadm /dev/md1 --add /dev/nvme1n1p2
mdadm: added /dev/nvme1n1p2
To Recheck the process either partition added or not
muhammadshakeeb@redis12:~$ sudo cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md1 : active raid1 nvme1n1p2[2] nvme0n1p2[0]
999809344 blocks super 1.2 [2/1] [U_]
[>....................] recovery = 0.1% (1001856/999809344) finish=66.4min speed=250464K/sec
bitmap: 1/8 pages [4KB], 65536KB chunk
md0 : active raid1 nvme1n1p1[2] nvme0n1p1[0]
261824 blocks super 1.2 [2/2] [UU]
unused devices: <none>
Some time it happens that grub fails and you are not able to boot the system. Best would be to start the server with liveCD or rescue mode. There are different ways to do that.
To not break anything I have followed below steps
- First check the disk structure using lsblk command. In this way you may know where is ROOT and BOOT. If They are in separate disk then you need to follow the steps as below else you can skip: POINT # 2
root@rescue ~ # mkdir /shakeeb/
We have use vg--system-root because it does contain the root partition. you can check using lsblk where is your root and put the same structure for example it is mostly inside: /dev/nvme0n1 or /dev/sda ....
root@rescue ~ # mount /dev/mapper/vg--system-root /shakeeb
- We have mounted /dev/md0 because here it shows a separate disk for BOOT in RAID mode. You can skip it if you have all partition/boot in one disk.
root@rescue ~ # mount /dev/md0 /shakeeb/boot/
-
Use the proc dev sys files from the rescue mode system. root@rescue ~ # mount --bind /proc /shakeeb/proc root@rescue ~ # mount --bind /dev /shakeeb/dev root@rescue ~ # mount --bind /sys /shakeeb/sys
-
Once all mounted then you need to switch the mode ( chroot )
root@rescue ~ # chroot /shakeeb /bin/bash
root@rescue / # ls -la
- Update grub
root@rescue / # update-grub
- If you have two disk ( with BOOT ) then run both the command as below.
root@rescue / # grub-install /dev/nvme0n1
Installing for i386-pc platform.
Installation finished. No error reported.
root@rescue / # grub-install /dev/nvme1n1
Installing for i386-pc platform.
Installation finished. No error reported.
root@rescue / # sync
- Exit and then reboot. You can easily access the server then.
Here I am changing the partition type to swap memory. HEX CODE = 82 is for SWAP
root@elk4 ~ # fdisk /dev/sdb3
Welcome to fdisk (util-linux 2.33.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
The old linux_raid_member signature will be removed by a write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x2bad72a0.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 3
First sector (2048-41732095, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-41732095, default 41732095):
Created a new partition 3 of type 'Linux' and of size 19.9 GiB.
Command (m for help): t
Selected partition 3
Hex code (type L to list all codes): 82
Changed type of partition 'Linux' to 'Linux swap / Solaris'.
Command (m for help): w
The partition table has been altered.
Failed to add partition 3 to system: Invalid argument
The kernel still uses the old partitions. The new table will be used at the next reboot.
Syncing disks.
1 lsblk
2 parted /dev/sdd
3 apt-get update
4 apt-get install sudo crypptab parted
5 apt-get install sudo crypptab
6 apt-get install sudo cryptab
7 apt-get install sudo crypttab
8 apt-get install sudo cryptsetup parted
9 parted /dev/sda
10 parted /dev/sdb
11 parted /dev/sdc
12 parted /dev/sdd
13 lsblk
14 sudo mdadm --create --verbose /dev/md2 --level=5 --raid-devices=4 /dev/sda3 /dev/sdb3 /dev/sdc3 /dev/sdd3
15 lsblk
16 sudo mdadm --create --verbose /dev/md3 --level=5 --raid-devices=4 /dev/sda4 /dev/sdb4 /dev/sdc4 /dev/sdd4
17 lsblk
18 fdisk /dev/sdd3
19 fdisk /dev/sdc3
20 fdisk /dev/sdb3
21 fdisk /dev/sda3
22 partprobe /dev/sda
23 partprobe /dev/sdb
24 partprobe /dev/sdc
25 partprobe /dev/sdd
26 lsblk
27 mkswap /dev/md2
28 free -m
29 swapon -s
30 free -m
31 cat /etc/fstab
32 swapon /dev/md2
33 free -m
34 cat /etc/fstab
35 vim /etc/fstab
36 sudo init 6
37 htop
38 apt-get install htop
39 htop
40 lsblk
41 sudo cryptsetup luksFormat --type luks1 /dev/md126
42 sudo cryptsetup luksDump /dev/md127
43 sudo cryptsetup luksDump /dev/md126
44 vim /etc/crypttab
45 sudo cryptdisks_start data-crypt
47 mkfs.ext4 /dev/mapper/data-crypt
48 ls -la /dev/sd*
49 ls -la /dev/mapper/
50 mkdir /data
51 blkid /dev/mapper/data-crypt
52 vim /etc/fstab
53 df -hT
54 mount -a
55 df -hT
56 mount -fa
57 df -hT
58 lsblk
59 cat /etc/crypttab
60 mount /dev/mapper/data-crypt /data/
61 df -hT
62 sudo init 6
63 lsblk
64 df -hT
65 psctl server start
66 history