Mounting storage is the process of attaching an additional disk or storage device to a server and making it available to the operating system. This expands the server's storage capacity for storing data or other files. Here are the general steps to mount storage on a Linux system:
1. Confirm the storage device First, make sure you have an available storage device, which can be a physical hard disk, disk array, network storage device (such as NAS), etc. Insert or connect the storage device to the server, and then run the following command to check whether the system can detect the new device:
bash
sudo fdisk -l
2. Format the storage device If the new device is brand new or unformatted, you will need to partition and format it. Note that this will wipe all data on the device, so proceed with caution.
For example, if the new device is /dev/sdb, you can format it with:
bash
sudo fdisk /dev/sdb # 创建分区(选项 n) # 选择主分区或逻辑分区 # 设定分区大小等(默认即可) # 保存并退出(选项 w) # 格式化分区 sudo mkfs.ext4 /dev/sdb1
3. Create a mount point In Linux, you need to create a mount point, which is an empty directory, and mount the storage device to this directory to make the data on the storage device available.
bash
sudo mkdir /mnt/my_storage
4. Mount the storage device Now, you can mount the storage device to the mount point created earlier:
bash
sudo mount /dev/sdb1 /mnt/my_storage
5. Automatic mount By default, the mounted storage device will be invalid after each restart. In order to automount, you need to /etc/fstab
add an entry to the file.
First, use the following command to get the UUID (Universally Unique Identifier) of the storage device:
bash
sudo blkid /dev/sdb1
Then, /etc/fstab
add an entry like this to the file:
bash
UUID=your_uuid_here /mnt/my_storage ext4 defaults 0 2
Replace your_uuid_here
with the UUID you actually obtained. Save and exit /etc/fstab
the file.
6. Check the mount Run the following command to check if the mount was successful:
bash
df -h
You should be able to see the new mount point /mnt/my_storage
and its used space information.
The above are the basic steps to mount the storage device on the Linux system. The specific operations may vary slightly with different Linux distributions and storage device types. When performing the mount operation, please be careful to avoid irreversible impact on important data. If you are new to this, it is recommended to back up your data before doing anything important and seek professional help if needed.