1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Mounting a RAID permanently

Discussion in 'Linux & Open Source' started by Marky, May 20, 2020.

  1. Marky

    Capodecina

    Joined: Apr 16, 2007

    Posts: 23,012

    Location: UK

    Hi all,

    As I have more time on my hands at the moment, I have started to learn how to use Linux properly (and headless!). I have a microserver setup to run Ubuntu Server LTS 18.04 and I have a few questions regarding the RAID setup...

    I currently have 2x1TB HDD running in RAID0, as I was only testing this at first. I am soon going to load 2x2TB HDD in RAID1 as a more permanent solution.

    Until I do that, I mounted the 2x1TB drives like so:

    Code:
    sudo mount /dev/md0 /media/Storage

    This has mounted the RAID to /media/Storage, which is perfect.
    However, whenever I shutdown the system the mount is no longer there and the Storage folder is empty.

    1. How do I have it so that it mounts the drives automatically on power up?

    2. I plan on moving to 2x8TB drives in the future, and then hopefully add additional 8TB drives as and when I require it. How would the RAID setup work for that? Is it just a matter of changing the RAID and adding the drive? Or is it more complicated?

    Additionally, if you have any resources/tutorials websites that you think would be helpful to a beginner Linux user like me, please suggest away :D

    Thanks!

    Marky
     
  2. pete910

    Mobster

    Joined: Oct 3, 2013

    Posts: 2,784

    In the /etc/fstab add

    Code:
    /dev/md0 /media/Storage ext4  rw,user,exec  1 1
    Use ext4 if thats what the file system is formatted as, change accordingly to what you need .

    Edit,

    Regards adding to the RAID it depends on how you have set it up originally.

    I'll dig some links up for you to read .

    :)
     
    Last edited: May 20, 2020
  3. droyden

    Hitman

    Joined: Oct 4, 2009

    Posts: 891

    If you have space (physical), then you can add 2x8 create the raid, create the file system, rsync the data, update the fstab, shutdown, remove the old disks. Done.

    If you have space for 1 disk only, you can add 1 disk, add to the raid, fail 1 disk in the existing raid. Rebuild to the 8tb disk, once synced, remove unused disk replace with another 8tb, repeat.

    Once the raid is synced on the 8tb disks but at the old size you can use --grow and then resize the file system. Less simple and more prone to issues if you have a disk failure during migration.

    Once
     
  4. Marky

    Capodecina

    Joined: Apr 16, 2007

    Posts: 23,012

    Location: UK

    Brilliant thanks for that :)

    If you do have any links for me to read up on, that would be massively helpful :)

    Strange one though... I reinstall Ubuntu Server just now and after creating the file system for the RAID and mounting md0. I was expecting it to unmount itself again on reboot, but this time it stays mounted! :p

    That doesn't sound too bad at all :D Thanks a lot :)
     
  5. Marky

    Capodecina

    Joined: Apr 16, 2007

    Posts: 23,012

    Location: UK

    Oh dear what have I done and how can I fix it :p...

    I was having some issues with a container not being able to create directories itself. So I edited the /etc/fstab - It was:

    Code:
    /dev/md0 /media/Storage ext4  rw,user,exec  1 1
    and I changed it to:

    Code:
    /dev/md0 /media/Storage ext4  rw,user,exec,uid=1000  1 1

    Bolded the change above. What have I done? I rebooted my system, and on reboot I now get "Connection Refused" when I try to SSH into my IP.
     
  6. pete910

    Mobster

    Joined: Oct 3, 2013

    Posts: 2,784

    Sounds like it's not booted due to failing to mount the volume.

    Do you have the correct UID ?

    On reflection user may not be needed as on a server. You will just need the correct perms to access the folders/files though. I take it the server has a user setup that you use to access the shares?

    Try this

    Code:
    /dev/md0 /media/Storage ext4 defaults 1 1
     
  7. Marky

    Capodecina

    Joined: Apr 16, 2007

    Posts: 23,012

    Location: UK

    The OS is on its own SSD, away from the md0 RAID.

    The only user on the server is the one I started with (admin) (ID: 1000).

    I assume I will need to link my server up to a monitor now it won’t let me SSH in?

    EDIT: Attached a monitor and it showed GNU GRUB? And then booted into "emergency mode" - Never heard of it :p

    EDIT2: I removed the line from fstab and rebooted. All good. I've now put the line you said "default" and it loads up fine :D

    Still having an issue with regards to the container not being able to create a folder on the mount though for some reason. I've setup the volumes in Portainer, but it's not playing ball for some reason...

    EDIT3: Oh man I finally got there in the end through trial and error. CHMOD to the folders 777 and restart of everything, think that was it :p
     
    Last edited: May 24, 2020
  8. pete910

    Mobster

    Joined: Oct 3, 2013

    Posts: 2,784

    :cool:
    Good, was going to check with you what the perms are on the folders.

    Just a FYI, 777 is not advisable as anyone can view/modify it :eek:

    Do 744 at least, then only the owner can write to said folders .
     
  9. Marky

    Capodecina

    Joined: Apr 16, 2007

    Posts: 23,012

    Location: UK

    I just CHMOD 755 the folders that the container writes to, and it kicked up an error again.

    Set it back to 777, did the same action, no errors.

    What do you reckon? :/
     
  10. pete910

    Mobster

    Joined: Oct 3, 2013

    Posts: 2,784

    What user are you using to access the remote file system? Please don't say root !

    If you are using a user acc make sure the files/folders on the server belong to the correct user/group
     
  11. Marky

    Capodecina

    Joined: Apr 16, 2007

    Posts: 23,012

    Location: UK

    No I login with the first and only account I made on the server (just admin).

    I don't know much about the user/group permissions system, so I'll need to do a little reading up on that.
     
  12. pete910

    Mobster

    Joined: Oct 3, 2013

    Posts: 2,784

    Admin generally means root on a lot of front ends for the windows people.

    I'll have a play with ubuntu server in a vm.

    To check file/folder perms in linux ssh in, cd to the dir in question and type

    Code:
    ls -l 
    It should show something similar to this

    Code:
    ls -l
    total 552
    drwxr-xr-x  5 pete pete   4096 Dec 16 22:40  Cinibench-R20
    -rwxr-xr-x  1 pete pete   9508 Dec 11 22:13 'CPU Core Usage.sgrd'
    drwxr-xr-x  2 pete pete   4096 May  4 23:17  Desktop
    drwxr-xr-x  2 pete pete   4096 May 26 15:37  Documents
    drwxr-xr-x  5 pete pete   4096 May  7 20:03  Downloads
    -rwxr-xr-x  1 pete pete   3486 Mar  3 00:16  fancon.sh
    drwxr-xr-x 20 pete pete   4096 May 22 23:22  Games
    -rw-r--r--  1 pete pete 486907 Mar 25 12:08  labeling_poster.pdf
    drwxr-xr-x  4 pete pete   4096 Sep  1  2015  luxmark-v3.1
    drwxr-xr-x  2 pete pete   4096 Apr  6 11:35  Music
    drwxr-xr-x  5 pete pete   4096 Jan 12 00:01  okimfpsdrv
    drwxr-xr-x  2 pete pete   4096 May 15 15:10  Pictures
    drwxr-xr-x  3 pete pete   4096 Jan 21 21:43  tmp
    -rw-r--r--  1 pete pete   6506 Mar 24 23:14  us-free-02.protonvpn.com.udp.ovpn
    drwxr-xr-x  3 pete pete   4096 Apr 11 21:24  Videos
    drwx------  6 pete pete   4096 May  4 23:14 'X4 Foundations'
    drwxr-xr-x  3 pete pete   4096 May  8 09:57  zenpowe
     
  13. Marky

    Capodecina

    Joined: Apr 16, 2007

    Posts: 23,012

    Location: UK

    It's actually "pluto_admin". This is what shows on ls -l

    Code:
    drwxr-xr-x  5 root        root        4096 May 25 00:10 Downloads
    drwxrwxr-x+ 8 pluto_admin pluto_admin 4096 May 25 00:10 docker
    drwxr-xr-x  3 root        root        4096 May 24 22:04 media
    drwxr-xr-x  3 root        root        4096 May 24 22:04 sabnzbd
    SAB should be creating a folder in /media/Storage/

    /media/Storage is the mount for the 2x2TB.
     
  14. pete910

    Mobster

    Joined: Oct 3, 2013

    Posts: 2,784

    looks to me like its all root as the main use dir is root. Is there any way to add a user acc in the GUI(if it has one)

    Edit:

    You on discord?
     
  15. Marky

    Capodecina

    Joined: Apr 16, 2007

    Posts: 23,012

    Location: UK

    It's headless, so no GUI unfortunately.

    What does the ls -l command do?
    I don't know why Downloads, media or SAB are on there - I run everything through Docker/Portainer (and I have other containers running that aren't in this list).
     
  16. pete910

    Mobster

    Joined: Oct 3, 2013

    Posts: 2,784

    Not up on docker to be frank, I need to have a mess to see how it's setup :(

    If what you are after accessing is in the docker folder then by the looks of it you need to be useing the user name pluto_admin

    Edit:

    Just cd up one dir and post the output of ls -l
     
  17. Marky

    Capodecina

    Joined: Apr 16, 2007

    Posts: 23,012

    Location: UK

    I cd up and it was the home folder, and then cd up again and it must be root. Now ls -l is showing:

    Code:
    total 4194400
    drwxr-xr-x   2 root root       4096 May 24 21:48 bin
    drwxr-xr-x   3 root root       4096 May 24 21:49 boot
    drwxr-xr-x   2 root root       4096 May 24 21:11 cdrom
    drwxr-xr-x  20 root root       4180 May 26 16:51 dev
    drwxr-xr-x  94 root root       4096 May 24 22:29 etc
    drwxr-xr-x   3 root root       4096 May 24 21:38 home
    lrwxrwxrwx   1 root root         34 May 24 21:13 initrd.img -> boot/initrd.img-4.15.0-101-generic
    lrwxrwxrwx   1 root root         34 May 24 21:13 initrd.img.old -> boot/initrd.img-4.15.0-101-generic
    drwxr-xr-x  22 root root       4096 May 24 21:12 lib
    drwxr-xr-x   2 root root       4096 Feb  3 18:22 lib64
    drwx------   2 root root      16384 May 24 21:10 lost+found
    drwxr-xr-x   3 root root       4096 Feb  3 18:22 media
    drwxr-xr-x   2 root root       4096 Feb  3 18:22 mnt
    drwxr-xr-x   3 root root       4096 May 24 21:52 opt
    dr-xr-xr-x 169 root root          0 May 26 16:51 proc
    drwx------   4 root root       4096 May 24 21:57 root
    drwxr-xr-x  28 root root        960 May 26 21:29 run
    drwxr-xr-x   2 root root      12288 May 24 21:52 sbin
    drwxr-xr-x   4 root root       4096 May 24 21:38 snap
    drwxr-xr-x   2 root root       4096 Feb  3 18:22 srv
    -rw-------   1 root root 4294967296 May 24 21:13 swap.img
    dr-xr-xr-x  13 root root          0 May 26 16:51 sys
    drwxrwxrwt   9 root root       4096 May 26 21:30 tmp
    drwxr-xr-x  11 root root       4096 May 24 21:52 usr
    drwxr-xr-x  13 root root       4096 Feb  3 18:24 var
    lrwxrwxrwx   1 root root         31 May 24 21:13 vmlinuz -> boot/vmlinuz-4.15.0-101-generic
    lrwxrwxrwx   1 root root         31 May 24 21:13 vmlinuz.old -> boot/vmlinuz-4.15.0-101-generic
    
    "media" is the folder that holds "Storage".
     
  18. pete910

    Mobster

    Joined: Oct 3, 2013

    Posts: 2,784

    Got me thinking, looking a bit odd to me, not used unbutu server, in fact debian based so at a loss tbh.

    I'll download it and run it in a VM to have a look later. am sure there are some on here that are more versed in it though.

    I personally use Clearos as it has a web frontend to administer the server.
    https://www.clearos.com/clearfoundation/software/clearos-7-community
     
  19. Marky

    Capodecina

    Joined: Apr 16, 2007

    Posts: 23,012

    Location: UK

    No worries mate, thanks a lot for the help anyways! :D
    I’ll do some more reading and I’m sure I’ll sort it