Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Accidently lost /home during resizing process

  1. #1
    Join Date
    Apr 2021
    Beans
    5

    Exclamation Accidently lost /home during resizing process

    I tried to decrease size of my /home in order to increase my root / which is too small. I tried to achieve this by following this walkthrough. Unfortunately, I wasn't aware of the differences between standard partitions (which I use) and the logical volume management (LVM) which the walkthrough is based on...at least that's what I suppose.

    In brief what I did:

    1. Login as root
    2. Unmount my /home via

    Code:
    umount /home
    3.Shrink my /home partition from 436G by 10G to 426G
    Code:
    e2fsck -f /dev/my_home
    resize2fs /dev/my_home 426G
    4. Try to reduce /home to 426G
    Code:
     lvreduce -L 426G /dev/my_home
    Here I get the error that the location /dev/my_home does not exists. Indeed, checking via

    Code:
    df -h
    does not show my /home anymore.

    I'm pretty much stuck here and have the strong fear that I have somehow destroyed my /home partition with the resize2fs command. I'm still actively in the session, since I don't dare to reboot. Help is very much appreciated!

    System: Ubuntu 20.04

  2. #2
    Join Date
    May 2013
    Location
    Galiza
    Beans
    4,010
    Distro
    Ubuntu

    Re: Accidently lost /home during resizing process


  3. #3
    Join Date
    Jun 2010
    Location
    London, England
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Accidently lost /home during resizing process

    Is this a desktop system or a server system? If it is desktop, what do you see when you open the file manager and go to Other Locations>Computer? Do you see a folder called Home? And in that folder is there another folder with the name of your User?

    Or, from the terminal type

    Code:
    pwd
    Do you see?

    /home/your user name
    Regards
    It is a machine. It is more stupid than we are. It will not stop us from doing stupid things.
    Ubuntu user #33,200. Linux user #530,530


  4. #4
    Join Date
    May 2006
    Location
    Switzerland
    Beans
    2,660
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: Accidently lost /home during resizing process

    Quote Originally Posted by niclasrieger View Post
    Code:
     lvreduce -L 426G /dev/my_home
    Here I get the error that the location /dev/my_home does not exists. Indeed, checking via "df -h" ...
    Are you sure you're not misinterpreting the error message?? Since you said above that you were not using LVM ... then there's simply no logical volume that "lvreduce" can reduce in size. And of course "df -h" won't show your home since you unmounted it. Why not check with e.g.
    Code:
    sudo fdisk -l
    Does the partition that "/home" was on get listed there? You can check "/etc/fstab" which partition that was:
    Code:
    cat /etc/fstab

  5. #5
    Join Date
    Apr 2021
    Beans
    5

    Re: Accidently lost /home during resizing process

    @grahammechanical:
    I'm in a terminal as a root with no GUI. The working directory is just
    Code:
    /
    . I see all the standard folders like bin/, boot/, etc/, home/, media/, run/ ..., but when I enter /home it's just empty.

    @scorp123:
    The output of
    Code:
    sudo fdisk -l
    yields a whole bunch of
    • Disk /dev/loop# (where # denotes a number from 0-19; everyone has has a size of about some 100 MB)
    • Disk /dev/nvme0n1: 476,96 GiB

    The last one is subdivided then into
    Device | Boot | Start | End | Sectors | Size | Id | Type

    • /dev/nvme0n1p1 | * | 2046 | 1000214527 | 1000212482 | 477G | 5 | Extended
    • /dev/nvme0n1p5 | 2048 | 31250431 | 31248384 | 14,9G | 82 | Linux swap / Solaris
    • /dev/nvme0n1p6 | 31252480 | 70311935 | 39059456 | 18.6G | 83 | Linux
    • /dev/nvme0n1p7 | 70313984 | 1000214527 | 929900544 | 443,4G | 83 | Linux


    This actually looks alright to me! device *5 is the swap, the size seems correct. Device *6 is the / directory I tried to increase. And device *7 is my /home which I wanted to decrease by 10GB. The sizes shown here are the original ones.
    What bothers me is that the Id of *6 and *7 is the same. Isn#t the idea of IDs that they are different?

    Code:
    cat /etc/fstab
    seems to agree with that (though there seems to be one error?):

    # / was on /dev/nvme0n1p6 during installation
    UUID=REALLY LONG NUMBER | / | ext4 | errors=remount-ro | 0 | 1

    # /home was on /dev/nvme0n1p7 during installation
    UUID=REALLY LONG NUMBER | /home | ext4 | defaults | 0 | 2

    and similar for my swap.


    PS: Sorry for the bad format, but since I cannot access internet from my problematic machine, I use another one and copy/paste the output is thus not possible.

  6. #6
    Join Date
    Jun 2006
    Location
    UK
    Beans
    Hidden!
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: Accidently lost /home during resizing process

    A few comments:

    Quote Originally Posted by niclasrieger View Post
    3.Shrink my /home partition from 436G by 10G to 426G
    Code:
    e2fsck -f /dev/my_home
    resize2fs /dev/my_home 426G
    4. Try to reduce /home to 426G
    Code:
     lvreduce -L 426G /dev/my_home
    Quote Originally Posted by niclasrieger View Post
    • /dev/nvme0n1p1 | * | 2046 | 1000214527 | 1000212482 | 477G | 5 | Extended
    • /dev/nvme0n1p5 | 2048 | 31250431 | 31248384 | 14,9G | 82 | Linux swap / Solaris
    • /dev/nvme0n1p6 | 31252480 | 70311935 | 39059456 | 18.6G | 83 | Linux
    • /dev/nvme0n1p7 | 70313984 | 1000214527 | 929900544 | 443,4G | 83 | Linux


    This actually looks alright to me! device *5 is the swap, the size seems correct. Device *6 is the / directory I tried to increase. And device *7 is my /home which I wanted to decrease by 10GB. The sizes shown here are the original ones.
    The sizes shown would be the originals. Your resize2fs command merely shrunk the filesystem, not the actual partition. They are different things - you have a filesystem within a partition.

    Quote Originally Posted by niclasrieger View Post
    What bothers me is that the Id of *6 and *7 is the same. Isn#t the idea of IDs that they are different?
    The id column in fdisk output refers to partition type, here type = 83, a Linux partition. Both your root and home partitions are type 83.

    And I think you may have missed this important point from scorp123:

    Quote Originally Posted by scorp123 View Post
    And of course "df -h" won't show your home since you unmounted it.
    Your home hasn't disappeared - you've simply unmounted it and not remounted it. My guess is that you probably have an undamaged system, with the exception of a slightly undersized filesystem within its partition.

    I don't want to belabour your original mistake, which was to use an inappropriate howto for the job at hand, but the way I would have done this exercise would have been to use gparted from a live session. Time-consuming but easy. No howto needed. I'm not sure whether gparted would do the job now with the reduced filesystem within nvme0n1p7 - perhaps others might want to comment - but I'll make one last and very important point:

    Before manipulating partitions, always, always, always make sure you have adequate backups of any data. Do you? Partition and/or filesystem resizing always carries the risk of something going wrong with catastrophic data loss.
    Last edited by coffeecat; 2 Weeks Ago at 10:12 AM.
    Ubuntu 18.04 Desktop Guide - Ubuntu 20.04 Desktop Guide - Forum Guide to BBCode - Using BBCode code tags - IRC #ubuntuforums

    Member: Not Canonical Team

    If you need help with your forum account, such as SSO login issues, username changes, etc, the correct place to contact an admin is here. Please do not PM me about these matters unless you have been asked to - unsolicited PMs concerning forum accounts will be ignored.

  7. #7
    Join Date
    Apr 2021
    Beans
    5

    Re: Accidently lost /home during resizing process

    Thanks coffecat! At this point I would be also very glad to just go back to the original state, that is, redoing resize2fs. Form what I read resize2fs /dev/my_home should just add the freed space back to the filesystem. Would you think that'd work?

    What would happen if I reboot the computer at that point? Is there a risk of additional data loss?

    I have made a backup of my home so worst case scenario of replaying everything would not be that catastrophic. However, recreating my setup from scratch would still be quite time consuming so it wouldn't be my preferred solution.

  8. #8
    Join Date
    Jun 2006
    Location
    UK
    Beans
    Hidden!
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: Accidently lost /home during resizing process

    I suggest you attempt to remount home first. Assuming your /etc/fstab is OK - what you've managed to post of it looks OK - simply do:

    Code:
    sudo mount -a
    And then test home.

    I said "time-consuming" when referring to using gparted. On reflection, probably not. I was thinking of times I've used it in the past with spinning disks and doing major resizes. You're using a SSD disk. What you want to do should be quite quick. You could use resize2fs to restore the filesystem to its original size, but why not start up a live system and see what gparted can do for you? Don't mount any of the partitions that you want to manipulate. You could then finish the job you've started. Shrink the nvme0n1p7 partition and then enlarge the nvme0n1p6 partition, and gparted would grow the filesystem in nvme0n1p6 to match.

    Growing nvme0n1p6 would, of course, have a potential risk for data on your root partition, which includes configurations for your system, so that's something you need to balance against your desire not to set up from scratch.
    Ubuntu 18.04 Desktop Guide - Ubuntu 20.04 Desktop Guide - Forum Guide to BBCode - Using BBCode code tags - IRC #ubuntuforums

    Member: Not Canonical Team

    If you need help with your forum account, such as SSO login issues, username changes, etc, the correct place to contact an admin is here. Please do not PM me about these matters unless you have been asked to - unsolicited PMs concerning forum accounts will be ignored.

  9. #9
    Join Date
    Oct 2005
    Location
    Lab, Slovakia
    Beans
    10,328

    Re: Accidently lost /home during resizing process

    The most important question is: Do you have a backup of your data?
    If yes, then you can simply reinstall, which takes about 20 minutes.
    If no, then I would boot from install media, mount /home and backup the data, then reinstall.
    Fixing a problem like this without destroying the data in the process is possible, but far more hassle than reinstalling, which will also give you a nice new up to date system.
    As you have found, playing with partitions is an almost sure fire way to mess up a system - not recommended in the best of times.
    Last edited by HermanAB; 2 Weeks Ago at 11:23 AM.

  10. #10
    Join Date
    Apr 2021
    Beans
    5

    Re: Accidently lost /home during resizing process

    Phew, thanks for pointing that out. I indeed could just mount the disk and from what I see the resize2fs command correctly shrinked the filesystem /home. It now has 419G of which 380 is used. I can enter /home/my_user/ and accessing my data seems to work as well. As to whether I corrupted data or not with my actions I unfortunately don't know.

    So if I understand you correctly, you suggest that I start a live system now and continue the work with gparted. Some questions that I'm sure you can quickly answer:
    • do I also have to unmount / if I want to increase this filesystem? or is unmounting /home enough?
    • do I have to unmount before going in live session or can this be done from within the live session?

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •