LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Expand Ubuntu Filesystem on Hyper-V not going through (https://www.linuxquestions.org/questions/linux-server-73/expand-ubuntu-filesystem-on-hyper-v-not-going-through-4175732065/)

eliassal 12-22-2023 10:29 AM

Expand Ubuntu Filesystem on Hyper-V not going through
 
can you please help in letting me know the steps needed to increase the size of ubuntu hard drive. It is VM, I increased the disk in hyper-V by 11G. Inside the VM, when I run PARTED Print I see

Code:

~# parted GNU Parted 3.4 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) print
Model: Msft Virtual Disk (scsi) Disk /dev/sda: 65,5GB Sector size (logical/physical): 512B/4096B Partition Table: msdos Disk Flags:

Number  Start  End    Size    Type      File system    Flags
 1      1049kB  52,7GB  52,7GB  primary  ext4            boot
 2      52,7GB  53,7GB  1022MB  extended
 5      52,7GB  53,7GB  1022MB  logical  linux-swap(v1)
 **3      53,7GB  65,5GB  11,8GB  primary  ext4**

I followed some instructions in some articles here but was not successful. I tried the GUI but cant extend the volume. What is strange, in all articles, they mention that I need the name of the group of disks which is not the case Doing
Code:

fdisk -l
it shows

Code:

Disk /dev/sda: 61 GiB, 65498251264 bytes, 127926272 sectors
Disk model: Virtual Disk   
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x0ea54806

Device    Boot    Start      End  Sectors  Size Id Type
/dev/sda1  *        2048 102856703 102854656  49G 83 Linux
/dev/sda2      102858750 104855551  1996802  975M  5 Extended
**/dev/sda3      104855552 127926271  23070720  11G 83 Linux**
/dev/sda5      102858752 104855551  1996800  975M 82 Linux swap / Solaris

Code:

Partition 2 does not start on physical sector boundary.
Partition table entries are not in disk order.

I tried growpart /dev/sda 1 I get

Quote:

NOCHANGE: partition 1 could only be grown by 2046 [fudge=2048]

yancek 12-22-2023 11:05 AM

If you look at your fdisk output and subtract the end sector of sda1 from the start sector of sda2, you get the result shown at the bottom of your post. sda3 is another primary partition but it is not contiguous to sda1 so you cannot expand it but can use it as a separate data partition. You are using a dos partition table which has an Extended partition and a swap within it. Maybe reinstall and use gpt.

You could delete the swap and then the Extended partition and move sda3 to the left. If you haven't done this type thing very much you should just reinstall and prepare the partitions the way you want.

michaelk 12-22-2023 12:46 PM

I assume you created /dev/sda3 with added space since it is 11GB. If so delete /dev/sda3, turn off swap and delete /dev/sda5 and /dev/sda2. It is possible using parted and resize2fs to expand /dev/sda1 while active but make sure you do have anything important backed up just in case. Create a new swap partition, format, update /etc/fstab with its new UUID and turn it back on. You do not need to recreate an extended partition.

syg00 12-22-2023 08:22 PM

And if you are planning on doing this again, you don't need the swap partition - it will just get in the way again. After the increase in size, simply allocate a swap file and add that to fstab. Will make life easier in future.

eliassal 12-23-2023 09:18 AM

Thanks to yancek michaelk and syg00

As this is thest time I do thiis, can you please help on

- If so delete /dev/sda3 HOW?
- turn off swap : swap is already off as it was one of the prerequisites to install Kubernetes
- delete /dev/sda5 and /dev/sda2, again HOW?

If possible please share the instructions in the form of commandline arguments so I dont do any mistake
Yes I have a backup of the VM

jmgibson1981 12-23-2023 11:16 AM

If I may you should rebuild the virtual machine using LVM instead of fixed partitions. Makes life a ton easier if you ever have any inkling you will be changing or wanting to change partition structures. Well worth the small time investment to change it over.

michaelk 12-23-2023 11:26 AM

To delete partitions you can use any partitioning utility i.e. fdisk, parted etc.
https://www.gnu.org/software/parted/manual/parted.html
https://www.tecmint.com/fdisk-comman...sk-partitions/


All times are GMT -5. The time now is 04:36 PM.