Cách 1: Tắt máy chủ, khởi động lại server
You do not need a live CD for this to work. I’m basically summarizing the other answers given here:
- From Ubuntu (in VM) install gparted by executing sudo apt-get install gpartedin terminal
- Open sudo gpartedfrom terminal
- Rightclick on the swap partition, click “swapoff”
- Delete swap partition
- Extend your data partition, but leave enough space to create a new swap partition
- Recreate swap partition with about the same size as before, select linux-swap as file system
- Click that green tick in gparted to apply all operations. Then select “swapon” to enable swap again
Cách 2: Tóm lược
Sử dụng command line, không cần phải reboot lại server.
You should first delete all partitions between your partition and free space. You can do it using
parted command.
1/ Turn off swap. we gonna remove it’s partition!
sudo swapoff -a
2/ run
sudo parted.
3/ get partitions list with
print all:(parted) print allModel: Virtio Block Device (virtblk)Disk /dev/vda: 752GBSector size (logical/physical): 512B/512BPartition Table: msdosDisk Flags:Number Start End Size Type File system Flags1 1049kB 528GB 528GB primary ext4 boot2 528GB 537GB 8588MB extended5 528GB 537GB 8588MB logical linux-swap(v1)
4/ remove none root partitions with
rm (part-index):(parted) rm 5Warning: Partition /dev/vda5 is being used. Are you sure you want to continue?Yes/No? yesError: Partition(s) 5 on /dev/vda have been written, but we have been unable toinform the kernel of the change, probably because it/they are in use. As aresult, the old partition(s) will remain in use. You should reboot now beforemaking further changes.Ignore/Cancel? C(parted) print allModel: Virtio Block Device (virtblk)Disk /dev/vda: 752GBSector size (logical/physical): 512B/512BPartition Table: msdosDisk Flags:Number Start End Size Type File system Flags1 1049kB 528GB 528GB primary ext4 boot2 528GB 537GB 8588MB extended(parted) rm 2Error: Partition(s) 5 on /dev/vda have been written, but we have been unable toinform the kernel of the change, probably because it/they are in use. As aresult, the old partition(s) will remain in use. You should reboot now beforemaking further changes.Ignore/Cancel? C(parted) print allModel: Virtio Block Device (virtblk)Disk /dev/vda: 752GBSector size (logical/physical): 512B/512BPartition Table: msdosDisk Flags:Number Start End Size Type File system Flags1 1049kB 528GB 528GB primary ext4 boot
The commands works on ubuntu 16.04 (NONE LVM) and machine is running a kvm:
sudo growpart /dev/vda 1sudo resize2fs /dev/vda1
growpart and resize2fs are e.g. available via sudo apt-get install cloud-guest-utils
=====================================
Chi tiết:
1/ Kiểm tra dung lượng ổ địa hiện tại
Sử dụng lệnh
df -hT:
Dùng lệnh
fdisk -l: dung lượng ổ /dev/sda: 200 GiB
2/ Tăng thêm 100GB qua Vcenter:
3/ Quét lại ổ đĩa:
– Kiểm tra các ổ địa hiện tại bằng lệnh
ls /sys/class/scsi_device/
– Scan lại các ổ bằng lệnh:
echo 1 > /sys/class/scsi_device/2\:0\:0\:0/device/rescanecho 1 > /sys/class/scsi_device/32\:0\:0\:0/device/rescan
4/ Kiểm tra xem hệ thống đã nhận thêm 100GB nữa chưa bằng lệnh
fdisk -l:
Giờ đây
/dev/sda: 300 GiB
5/ Sử dụng 2 lệnh dưới đây để mở rộng ổ
/dev/sda2growpart /dev/sda 2resize2fs /dev/sda2
6/ Kiểm tra lại
– Sử dụng
fdisk -l:
– và
df -hT:







No comments:
Post a Comment