Configure automatic mount on startup

更新时间:
复制 MD 格式

An OSS bucket mounted manually does not persist across Linux system restarts. To mount the bucket automatically on every startup, add an entry to /etc/fstab.

Prerequisites

Before you begin, ensure that you have:

  • ossfs 2.0.6 or later installed. If you are on an earlier version of ossfs 2.0, upgrade to 2.0.6 or later. See Install ossfs.

  • ossfs 2.0 configured. See Configure ossfs 2.0.

Add an fstab entry

  1. Open /etc/fstab and add the following line:

       bucket_name mount_point ossfs2 _netdev,nofail,x-systemd.after=networkd-dispatcher.service,conf=/root/ossfs2.conf 0 0

    Replace the placeholders with your actual values:

    ParameterDescription
    bucket_nameThe name of the OSS bucket to mount.
    mount_pointThe local directory to use as the mount point.
    conf=/root/ossfs2.confThe absolute path to your ossfs 2.0 configuration file.
    _netdev,nofail,x-systemd.after=networkd-dispatcher.serviceMount options that ensure the mount runs only after network services are ready (_netdev, x-systemd.after=networkd-dispatcher.service) and that a mount failure does not block system startup (nofail).
    0 0The dump and fsck values. Set both to 0 for ossfs2 file systems.
    Note

    Each fstab entry mounts one bucket. To mount multiple buckets, add a separate entry for each one.

  2. Run the following command to mount all ossfs2 entries in /etc/fstab:

       mount -a -t ossfs2

    If the command completes without errors, the configuration is correct.