Linux Server Storage: Difference between revisions

From Irregularpedia
Jump to navigation Jump to search
Initial
 
No edit summary
Tag: 2017 source edit
 
Line 1: Line 1:
<span id="persistence-mounted-storage"></span>
= Persistence Mounted Storage and Bind Mounts =
 
Managing persistent storage is crucial for ensuring data availability and integrity, whether working with physical drives, virtualized environments like Proxmox, or cloud-based services. This guide covers setting up persistent mounted storage, configuring bind mounts for Proxmox containers and VMs, and using rclone to integrate cloud storage services such as Google Drive, ProtonDrive, pCloud, and more.
 
== Persistence Mounted Storage ==
== Persistence Mounted Storage ==
<pre>
# Determine which drive has the size you attached
lsblk


<syntaxhighlight lang="shell">lsblk #determine which drive has the size you attached
# Prompt the user to select the mounted storage drive
echo "Which is the mounted Storage? (Look at the Storage Size) such as sda sdb sdc: "
echo "Which is the mounted Storage? (Look at the Storage Size) such as sda, sdb, sdc: "
read DRIVE
read DRIVE
mkdir -p $HOME/datadrive #make a directory in the home user directory
sudo mkfs.ext4 /dev/$DRIVE #format drive (sda used here) to use as storage
sudo mount /dev/$DRIVE $HOME/datadrive # mount storage to dir
echo "/dev/$DRIVE ./datadrive ext4 defaults 0 0" | sudo tee -a /etc/fstab # ensure that attached storage is permanently mounted</syntaxhighlight>
<span id="bind-storage-from-host-proxmox-to-and-from-containervm"></span>
== Bind Storage from host proxmox to and from container/vm ==


# Create a directory in the user's home directory
mkdir -p $HOME/datadrive
# Format the drive (sda used here) to use as storage
sudo mkfs.ext4 /dev/$DRIVE
# Mount storage to the created directory
sudo mount /dev/$DRIVE $HOME/datadrive
# Ensure that attached storage is permanently mounted
echo "/dev/$DRIVE $HOME/datadrive ext4 defaults 0 0" | sudo tee -a /etc/fstab
</pre>
== Bind Storage from Host Proxmox to and from Container/VM ==
'''Direct Bind Mount''':
'''Direct Bind Mount''':
<pre>
# LXC containers support bind mounts directly, allowing you to make the host directory accessible inside the container.
# Step 1: Edit the container’s configuration file
# The configuration file is located at:
nano /etc/pve/lxc/<VMID>.conf
# Step 2: Add a mount point entry
# Example configuration line:
mp0: /datadrive/media/,mp=/media,readonly=0
# Explanation:
# - /datadrive/media/ is the source directory on the host.
# - /media is the destination directory inside the container.
# - readonly=0 allows write access. Remove it for read-only access.
# Step 3: Restart the container to apply changes
pct restart <VMID>
</pre>
== Using rclone for Cloud Storage Integration ==
rclone is a powerful tool for mounting and syncing cloud storage services as local directories. Follow these steps to set up rclone with popular services like Google Drive, ProtonDrive, and pCloud.
=== Install rclone ===
<pre>
# Update package manager and install rclone
sudo apt update
sudo apt install -y rclone
</pre>
=== Configure rclone ===
<pre>
# Run the rclone configuration wizard
rclone config
# Follow the prompts to:
# - Create a new remote
# - Select the cloud service (e.g., Google Drive, ProtonDrive, pCloud)
# - Authenticate with your account
# - Save the configuration
</pre>
=== Mount Cloud Storage Locally ===
<pre>
# Create a directory to mount the cloud storage
mkdir -p $HOME/cloudstorage
# Use rclone to mount the cloud storage
rclone mount <remote_name>: $HOME/cloudstorage --daemon
# Example:
# rclone mount gdrive: $HOME/cloudstorage --daemon
</pre>
=== Automate rclone Mount on Boot ===
<pre>
# Create a systemd service file for rclone
sudo nano /etc/systemd/system/rclone.service
# Add the following content, replacing <remote_name> and <mount_point>:
[Unit]
Description=Mount rclone remote at boot
After=network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/rclone mount <remote_name>: <mount_point> --config=/home/$USER/.config/rclone/rclone.conf --daemon
Restart=on-failure
User=$USER
Group=$USER
[Install]
WantedBy=multi-user.target
# Save and enable the service
sudo systemctl enable rclone.service
sudo systemctl start rclone.service
</pre>
=== Supported Cloud Services ===
rclone supports a wide range of cloud storage providers. Some popular options include:
* '''Google Drive''': Seamless integration for personal and business accounts.
* '''ProtonDrive''': Secure and privacy-focused storage.
* '''pCloud''': Affordable and reliable for personal and professional use.
* '''Dropbox''': Widely used for personal and collaborative storage.
* '''Amazon S3''': Scalable object storage for developers and enterprises.


