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

Ubuntu 14.04环境下无需删除分区在线调整非根分区大小咨询

Hey there, let's walk through how to safely resize your backup disk on Ubuntu 14.04 while the system is up and running—since you already know your way around partitioning tools and can easily unmount the disk, this should be smooth sailing with a few key checks and targeted steps.

First, Critical Pre-Checks

Before diving in, make sure you've covered these bases:

  • Fully unmount the disk: Run umount /dev/sdX (replace X with your disk's identifier, e.g., sdb). Verify it's unmounted with lsblk or df -h—you shouldn't see the disk listed in mounted volumes.
  • Double-check ESXi disk size: Confirm the ESXi host has already applied the full disk expansion. Run fdisk -l /dev/sdX and verify the total disk capacity matches what you set in ESXi.
  • Backup the backup (yes, really): Even though it's a backup disk, partition operations carry small risks. Quickly copy critical data to another location or take an ESXi snapshot of the VM (note: since it's an independent persistent disk, snapshots won't capture it—so stick to file-level backups here).

Option 1: Use parted (Works for GPT or MBR Partitions)

This is my go-to for flexible partition resizing:

  1. Launch the parted interactive tool: sudo parted /dev/sdX
  2. List current partitions to confirm details: print
  3. If you're resizing a logical partition inside an MBR extended partition:
    • First resize the extended partition: resizepart <extended-partition-number> (e.g., resizepart 1). When prompted for the end position, just hit Enter to use the maximum available space.
  4. Resize your target data partition: resizepart <data-partition-number> (e.g., resizepart 5), again hitting Enter to use full capacity.
  5. Exit parted: quit
  6. Expand the file system to fill the new partition size (for ext3/ext4): sudo resize2fs /dev/sdXn (replace n with your partition number, e.g., sdb1)

Option 2: Use fdisk (MBR Partitions Only)

If you prefer fdisk, follow these steps (don't mess up the starting sector—this is critical):

  1. Back up your partition table first: sudo sfdisk -d /dev/sdX > partition_backup.txt
  2. Launch fdisk: sudo fdisk /dev/sdX
  3. Print partitions and note the starting sector of your target partition: p
  4. Delete the old partition: d followed by the partition number
  5. Create a new partition: n, select the same partition type (primary/logical), enter the exact starting sector you noted earlier, and hit Enter for the end sector to use max space.
  6. Save the new partition table: w
  7. Expand the file system: sudo resize2fs /dev/sdXn

Option 3: Use gParted (Graphical, No Command Line Fuss)

If you prefer a visual interface:

  1. Install gParted (if not already present): sudo apt-get install gparted
  2. Launch it: sudo gparted
  3. Select your target disk from the dropdown in the top-right corner (e.g., /dev/sdb)
  4. Right-click the partition you want to resize, choose Resize/Move
  5. Drag the right-hand slider all the way to the end to use full disk space, then click Resize
  6. Click the green checkmark in the toolbar to apply the changes
  7. Once done, remount the disk: sudo mount /dev/sdXn /mnt/your-backup-mountpoint

Key Technical Confirmations & Edge Cases

  • Independent Persistent Disk Behavior: Since your disk is set to "independent persistent" in ESXi, you don't have to worry about snapshot conflicts or hidden disk layers. The OS will see the full expanded capacity immediately after ESXi applies the change.
  • Non-ext File Systems: If your backup disk uses XFS instead of ext3/ext4, you'll need to mount it first, then run sudo xfs_growfs /mnt/your-mountpoint (XFS only supports online expansion).
  • GPT Partitions: If your disk uses GPT, skip fdisk and use gdisk instead—steps are nearly identical, but use sudo sgdisk -b backup.gpt /dev/sdX to back up the partition table, and follow the same delete/recreate workflow (keep the starting sector identical).
  • Post-Resize Verification: After finishing, run df -h to check the file system size, and fdisk -l /dev/sdX to confirm the partition matches the disk's total capacity.

Emergency Rollback Plan

  • If you mess up the partition table, restore from your backup:
    • For fdisk: sudo sfdisk /dev/sdX < partition_backup.txt
    • For gdisk: sudo sgdisk -l backup.gpt /dev/sdX
  • If the file system gets corrupted, unmount the disk and run sudo e2fsck -f /dev/sdXn to repair it before trying to resize again.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 08:33:43