0

I do not have an IT background. I am working things out on my own, so I would really appreciate your help on this as I am in a panic at the moment.

I wanted to increase the size of my /home directory (as a normal user). I followed the steps provided below by Ari: How to shrink /home and add more space on CentOS7

However, after following the steps (except that I saved the backup in the /root (as superuser), I could no longer login back to my account.

When I used the GUI to login, my password was accepted by the system. But then the screen turns blank and then I am sent back to the login screen. When I checked /etc/passwd, I could see my account name and home directory as /home/myname.

Can I still recover my account? I have very important files and software. What should I do?

The following is the original post by Ari:

As others have pointed out, XFS filesystem cannot be shrunk.

So your best bet is to backup /home, remove and recreate its volume in a smaller size and give the rest to your /root volume just as Koen van der Rijt outlined in his post.

• backup the contents of /home

tar -czvf /root/home.tgz -C /home . • test the backup

tar -tvf /root/home.tgz • unmount home

umount /dev/mapper/centos-home • remove the home logical volume

lvremove /dev/mapper/centos-home • recreate a new 400GB logical volume for /home, format and mount it

lvcreate -L 400GB -n home centos mkfs.xfs /dev/centos/home mount /dev/mapper/centos-home • extend your /root volume with ALL of the remaining space and resize (-r) the file system while doing so

lvextend -r -l +100%FREE /dev/mapper/centos-root • restore your backup

tar -xzvf /root/home.tgz -C /home • check /etc/fstab for any mapping of /home volume. IF it is using UUID you should update the UUID portion. (Since we created a new volume, UUID has changed)


newaminal
  • 1
  • 1
  • You were able to execute the lv commands "as a normal user" ? – Gerard H. Pille Nov 02 '20 at 10:14
  • I changed to su before performing the lv commands. When I did: tar -tvf /root/home.tgz, I could still see the files, but when changed to `su`, I could see the home.tgz backup file but I could not login back to my original user account. – newaminal Nov 02 '20 at 10:18
  • I'm checking the post by Ari. Can you come up with the exact commands you executed? – Gerard H. Pille Nov 02 '20 at 11:01
  • Does lvs show you the new /home ? "Can I still recover my account?" As long as you keep the tar. – Gerard H. Pille Nov 02 '20 at 11:09
  • Thanks. Apparently, I can't get the terminal history in the user account because I cannot login anymore. The tar file looks very small in size. – newaminal Nov 02 '20 at 11:42
  • Perhaps you skipped a couple of points, like eg. "tar -tvf /root/home.tgz" ? – Gerard H. Pille Nov 02 '20 at 13:04
  • The commands you executed should be in root's history, no? – Gerard H. Pille Nov 02 '20 at 13:05
  • I did not skip "tar -tvf /root/home.tgz" I did the "tar -czvf /root/home.tgz -C /home . " in the local user, not the root Does this make the problem? – newaminal Nov 02 '20 at 13:34
  • 1
    I find it hard to believe "tar -czvf /root/home.tgz -C /home . " can be executed (without error) by a normal user, because a normal user should not be able to create a file in /root. So, when you did the "tar -tvf", what did you get? – Gerard H. Pille Nov 02 '20 at 14:01
  • As a general advice: Don't follow *any* instructions without understanding what they do! I've seem several "solutions" to problems that were simply wrong or needlessly complicated. Specifically some people copy instructions fro mother people without seemingly understanding what those do. So you can find the same instructions multiple times, but still the are not correct! – U. Windl Sep 01 '23 at 07:14

1 Answers1

0

Your best option is to recover /home from a backup, I'm sure you'll have one since /home contains "very important files and software".

Gerard H. Pille
  • 2,569
  • 1
  • 13
  • 11
  • Thank you @Gerard. I just created a new user and recovered my files from the new /home of the new user account. – newaminal Nov 02 '20 at 14:33
  • How can your files be in the home of a new user? A new user has no files at all? – Gerard H. Pille Nov 02 '20 at 15:02
  • What I mean is I created a new user and gave that user administrator privileges, then I just started from scratch. Most of my large files are in another drive, so I could still access them from the new user's home. But I could not find the files saved in the lost user's home--some of them are important. I wonder because when I did an `ls -lht` command, the backup showed only 20 (without a unit. Does that mean 20kb? It's rather small considering the size of my lost user's /home directory. – newaminal Nov 02 '20 at 23:55
  • "ls" doesn't go into subdirectories if you don't say it should. So, what was in the tar file? – Gerard H. Pille Nov 03 '20 at 00:09
  • The backup of my "lost" user's /home should be in the tar file as expected, after following Ari's post? – newaminal Nov 03 '20 at 00:56
  • Yes, but I'm not asking what should be in it. I'd like to know what it does contain. – Gerard H. Pille Nov 03 '20 at 03:09
  • It has some of my important files like notes in doing many bioinformatics codes. – newaminal Nov 03 '20 at 07:51
  • OK, so be it. I don't understand how you could create that tar as a normal user. Or did the old user also have "administrator privileges"? That term is from Windows, not Linux. – Gerard H. Pille Nov 03 '20 at 08:08
  • Yes, the old user also had administrator (sudo) privileges. – newaminal Nov 03 '20 at 08:45
  • You could have mentioned the sudo a bit earlier. In that case you must have skipped the "tar -xzvf /root/home.tgz -C /home". That's the command that would have restored the old user. It should still work. – Gerard H. Pille Nov 03 '20 at 09:55
  • Thank you, Gerard. I did the `tar -xzvf /root/home.tgz -C /home .` using the sudo privilege. But I could not login to the account after recovery. I think there are some links missing. I am a bit frustrated with this. I may just have to give up the files there. I appreciate your kind time, though! – newaminal Nov 03 '20 at 10:31
  • Each morning, you should repeat fifty times before the mirror: "Today I will make not typos when logged in as root". Do you notice the difference between "tar -xzvf /root/home.tgz -C /home ." (newanimal, sorry, newaminal version) and "tar -xzvf /root/home.tgz -C /home" (Ari version), or is your eyesight as bad as mine? – Gerard H. Pille Nov 03 '20 at 12:10
  • Thanks. I would definitely learn from each mistake. Sometimes they come with a price, though. Appreciate your time, Gerard~ – newaminal Nov 04 '20 at 02:56