You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Amazon EC2 Linux实例添加额外卷后是否自动使用新卷存储咨询

Hey Steve, let’s tackle your EC2 disk space issue step by step—first, the core question you asked:

No, your Linux system won’t automatically start storing files on the new EBS volume once the original runs out of space. Here’s why: when you attach a new volume, it’s unformatted and unmounted by default—your OS doesn’t even recognize it as usable storage until you set it up manually.

Below is a straightforward guide to adding and configuring the extra volume, plus how to make it usable for your system:

Step 1: Attach the new EBS volume to your EC2 instance
  • Head to the AWS EC2 Console, navigate to Volumes under the "Elastic Block Store" section.
  • Click Create volume, choose the size you need, and make sure the Availability Zone matches your EC2 instance (volumes are AZ-specific).
  • Once created, right-click the new volume, select Attach volume, pick your EC2 instance from the dropdown, and confirm.
Step 2: Format the new volume (skip if it has existing data)
  • SSH into your EC2 Linux instance. First, list all block devices to find your new volume:
    lsblk
    
    Look for a device with your chosen size (e.g., /dev/nvme1n1 for Nitro-based instances, or /dev/xvdh for older types).
  • Format it with a filesystem (ext4 is standard for Linux):
    sudo mkfs.ext4 /dev/nvme1n1
    
    Warning: This will erase all data on the volume—only run this if it’s a brand-new, empty volume.
Step 3: Mount the volume to a directory
  • Create a mount point (a directory where the volume will be accessible):
    sudo mkdir /mnt/extra-storage
    
  • Mount the volume to this directory:
    sudo mount /dev/nvme1n1 /mnt/extra-storage
    
  • Verify the mount worked with:
    df -h
    
    You’ll see the new volume listed under /mnt/extra-storage.
Step 4: Make the mount persistent across reboots
  • Get the unique UUID of your new volume (this is more reliable than using the device name, which can change):
    sudo blkid /dev/nvme1n1
    
    Copy the UUID value (looks like abc123-...).
  • Edit the /etc/fstab file to add the mount:
    sudo nano /etc/fstab
    
    Add this line at the end (replace your-uuid-here with the UUID you copied):
    UUID=your-uuid-here /mnt/extra-storage ext4 defaults,nofail 0 2
    
  • Save and exit (Ctrl+O, then Ctrl+X in nano). Test the configuration to avoid boot issues:
    sudo mount -a
    
    If no errors pop up, you’re good to go.
Optional: Migrate large existing directories to the new volume

If your original disk is full because of specific large directories (like /var/log, /home, or app data), you can move those to the new volume to free up space immediately:

  • For example, to migrate /var/log:
    1. Stop services that write to the directory first (e.g., syslog):
      sudo systemctl stop rsyslog
      
    2. Copy all files to the new volume (preserve permissions and structure):
      sudo rsync -av /var/log/ /mnt/extra-storage/log/
      
    3. Backup the original directory:
      sudo mv /var/log /var/log.bak
      
    4. Create a new empty directory as the new mount point:
      sudo mkdir /var/log
      
    5. Update your /etc/fstab file to mount the new volume directly to /var/log instead of /mnt/extra-storage.
    6. Mount the volume:
      sudo mount -a
      
    7. Restart the stopped service:
      sudo systemctl start rsyslog
      
    8. Once you confirm everything works, you can delete the backup:
      sudo rm -rf /var/log.bak
      

内容的提问来源于stack exchange,提问作者steve

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 08:15:49