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(replaceXwith your disk's identifier, e.g.,sdb). Verify it's unmounted withlsblkordf -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/sdXand 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:
- Launch the parted interactive tool:
sudo parted /dev/sdX - List current partitions to confirm details:
print - 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.
- First resize the extended partition:
- Resize your target data partition:
resizepart <data-partition-number>(e.g.,resizepart 5), again hitting Enter to use full capacity. - Exit parted:
quit - Expand the file system to fill the new partition size (for ext3/ext4):
sudo resize2fs /dev/sdXn(replacenwith 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):
- Back up your partition table first:
sudo sfdisk -d /dev/sdX > partition_backup.txt - Launch fdisk:
sudo fdisk /dev/sdX - Print partitions and note the starting sector of your target partition:
p - Delete the old partition:
dfollowed by the partition number - 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. - Save the new partition table:
w - Expand the file system:
sudo resize2fs /dev/sdXn
Option 3: Use gParted (Graphical, No Command Line Fuss)
If you prefer a visual interface:
- Install gParted (if not already present):
sudo apt-get install gparted - Launch it:
sudo gparted - Select your target disk from the dropdown in the top-right corner (e.g.,
/dev/sdb) - Right-click the partition you want to resize, choose Resize/Move
- Drag the right-hand slider all the way to the end to use full disk space, then click Resize
- Click the green checkmark in the toolbar to apply the changes
- 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
fdiskand usegdiskinstead—steps are nearly identical, but usesudo sgdisk -b backup.gpt /dev/sdXto back up the partition table, and follow the same delete/recreate workflow (keep the starting sector identical). - Post-Resize Verification: After finishing, run
df -hto check the file system size, andfdisk -l /dev/sdXto 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
- For
- If the file system gets corrupted, unmount the disk and run
sudo e2fsck -f /dev/sdXnto repair it before trying to resize again.
内容的提问来源于stack exchange,提问作者aPugLife
相关产品推荐
相关产品推荐

