Linux sda1 extend issue

Discussion in 'Installation/Configuration' started by tashman89, Jan 3, 2022.

  1. tashman89

    tashman89 Member

    Hello Dears,

    Please I need your support.
    I have an issue with extending the file system
    1- I have VM on vSphere and I want to extend the / file system first this I have increased the HDD from VM setting from 80 to 130
    after rebooting the server I have found the new storage but unfortunately, I didn't complete the expansion process the structure of the file system is standard and there is an issue
    upload_2022-1-3_12-53-54.png
    upload_2022-1-3_12-55-21.png

    I have tried many ways but no luck the last thing I have used gparted but as you can see I could update the / file system

    upload_2022-1-3_12-59-59.png

    upload_2022-1-3_13-0-36.png

    so What I have to do to move the unlocated space to the first file system sdb1

    BR
     

    Attached Files:

  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Disk space for a partition must be contiguous, so you can not add that since the sdb5 partition is in the middle.
    You do not say why or how the resize fails. Please show error messages or write what exactly you do and how it fails.
    Some file systems can not be resized, or can only grow and not made smaller. Check documentation for what fs you have.
    Are you running gparted from a system booted from cd or USB stick? The root partition can not be mounted when you resize or move it.
    Check the docs for gparted, I think it can move a partition, so you could move the sdb5 to the end of disk. Then the unallocated space is in the middle and you can grow sdb1.
     
  3. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    It appears you both increased sda by 50GB as well as have a 50GB sdb (a second disk) in the cli screen shot, and then the same sdb is 130GB in your gparted screenshots (I assume you are changing the device size in between screen shots?); you also highlighted the sda1 filesystem in yellow, making me think that is the "first file system" you refer to which you want to increase? Or maybe you mean the first partition on that disk, ie. sdb1. It's not clear to me exactly what you're trying to do; and once you can explain clearly what you are trying to do, you'll be pretty close to done (ie. the actual changes are pretty straightforward once you understand what's going on).

    Some comments:
    Note that if you move a partition like this, you want to ensure the data itself is moved to the new location; I don't know if gparted does that offhand, or if it only rewrites partition tables; if it doesn't, you'll need to take care of that (eg. copy data to the other disk temporarily, rework the partitions as needed, then copy your data back).

    You may need to boot off another media other than your normal system disk, as @Taleman alluded to.

    Keep in mind you can utilize additional space as a mount point, so eg. if your goal were to have more space on the root filesystem (sda1 partition), you could repartition things and move data around to get that done, or you could simply create a new partition from the unallocated space and mount that as /var. (That has an interim step of mounting the new partition somewhere else and moving all files/directories from the old /var to the new partition, then remounting the new partition as /var - and don't forget changing /etc/fstab to mount it at boot time.)
     
  4. tashman89

    tashman89 Member

    Thanks, Taleman & Jesse for your reply, and kindly find below screenshots to explain what I have and please advise what I have to do to extend /dev/sda1

    upload_2022-1-4_23-58-10.png
    upload_2022-1-4_23-58-17.png

    m upload_2022-1-4_23-58-28.png

    upload_2022-1-4_23-58-40.png

    upload_2022-1-5_0-0-45.png
     
  5. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    As sda2 starts almost immediately after sda1, to extend sda1 you will have to move sda2/sda5 (sda5 is a logical partition created from the extended partition sda2 - they both have the same start/end sectors) to the end of the disk (including copying the data), then you can make sda1 larger (and after increasing the partition size, you'll need to increase the filesystem size).

    Start with ensuring you have a good backup. The task is quite doable, but sometimes we all make mistakes.
     
  6. tashman89

    tashman89 Member

    Thanks Jesse,
    Could you please advise if can share with me the commands or I have to use gparted .

    BR
     
  7. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    You could try Internet Search Engines with
    Code:
    site:youtube.com gparted resize
    Or use same search engines creatively to find instructions on commands for resizing disk partitions.
    Remember: take the backup first! Disk image backup and files backup.
     
  8. tashman89

    tashman89 Member

    Thank you all dears I appreciate your cooperation, I have one issue "How can I move the unallocated space to /dev/sda1 I have tried many times using GParted but no luck "

    upload_2022-1-6_11-19-10.png
     
  9. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    you can't, it's at the end of the drive. you can only extend a partition into unallocated space directly after itself.

    you could try changing the start / end points of sda2/5, so that it uses the end of the disk. it seems to be fraught with all sorts of potential points of data loss though.

    personally, i would just add another virtual drive to the vps in vsphere, configure that as ext4, mount it, then rsync everything from /dev/sda5 to it, unmount /dev/sda5 and then remount the new partition to wherever /dev/sda5 was mounted.
    you can then remove /dev/sda5 and /dev sda2 from the original drive, then everything after /dev/sda1 is unallocated you can then extend /dev/sda1 to use as much (of all) of the drive as you want. then just leave it all running like that.

    if you don't want to leave the extra drive there, just extend /dev/sda1 by the original 50Gb you're attempting to, then recreate the /dev/sda2 /dev/sda5 lvm/pvm at the new end point of /dev/sda1, and rsync everything back from the new extra disk and remount in a reverse of the original process. then remove the extra virtual disk.
     
  10. tashman89

    tashman89 Member

    Hello nhybgtvfr ,
    Thanks for your reply and sorry for being late.
    could you please advise or explain more about adding virtual drive did you mean CD-ROM or a new HDD.

    BR
     
  11. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    well, how did you add, or increase the size of the current disk?
    i assume you have some quite large disks on the vsphere server, or attached storage.
    you created virtual disks in vsphere, and attach those disks to your vps's, as /dev/sda or /dev/sdb
    just do the same again, create an additional virtual disk in vsphere, and attach that as another drive to your existing vps.
    then create a new partition on that drive in that vps, format and mount it.
     

Share This Page