How do you mirror the OS drive? I saw the instructions somewhere but I can't find it anymore.
Mirror OS drive
-
- OMV 4.x
- LeonThePC
-
-
-
No, I am talking about mirroring the OS Flash drive so if one flash drive dies the system will be able to boot from the other. I thought I read somewhere that it is possible. Am I wrong?
-
No, I am talking about mirroring the OS Flash drive so if one flash drive dies the system will be able to boot from the other. I thought I read somewhere that it is possible. Am I wrong?
If you are realtime mirroring two usb sticks (please don't - if you need redundancy, you something better than a usb stick), once one usb stick starts failing, it is going to mirror the corruption to the other usb stick.
-
Are we talking about file corruption or Media corruption. If a flash drive starts to fail will it cause the files to be corrupted on the other flash drive? Then would you say that would be the same with a mirroring on a hard drive? It one drive starts to fail the the other drive will also get corrupted?
If flash drives would die after a few months even with the Flash Plugin enabled why is install the OS recommended to be done to a flash drive.
-
Are we talking about file corruption or Media corruption.
file corruption.
If a flash drive starts to fail will it cause the files to be corrupted on the other flash drive?
Yes.
Then would you say that would be the same with a mirroring on a hard drive? It one drive starts to fail the the other drive will also get corrupted?
Yes but they typically fail after a much longer period of time.
If flash drives would die after a few months even with the Flash Plugin enabled why is install the OS recommended to be done to a flash drive.
I didn't say they would only last a few months with the flashmemory plugin. And it is definitely not *recommended* to use a flash drive. We stopped recommending against flash drives because of the flashmemory plugin but it will never be the recommended media.
Anyway, you are missing my point. I was trying to say that if you can't handle having downtime and want realtime mirroring, use something better than flash drives. You would be putting just as much wear & tear on the backup stick as the primary stick. I would use a scheduled dd or rsync to copy the running stick to the backup once a week or something. You could manually run the sync whenever something major changed on the primary as well.
-
I don't need realtime mirroring, but it would still be nice. Mostly, I want a copy of the OS and configuration so that if the Flash drive dies, I don't have to reinstall and reconfigure.
1. Will rsync make the 2nd flash drive bootable?
2. My motherboard comes with 4 SATA ports. If I am setting up RAID 5 with 4 drives, what other option do I have for boot drive other than Flash drive? The motherboard would have to have 6 or more SATA ports to be able to have a RAID 5 and 2 mirrored OS drives. -
1. Will rsync make the 2nd flash drive bootable?
No.
What I do here is make a nightly dd image of my OMV system drive. I keep the seven most recent images. This is all handled by scripts on cron.
-
OK, you got me convinced.
1. How do I use DD to backup to another Flash drive?
2. How do I schedule to keep only seven?
3. How do I restore? -
Here is the script that makes the dd backups. You will have to properly change it to reflect the id for your system drive and the location of the stored backups. I run this daily on cron at 3:00am.
Bash
Alles anzeigen#!/bin/bash # Script to make dd image of system drive now=$(date +"%Y.%m.%d.%H.%M.%S") file="omv-4-$now.img" cd /srv/dev-disk-by-label-d1/omv-backup-imgs dd if=/dev/disk/by-id/usb-SAMSUNG_SSD_UM410_Series_100000000000-0:0 of=$file bs=1M
The shebang does not display in the above script, so please enter it when you create the file.
Here is the script that moves the daily dd image into a directory that is created with today's date and deletes any directories and files that are older than 7 days. I run this daily on cron at 11:00am. You will have to properly change it to reflect the id for your system drive and the location of the stored backups.
Code
Alles anzeigen#! /bin/sh TEMP=`date +%F` cd /srv/dev-disk-by-label-d1/omv-backup-imgs mkdir $TEMP ls -1 | grep img | xargs -n 10 -i mv {} $TEMP/ cd /srv/dev-disk-by-label-d1/omv-backup-imgs # now remove old directories and files cd /srv/dev-disk-by-label-d1/omv-backup-imgs for i in * do if [ -d $i ] then TODAY=`date +%s` FILETIME=`date +%s -d $i` if [ $? -eq 0 ] then DIFF=`expr $TODAY - $FILETIME` # The number below is seconds # 2592000s 30d # 7776000s 90d # 604800s 7d # 259200s 3d if [ $DIFF -gt 604800 ] then echo $i $DIFF "more than 7 days, say bye bye" cd $i # remove a lot of files, then remove dir ls -1 | xargs -n 10 -i rm -f {} cd .. rmdir $i else echo $i $DIFF "OK" fi else echo $i "is not a dated directory" fi fi done
The above scripts create the dd images of my OMV 16GB SSD system drive and store them on another large hard drive. The size of each dd image is the same size as the system drive, so make sure you have enough room on the other drive to hold as many images as you have decided to keep.
To restore an image you can use dd. Just be very, very careful about the destination (of=) you chose to restore the image file to as it will be overwritten without any warning. The destination drive must be at least as large as the drive that the image was made from. Again, you will have to properly compose this command to reflect your drive id and image file name. This command must be run as root. Again, be very careful specifying the destination drive (of=), I am using /dev/sda here as an example only.
dd if=omv-4-2018.05.01.07.00.01.img of=/dev/sda bs=1M
-
I am sorry but I am new to Linux.
Where & how do I type these scripts so that I can schedule them?
How do I schedule it using cron?Will these jobs show up in the web interface's "scheduled jobs"?
-
You have to create a text file in an editor and paste the script contents into it. Give the file a descriptive name and perhaps the .sh extension. Then make it executable by running chmod 777 scriptname.sh
Don't forget that missing shebang in the first script. It really is in my post but the forum will not display it.
You can put the scripts anywhere, but I put all of mine in /usr/local/scripts
You can use OMV's scheduled jobs to create the crons.
Also, make absolutely sure you have made all the necessary changes to the scripts as required for your setup. And don't rely on these until you have tested the entire process from end to end - creating a backup image, restoring it to new media, and making sure it boots and works. Also, keep an eye on your image storage location to make sure older images are being deleted.
-
First, thank you so much.
Second, sorry again, I work with Windows all day, I am new to linux.How do I use the OMV "scheduled jobs" to create the crons?
changes to the 1st script:
I need help with last line (dd if=/dev/disk/by-id/usb-SAMSUNG_SSD_UM410_Series_100000000000-0:0 of=$file bs=1M )
1st - how do I get the drive UUID. I tried (ls -l /dev/disk/by-uuid) and my results didn't look like yours, i got
f17ff563-9864-44fb-87d0-b4116d1fdd462nd - do I replace this (usb-SAMSUNG_SSD_UM410_Series_100000000000-0:0) with my UUID?
-
See the attached screenshot for an example scheduled job. Adjust to suit.
You can use
/dev/disk/by-uuid/f17ff563-9864-44fb-87d0-b4116d1fdd46
so long as that is your entire OMV system disk. If you have data disks in your machine they will also appear in that list.
I could use similar, but since my OMV system disk is a SSD in an external USB case, I prefer to use what I have - it's clearer.
If you run this command it might provide more details about your disks:
tree /dev/disk -a
What you want to be sure of is that your dd if= statement points to the entire disk and not any of the individual partitions.
-
I forgot to mention that the UUID that I provided was for the partition, sde1, and not the disk, sde. Thank you again.
I tried
tree /dev/disk -ait said that the command is not found.
-
Using a UUID for a partition will not work for this purpose, you must image the entire disk.
For the dd if= part, you can use /dev/sde but this is not the best practice because there is no guarantee that that physical disk will always be /dev/sde. If you add or remove disks or rearrange them by moving the cables around, it could change and you will have problems.
Also, using dd if=/dev/disk/by-label/...... will not work either as it misses the boot track.
Best practice is to use dd if=/dev/disk/by-id/.....
You can install the tree command in a root shell like this:
apt-get install tree
Then use tree /dev/disk -a to get the required information.
-
I did a little research and I found that I can get the ID of my USB by making a directory listing of /dev/disk/by-id
I used "ls -l"The ID of my USB drive is
usb-Lexar_USB_Flash_Drive_B2BA35B8C962-0:0 -
the last line of the 2nd script says "done"
Is that a command?
-
Yes. I believe it ends the if then else structure. But I didn't write it myself.
-
I created the first script. When I ran it I received errors.
ERRORS
line 2: $'\r': command not found
line 4: $'\r': command not found
line 6: $'\r': command not found
line 8: $'\r': command not found
line 9: cd: $'/srv/dev-disk-by-label-backup/OSbackup\r': No such file or directory
line 10: $'\r': command not foundMY SCRIPT
#!/bin/bash# Script to make dd image of system drive
now=$(date +"%Y.%m.%d.%H.%M.%S")
file="omv-4-$now.img"
cd /srv/dev-disk-by-label-backup/OSbackup
dd if=/dev/disk/by-id/usb-Lexar_USB_Flash_Drive_AASORI8PQW0H8O7E-0:0 of=$file bs=1M
Jetzt mitmachen!
Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!