Hard drive unplug or hot swap (no RAID)

    • OMV 1.0
    • Hard drive unplug or hot swap (no RAID)

      Hi,

      I installed 3.5 hard drive external bays/trays on my OMV box.

      I have two data drive.
      First one is for live data (where I modify files often).
      Second one is a backup drive where I rsync or rsnapshop some folders from the first once in a while. I would like to be able to take out that second disk and put it some place safe since it is not used most of the time.

      Just to be clear, that is not my only backup, I also backup to a USB drive that I keep at my work. So I do repect the 1-2-3 backup rule. moving on...

      Please consider that I am not using RAID, my drives are formatted in EXT4 and I am using AHCI.

      - Can I unplug a drive or do I need to power off the OMV box first? Do I need to unmount first? Or hdparm -Y? Or can I just pull it out? Is it risky?

      - I don't seem to be able to unmount without deleting all my samba shares first. Even deactivate them is not enough. Why is it so? It's clear that I do not plan on deleting and recreating my share every time. What is the workaround for this? Force unmount?

      - Can I put back an existing hard drive on a different sata port? Will it be recognize correctly by OMV/Debian or is the drive ID is linked to the SATA port where it was connected first?

      - Let's say that I power off and remove the drive. What happen if a drive is missing when OMV is powered on? Will it create any issue with OMV? Will everything be back as I replug the drive?

      I do realize that I could simply try it to get my answers. But I prefer to understand how it should be done first.

      thanks a lot for your time

      regards,
    • Balzac wrote:

      Can I unplug a drive or do I need to power off the OMV box first? Do I need to unmount first? Or hdparm -Y? Or can I just pull it out? Is it risky?


      Usual thing is unmount and remove live if you wish (depends if it is hot plug)

      Balzac wrote:

      I don't seem to be able to unmount without deleting all my samba shares first. Even deactivate them is not enough. Why is it so? It's clear that I do not plan on deleting and recreating my share every time. What is the workaround for this? Force unmount?


      Intended behaviour. is assumed all your data internal drives are there all the time not for constant removal.

      Balzac wrote:

      Can I put back an existing hard drive on a different sata port? Will it be recognize correctly by OMV/Debian or is the drive ID is linked to the SATA port where it was connected first?


      Yes. Formatted FS disk generate a unique ID.

      Balzac wrote:

      Let's say that I power off and remove the drive. What happen if a drive is missing when OMV is powered on? Will it create any issue with OMV? Will everything be back as I replug the drive?


      A service that had share on that path will try to eventually write there, filling your OS drive probably

      Use the usb backup plugin if you want to insert and remove drives constantly
      chat support at #openmediavault@freenode IRC | Spanish & English | GMT+10
      telegram.me/openmediavault broadcast channel
      openmediavault discord server
    • Thanks for the quick reply SubZero. Much appreciated.

      subzero79 wrote:

      Usual thing is unmount and remove live if you wish (depends if it is hot plug)


      By "remove live", you mean unplug the power cord? No need to spin down?

      subzero79 wrote:

      Intended behaviour. is assumed all your data internal drives are there all the time not for constant removal.


      Makes sense. However, it would be nice to be able to toggle a drive as "removable".

      subzero79 wrote:

      A service that had share on that path will try to eventually write there, filling your OS drive probably


      Yes, I read about that. Is it considered a bug or is it simply how Linux works? I would have expect that any try to write on an non-existing drive would simply fail (a la Windows).

      subzero79 wrote:

      Use the usb backup plugin if you want to insert and remove drives constantly


      Can this plugin be used with sata or esata drive as well?


      If I understand correctly, nothing prevent me to remove a drive as long as
      1. It is unmounted and there is no share
      2. There is no script, cron job or plugin that try to write on it while it is unavailable.

      So basicaly, in my case since I am using rsnapshot, I should keep it in the OMV box at all time. However, I could use another drive in my external bay as a manual backup device.

      The post was edited 1 time, last by Balzac ().

    • Balzac wrote:

      By "remove live", you mean unplug the power cord? No need to spin down?


      spin down is a power management feature. Never done it before to unplug a drive

      Balzac wrote:

      Makes sense. However, it would be nice to be able to toggle a drive as "removable".


      You can submit a feature request at bugtracker.openmediavault.org

      Balzac wrote:

      Yes, I read about that. Is it considered a bug or is it simply how Linux works? I would have expect that any try to write on an non-existing drive would simply fail (a la Windows).


      this is the linux village, no C: or D:

      Balzac wrote:

      Can this plugin be used with sata or esata drive as well?


      I think is restricted to USB, but i am not sure. You can test it, if it doesn't work you can submit a feature request also at bugtracker


      Balzac wrote:

      If I understand correctly, nothing prevent me to remove a drive as long as
      1. It is unmounted and there is no share
      2. There is no script, cron job or plugin that try to write on it while it is unavailable.


      That's in the webUI, if you're in ssh there is a switch option in the unmount command called lazy that can force unmount. Of course pid's that are writing to the volume will write to the OS path probably or maybe some will abort since the path is gone.
      chat support at #openmediavault@freenode IRC | Spanish & English | GMT+10
      telegram.me/openmediavault broadcast channel
      openmediavault discord server
    • Balzac wrote:

      Can this plugin be used with sata or esata drive as well?


      I think esata was added some time ago.

      Greetings
      David
      "Well... lately this forum has become support for everything except omv" [...] "And is like someone is banning Google from their browsers"

      Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.


      Upload Logfile via WebGUI/CLI
      #openmediavault on freenode IRC | German & English | GMT+1
      Absolutely no Support via PM!

      I host parts of the omv-extras.org Repository, the OpenMediaVault Live Demo and the pre-built PXE Images. If you want you can take part and help covering the costs by having a look at my profile page.
    • subzero79 wrote:

      this is the linux village, no C: or D:


      It's more like a big city, isn't it? Once in a while, you get lost... :)
      Thanks a lot for quick and detailed answers. I will absolutly do feature resquests as I think they could be nice to have.

      davidh2k wrote:

      I think esata was added some time ago.

      Ok, I'll try it. But in my case, I have sata (not esata) drive in an external bay. I don't know if they will be seen as removable. Worth a try. I'll post back my results.

      thanks

      The post was edited 1 time, last by Balzac ().

    • lulu, I have the same aim: I have several SATA drives and a hot-pluggable caddy on a Silicon Image hot-swap controller; I used to use vanilla Ubuntu server and simply had a script to mount whichever drive was inserted to /mnt/backup and then rsnapshot wrote to that directory. It's simple enough, but sadly none of the OMV plug-ins quite delivers the same functionality. I'm playing with rsnapshot and USB Backup (slowly) to see whether there's a way to make it possible, perhaps with something similar to my old Ubuntu disk-swap script.

      In OMV, I can see my backup volume, sda (and two data disks that are on the same SATA controller) in the list of backup targets for USBBackup. I wonder whether yours isn't showing up because the controller or the drive caddy isn't seen as hot-pluggable by OMV's Debian OS? Unfortunately, I don't know a way in linux to find out whether the OS thinks the disk is hot-pluggable or not. Maybe someone else does...?

      My aim is to find out whether I can make the removable SATA disk the target for rsnapshot without writing snapshots to another disk and then copying them to the removable (thus doing the job twice). If I get anywhere with that, I'll report back!

      Jeff
    • I don't think there's a way to ask the Kernel if a particular disk is hot pluggable and I believe the Kernel assumes that all disks just are. Though I'm not sure that's true for IDE drives or weird non-standard controllers. In general, USB, eSATA, AHCI SATA, and Firewire are always assumed to be hotpluggable by the kernel. After that, it's up to the hardware to do the right thing and finding the right hardware can be hard. I've never seen a USB device have issues with hotplugging, that would kind of defeat the purpose of being a USB device...

      In terms of removing the disk, it should be unmounted first and then you can just disconnect it. Once it's unmounted, you ensure that everything is stored on the disk, nothing is in memory, and the filesystem is clean. Modern disks are designed to handle hard power downs so you should be able to remove it. The only danger that remains is physically jostling the disk while it's still spinning. While the chance of this causing an issue is slim, I still tend to power down USB drives first before I move them, though this is only true for mechanical drives. Solid state obviously doesn't matter as it doesn't spin.

      I imagine the problem is that OMV's plugins are just not built for hotplugging at the moment. It would be pretty cool if they had a way to deal with this situation. Something like checking if the disk is mounted before backing up and using an automounter like help.ubuntu.com/community/Autofs to automatically mount the drive when it's connected. It's certainly doable, it would just take a bit of work.

      If you're comfortable with scripting, building OMV plugins isn't terribly difficult. It does require learning a bit of PHP and JS though, depending on what you're trying to do.