Koozali – Mounting a RAID1 partition from a 2nd server or snapshot backup.

I have an SME server v9 up and running on a VPS (virtual private server).
The provider makes snapshot based backups daily, weekly and monthly.
You can switch to an alternate snapshot in seconds, which works great for an instant full system restore.

Instead of switching you can also attach a snapshotted volume to the live server as an extra hard disk and use this to restore individual files and folders.

When I try to do this I can see the additional hard disk, but I have no idea how to safely mount it properly and browse its content.

I understand the following commands and have a decent understanding of Centos Linux:

Linux disk utilities
 df -h
 fdisk -l
 sfdisk -l
 cat /etc/fstab
 mount
 mdadm -D /dev/md0
 mdadm -D /dev/md1
 cat /proc/mdstat

Logical Volume Manager (LVM)
 vgdisplay
 lvdisplay
 pvdisplay

The normal output without any extra hard disk attached:

[root@home]# df -h
 Filesystem            Size  Used Avail Use% Mounted on
 /dev/mapper/main-root 19G  6.8G   11G  39% /
 tmpfs                 499M     0  499M   0% /dev/shm
 /dev/md0              239M   82M  145M  36% /boot
[root@home]# cat /proc/mdstat
 Personalities : [raid1]
 md0 : active raid1 vda1[0]
 255936 blocks super 1.0 [2/1] [U_]

 md1 : active raid1 vda2[0]
 20697984 blocks super 1.1 [2/1] [U_]
 bitmap: 1/1 pages [4KB], 65536KB chunk
[root@home]# sfdisk -l
Disk /dev/vda: 41610 cylinders, 16 heads, 63 sectors/track
 Units = cylinders of 516096 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start     End   #cyls    #blocks   Id  System
 /dev/vda1   *      2+    509-    508-    256000   fd  Linux raid autodetect
 start: (c,h,s) expected (2,0,33) found (0,32,33)
 end: (c,h,s) expected (509,15,31) found (31,254,31)
 /dev/vda2        509+  41610-  41101-  20714496   fd  Linux raid autodetect
 start: (c,h,s) expected (509,15,32) found (31,254,32)
 end: (c,h,s) expected (1023,15,63) found (1023,254,63)
 /dev/vda3          0       -       0          0    0  Empty
 /dev/vda4          0       -       0          0    0  Empty
 Disk /dev/md1: 5174496 cylinders, 2 heads, 4 sectors/track
 Disk /dev/mapper/main-root: 2449 cylinders, 255 heads, 63 sectors/track
 Disk /dev/mapper/main-swap: 126 cylinders, 255 heads, 63 sectors/track
 Disk /dev/md0: 63984 cylinders, 2 heads, 4 sectors/track

Devices syntax

/dev/hda,hdb,hdc... (= hard disks)
 /dev/hda1..99 (= partitions on hard disk hda)
 /dev/hdb1..99 (= partitions on hard disk hdb)
 /dev/sda,sdb,sdc... (= removable storage)
 /dev/sda1,sda2,sda3... (= partitions on removable storage sda)
 /dev/md0 (md = mirror disk = first RAID1)
 /dev/md1 (md = mirror disk = second RAID1)
 /dev/vda (virtual hard disk)
 /dev/vda1, vda2, vda3, vda4 (partitions on 'vda')

Note that vda1 belongs to md0 and vda2 belongs to md1 but both vda1 and vda2 are part of vda.

The recommended partitioning scheme dictates a separate “/boot” partition to hold the Linux kernel.  For most users, a 100 MB boot partition is sufficient.  In this case it is 239MB.  /dev/mapper/main-root then aliases /dev/md1 as it is 19GB in size and holds the root (“/”) partition (also known as ‘data’ partition.

/dev/mapper/main-root and /dev/mapper/main-swap indicate Logical Volume Manager (LVM) is in use.  LVM is used to combine one or more phyisical devices into a logical device.

So for our SME server we have 1 virtual hard disk (vda) with 2 partitions (vda1 and vda2).
vda1 is 239MB and used to hold “/boot” as part of the degraded RAID1 volume md0
vda2 is  19GB and used to hold “/” as part of the degraded RAID1 volume md1

Use “sme noraid nolvm”

When installing SME server on a Virtual Private Server (VPS), it is best not to use RAID or LVM.  Install SME server using “sme noraid nolvm”.  Note that for the /boot partition the installer will still use a degraded RAID1 volume.  The root (“/”) partition however will be a plain physical partition.

If you use the noraid and nolvm options then you will get something like this:

[root@home]# cat /proc/mdstat
Personalities : [raid1] 
md0 : active raid1 vda1[0]
      255936 blocks super 1.0 [2/1] [U_]
      
unused devices: <none>

[root@home]# fdisk -l

Disk /dev/vda: 536.9 GB, 536870912000 bytes
16 heads, 63 sectors/track, 1040253 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00068d1d

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           3         510      256000   fd  Linux raid autodetect
Partition 1 does not end on cylinder boundary.
/dev/vda2             510        8572     4063232   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/vda3            8572     1040254   519967744   83  Linux
Partition 3 does not end on cylinder boundary.

Disk /dev/md0: 262 MB, 262078464 bytes
2 heads, 4 sectors/track, 63984 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

/dev/vda3 contains the data and can easily be mounted(!)

Mounting a 2nd SME server partition (only works for NOLVM / NORAID).

mkdir /mnt/zzz
mount /dev/vdb3 /mnt/zzz
Koozali – Mounting a RAID1 partition from a 2nd server or snapshot backup. was last modified: February 12th, 2017 by tabcom