'' LXC containers support bind mounts directly, allowing you to make the host directory accessible inside the container.
== Categories ==
'' Edit the container’s configuration file located at <code>/etc/pve/lxc/&lt;VMID&gt;.conf</code>.
[[Category:Storage]]
'' Add a mount point entry like so: <code>mp0: /datadrive/media/,mp=/media,readonly=0</code>
[[Category:Linux]]
'''' This configuration line mounts <code>/datadrive/media/</code> from the host to <code>/media</code> inside the container. Remove <code>readonly=0</code> if you wish to have write access as well.
[[Category:Proxmox]]
'' Restart the container to apply changes: <code>pct restart &lt;VMID&gt;</code>
[[Category:Containers]]
[[Category:Cloud Storage]]
[[Category:Server Setup]]
[[Category:Guides]]

Latest revision as of 04:09, 21 November 2024

Persistence Mounted Storage and Bind Mounts

Managing persistent storage is crucial for ensuring data availability and integrity, whether working with physical drives, virtualized environments like Proxmox, or cloud-based services. This guide covers setting up persistent mounted storage, configuring bind mounts for Proxmox containers and VMs, and using rclone to integrate cloud storage services such as Google Drive, ProtonDrive, pCloud, and more.

Persistence Mounted Storage

# Determine which drive has the size you attached
lsblk

# Prompt the user to select the mounted storage drive
echo "Which is the mounted Storage? (Look at the Storage Size) such as sda, sdb, sdc: "
read DRIVE

# Create a directory in the user's home directory
mkdir -p $HOME/datadrive

# Format the drive (sda used here) to use as storage
sudo mkfs.ext4 /dev/$DRIVE

# Mount storage to the created directory
sudo mount /dev/$DRIVE $HOME/datadrive

# Ensure that attached storage is permanently mounted
echo "/dev/$DRIVE $HOME/datadrive ext4 defaults 0 0" | sudo tee -a /etc/fstab

Bind Storage from Host Proxmox to and from Container/VM

Direct Bind Mount:

# LXC containers support bind mounts directly, allowing you to make the host directory accessible inside the container.

# Step 1: Edit the container’s configuration file
# The configuration file is located at:
nano /etc/pve/lxc/<VMID>.conf

# Step 2: Add a mount point entry
# Example configuration line:
mp0: /datadrive/media/,mp=/media,readonly=0

# Explanation:
# - /datadrive/media/ is the source directory on the host.
# - /media is the destination directory inside the container.
# - readonly=0 allows write access. Remove it for read-only access.

# Step 3: Restart the container to apply changes
pct restart <VMID>

Using rclone for Cloud Storage Integration

rclone is a powerful tool for mounting and syncing cloud storage services as local directories. Follow these steps to set up rclone with popular services like Google Drive, ProtonDrive, and pCloud.

Install rclone

# Update package manager and install rclone
sudo apt update
sudo apt install -y rclone

Configure rclone

# Run the rclone configuration wizard
rclone config

# Follow the prompts to:
# - Create a new remote
# - Select the cloud service (e.g., Google Drive, ProtonDrive, pCloud)
# - Authenticate with your account
# - Save the configuration

Mount Cloud Storage Locally

# Create a directory to mount the cloud storage
mkdir -p $HOME/cloudstorage

# Use rclone to mount the cloud storage
rclone mount <remote_name>: $HOME/cloudstorage --daemon

# Example:
# rclone mount gdrive: $HOME/cloudstorage --daemon

Automate rclone Mount on Boot

# Create a systemd service file for rclone
sudo nano /etc/systemd/system/rclone.service

# Add the following content, replacing <remote_name> and <mount_point>:
[Unit]
Description=Mount rclone remote at boot
After=network-online.target

[Service]
Type=simple
ExecStart=/usr/bin/rclone mount <remote_name>: <mount_point> --config=/home/$USER/.config/rclone/rclone.conf --daemon
Restart=on-failure
User=$USER
Group=$USER

[Install]
WantedBy=multi-user.target

# Save and enable the service
sudo systemctl enable rclone.service
sudo systemctl start rclone.service

Supported Cloud Services

rclone supports a wide range of cloud storage providers. Some popular options include:

  • Google Drive: Seamless integration for personal and business accounts.
  • ProtonDrive: Secure and privacy-focused storage.
  • pCloud: Affordable and reliable for personal and professional use.
  • Dropbox: Widely used for personal and collaborative storage.
  • Amazon S3: Scalable object storage for developers and enterprises.

Categories