You are not logged in.

#1 2024-08-06 03:59:33

geopardo
Member
From: Europe
Registered: 2021-03-23
Posts: 169

restore home directory

Hi everyone
I have a problem, after an update it appeared this error

failed to start file system check on /dev/disk/by-uuid

I follow this topic and solve the problem
https://bbs.archlinux.org/viewtopic.php?id=223633

Later when I login in the system another problem appears, I can't find the home folder anymore, Linux look for the Xauthority file but it's not there for my user.

I partially solved the problem by creating another user, and I enter correctly im the system ...
but the hard disk remains full and the home folder of the unreachable user takes up space.

I used command 

fsck -f /dev/sdx

and I had see when it run/repair more directory, like /???/Desktop/file.mp3 for example.
I see these question marks instead of the home folder name of the user who lost access.

How can I rebuild the home directory for the user in question?

Greetings

PS
It would be nice just to recover some mp3s and delete the entire folder and the user who no longer has access.

I say this because the situation is really difficult.

Last edited by geopardo (2024-08-06 04:03:46)


Some 'security people are f*cking morons' says Linus Torvalds..

Offline

#2 2024-08-06 09:27:03

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,311

Re: restore home directory

The directory node got likely corrupted and restored w/ some bogus name

printf '%s\n' /home/* | od -t x1 -a

will print the contents of /home in hex values

Online

#3 2024-08-06 10:32:02

geopardo
Member
From: Europe
Registered: 2021-03-23
Posts: 169

Re: restore home directory

In one attempt I had created a new /home for the user.
using mkdir but to no avail, as I couldn't move any files..

should I remove /home/greenman?

The right step is to rename the corrupt directory, right?

[root@greenhub sandro]# printf '%s\n' /home/* | od -t x1 -a
0000000  2f  68  6f  6d  65  2f  67  72  65  65  6e  6d  61  6e  0a  2f
          /   h   o   m   e   /   g   r   e   e   n   m   a   n  nl   /
0000020  68  6f  6d  65  2f  6c  6f  73  74  2b  66  6f  75  6e  64  0a
          h   o   m   e   /   l   o   s   t   +   f   o   u   n   d  nl
0000040  2f  68  6f  6d  65  2f  73  61  6e  64  72  6f  0a
          /   h   o   m   e   /   s   a   n   d   r   o  nl
0000055
[root@greenhub sandro]# ls -la /home
totale 228
drwxr-xr-x    5 root   root     4096  4 ago 07.05 .
drwxr-xr-x   18 root   root     4096  4 ago 12.36 ..
drwxr-xr-x    2 root   root     4096  4 ago 08.33 greenman
drwx------ 1194 root   root   217088 18 dic  2023 lost+found
drwx------   18 sandro sandro   4096  5 ago 22.54 sandro

Some 'security people are f*cking morons' says Linus Torvalds..

Offline

#4 2024-08-06 14:39:16

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,311

Re: restore home directory

So there're /home/greenman and /home/sandro - I assume the latter is your regular $HOME?
Not sure whether there's anything "corrupt" but before we know what's up I'd not write the FS at all.
When you log in on a console (the fat DEs hate if there's any issue w/ your $HOME) as sandro, can you

echo $HOME
pwd
ls -l

and access your files?

Online

#5 2024-08-07 00:00:07

geopardo
Member
From: Europe
Registered: 2021-03-23
Posts: 169

Re: restore home directory

I can access to all whit /home/sandro but not the contents of old /home/greenman.
I can access an empty /home/greenman, here there are two file copied from /home/sandro, xinitric and Xauthority
In fact I used mkdir to recreate the /home/greenman, before using a specific file recovery program.

I've tried several, without success.


Some 'security people are f*cking morons' says Linus Torvalds..

Offline

#6 2024-08-07 07:29:29

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,311

Re: restore home directory

The ownership and permissions of /home/greenman are off - should be greenman:greenman/700

findmnt -T /home
findmnt -T /home/greenman
sudo ls -a /home/greenman

Online

#7 2024-08-07 13:38:50

GerBra
Forum Fellow
From: Bingen/Germany
Registered: 2007-05-10
Posts: 258

Re: restore home directory

After your fschk:

and I had see when it run/repair more directory, like /???/Desktop/file.mp3 for example

Have you ever looked into lost+found directory in /home (and maybe also in /lost+found).
From your: ls -la /home i would bet that most of your missing files are there (maybe with "crypted" directory and/or filename(parts)).


My avatar: "It's not just a toilet... a FERGUSON. The King of bowls. Sit down and give me your best shot." Al Bundy

Offline

#8 2024-08-08 00:49:46

geopardo
Member
From: Europe
Registered: 2021-03-23
Posts: 169

Re: restore home directory

The /home/greenman folder is rebuilt.

I think the right connections are missing to let the user enter the operating system.

sandro@greenhub ~]$ findmnt -T /home/greenman
TARGET SOURCE    FSTYPE OPTIONS
/home  /dev/sdb1 ext4   rw,relatime
[sandro@greenhub ~]$ findmnt -T /home
TARGET SOURCE    FSTYPE OPTIONS
/home  /dev/sdb1 ext4   rw,relatime
[sandro@greenhub ~]$ sudo ls -a /home/greenman
[sudo] password di sandro: 
.  ..  .Xauthoriry  .xinitrc

and

[sandro@greenhub ~]$ fsck /dev/sdb1
fsck da util-linux 2.40.2
e2fsck 1.47.1 (20-May-2024)
/dev/sdb1 is mounted.



ATTENZIONE: il file system è montato. Continuando l'operazione
verranno causati seri danni al file system.


Continuare<n>? no
controllo annullato.

Some 'security people are f*cking morons' says Linus Torvalds..

Offline

#9 2024-08-08 01:05:13

geopardo
Member
From: Europe
Registered: 2021-03-23
Posts: 169

Re: restore home directory

GerBra wrote:

After your fschk:

and I had see when it run/repair more directory, like /???/Desktop/file.mp3 for example

Have you ever looked into lost+found directory in /home (and maybe also in /lost+found).
From your: ls -la /home i would bet that most of your missing files are there (maybe with "crypted" directory and/or filename(parts)).

Not yet, but when I restructured the disk nodes and indexes I saw that all the files were there.
I use this command

fsck -f /dev/sdb1

But then problems occur with Xauthority and Linux couldn't find the /home/greenman directory and it said not found.
Then i used these commands for try access the desktop:

# usermod -d /my/new/home -m username
# ln -s /my/new/home/ /my/old/home

I think I butchered it whit the second, for allow programs to find files that have hardcoded paths.


Some 'security people are f*cking morons' says Linus Torvalds..

Offline

#10 2024-08-08 01:33:52

geopardo
Member
From: Europe
Registered: 2021-03-23
Posts: 169

Re: restore home directory

This is the home directory to restore.. 18 files, like new sandro home..

[root@greenhub sandro]# ls -la /home
totale 228
drwxr-xr-x    5 root   root     4096  4 ago 07.05 .
drwxr-xr-x   18 root   root     4096  4 ago 12.36 ..
drwxr-xr-x    2 root   root     4096  4 ago 08.33 greenman
drwx------ 1194 root   root   217088 18 dic  2023 lost+found
drwx------   18 sandro sandro   4096  5 ago 22.54 sandro

drwxr-xr-x   18 root   root     4096  4 ago 12.36 ..


Some 'security people are f*cking morons' says Linus Torvalds..

Offline

#11 2024-08-08 07:09:35

GerBra
Forum Fellow
From: Bingen/Germany
Registered: 2007-05-10
Posts: 258

Re: restore home directory

First: my English is not very good, so i normally don't write easy here. I stepped in because the lost+found thing.

Situation from your first post: You have had a massive file system problem, so the repair (fsck) nuked /home/greenman completely to get the filesystem back intact. The remaining "data" was friendly placed in /home/lost+found.

To get greenman back to work (situation from post#10):
* As root from a TTY, don't have user greenman logged in

chown -R greenman:greenman /home/greenman
chmod 700 /home/greenman
passwd greenman #if needed

Or delete user greenman and it's $HOME once more and recreate the user again with useradd -m
Don't bother with things like .Xautorithy, these will be created when needed after you login the greenman user (either from TYY or DisplayManager.

If you actually need real data files from test user /home/sandro you must copy the files as root from /home/sandro to /home/greenman and make them the correct owner/access-mode.
You could to this always with the chown command from above.

PS
It would be nice just to recover some mp3s and delete the entire folder and the user who no longer has access.

This is maybe the next and work intensive step. As mentioned, i guess most of your "data" was moved to /home/lost+found.
Don't know how familar you are with ext4 fs things, so maybe look at these links:
https://www.baeldung.com/linux/lost-found-directory
And do a search for "ext4 restore from lost+found"
This could be a hard work to identify and check the integrity of files/dirs to "restore" (restore means: copy them from /home/lost+found to /home/greenman). Last time i did this years ago it costs many hours, also for someone ho doesn't had a backup...
You also have no backups? <g>

After you have restored data from /home/lost+found dir you should empty this directory (as root), but only the content, not the directory itself.


My avatar: "It's not just a toilet... a FERGUSON. The King of bowls. Sit down and give me your best shot." Al Bundy

Offline

#12 2024-08-08 07:47:10

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,311

Re: restore home directory

Hold on.

# usermod -d /my/new/home -m username
# ln -s /my/new/home/ /my/old/home

so greenman is a symlink to sandro? (Explains the permissions)

ls -la /home

Before writing the FS, check whether everything you want exists in lost+found.
If you're missing critical data, avoid further writes to the filesystem until you've secured that on some other storage drive.
If your missing important stuff, see whether testdisk or phtorec can recover in doubt at least fragments of the necessary data.

Online

#13 2024-08-08 08:39:42

GerBra
Forum Fellow
From: Bingen/Germany
Registered: 2007-05-10
Posts: 258

Re: restore home directory

Seth wrote:

so greenman is a symlink to sandro? (Explains the permissions)

Don't think so, cause the post #10 ls -la has no indicates for a symlinked $HOME. (-la would show the link dest and dir-flags would be 0777)
But double check is best.

Seth wrote:

Before writing the FS, check whether everything you want exists in lost+found

That's right. Myself would operate from a extern boot system (ex. archlinux install iso) and mount there the partition read-only.
There i have all tools (include my favorite mc (MidnightCommander file manager) to inspect things.
So if i would miss my million-dollar-bitcoin.wallet (and don't have a backup !) i would seek in lost+found. If its not there than your mentioned tools like photorec comes in play.

Last edited by GerBra (2024-08-08 08:51:38)


My avatar: "It's not just a toilet... a FERGUSON. The King of bowls. Sit down and give me your best shot." Al Bundy

Offline

#14 2024-08-10 05:10:42

geopardo
Member
From: Europe
Registered: 2021-03-23
Posts: 169

Re: restore home directory

GerBra wrote:

First: my English is not very good, so i normally don't write easy here. I stepped in because the lost+found thing.

Situation from your first post: You have had a massive file system problem, so the repair (fsck) nuked /home/greenman completely to get the filesystem back intact. The remaining "data" was friendly placed in /home/lost+found.

In fact removed user greenman the problem remains. At this point I need remove lost+found content

[sandro@greenhub ~]$ ls -la /home
totale 224
drwxr-xr-x    4 root   root     4096 10 ago 07.22 .
drwxr-xr-x   18 root   root     4096  4 ago 12.36 .. <----- broken dir in lost-found ?
drwx------ 1194 root   root   217088 18 dic  2023 lost+found
drwx------   18 sandro sandro   4096 10 ago 07.26 sandro

Last edited by geopardo (2024-08-10 05:32:48)


Some 'security people are f*cking morons' says Linus Torvalds..

Offline

#15 2024-08-10 05:19:20

geopardo
Member
From: Europe
Registered: 2021-03-23
Posts: 169

Re: restore home directory

seth wrote:

Hold on.

# usermod -d /my/new/home -m username
# ln -s /my/new/home/ /my/old/home

so greenman is a symlink to sandro? (Explains the permissions)

ls -la /home

Before writing the FS, check whether everything you want exists in lost+found.
If you're missing critical data, avoid further writes to the filesystem until you've secured that on some other storage drive.
If your missing important stuff, see whether testdisk or phtorec can recover in doubt at least fragments of the necessary data.

I think I could recover /home/greenman (which was only well cataloged, I have a backup)

Now I have a backup but I don't have space to put it on the system.

I probably created a mess by renaming /home/greenman. It would have been enough to create a user and observe the /home folder from the desktop.

I created the user sandro at the end to see if I could recover something. But I had already created too much havoc beyond myself, combined with the fsck restore it was chaos.

I have now deleted the user greenman

greenman is not a symlink.

Last edited by geopardo (2024-08-10 05:28:57)


Some 'security people are f*cking morons' says Linus Torvalds..

Offline

#16 2024-08-10 07:13:01

GerBra
Forum Fellow
From: Bingen/Germany
Registered: 2007-05-10
Posts: 258

Re: restore home directory

geopardo wrote:

[sandro@greenhub ~]$ ls -la /home
totale 224
drwxr-xr-x    4 root   root     4096 10 ago 07.22 .
drwxr-xr-x   18 root   root     4096  4 ago 12.36 .. <----- broken dir in lost-found ?
drwx------ 1194 root   root   217088 18 dic  2023 lost+found
drwx------   18 sandro sandro   4096 10 ago 07.26 sandro

broken dir? No, the two dotted entries exists in every directory. They mean: one-dot points to the current dir, two-dots points to the upper dir. You could check/test this for ex. with: cd . and cd ..

geopardo wrote:

I have now deleted the user greenman
...
I think I could recover /home/greenman (which was only well cataloged, I have a backup)
Now I have a backup but I don't have space to put it on the system.

To see where we are at the moment:
So the above list of your /home ist the current state?

User greenman is gone forever, you would continue with user sandro ?

You have a backup from the old greenman data somewhere which you wan't to reuse with your new user (sandro?) ?

You don't need anything anymore from things which the fsck puts in /home/lost+found ?

Please also post (as root):

LANG=C df -h /home
LANG=C du -hs /home/lost+found
LANG=C id sandro

//edit: corrected faulty df -hs to du -hs in code block

Last edited by GerBra (2024-08-10 07:19:43)


My avatar: "It's not just a toilet... a FERGUSON. The King of bowls. Sit down and give me your best shot." Al Bundy

Offline

#17 2024-08-10 09:28:20

geopardo
Member
From: Europe
Registered: 2021-03-23
Posts: 169

Re: restore home directory

exactly I have a disk with the same files that I use as a backup and continue as sandro user

[sandro@greenhub ~]$ su
Password: 
[root@greenhub sandro]# LANG=C df -h /home
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb1       234G  140G   83G  64% /home
[root@greenhub sandro]# LANG=C du -hs /home/lost+found
110G    /home/lost+found
[root@greenhub sandro]# LANG=C id sandro
uid=1002(sandro) gid=1002(sandro) groups=1002(sandro),998(wheel)
[root@greenhub sandro]# 

Some 'security people are f*cking morons' says Linus Torvalds..

Offline

#18 2024-08-10 09:30:43

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,311

Re: restore home directory

110G    /home/lost+found

Seems like your data has been restored there, you can maybe use it to fill the gaps in your backup.

Online

#19 2024-08-10 12:01:42

GerBra
Forum Fellow
From: Bingen/Germany
Registered: 2007-05-10
Posts: 258

Re: restore home directory

geopardo wrote:

I have a disk with the same files that I use as a backup and continue as sandro user

So it's your decision if you are ready to clean up /home/lost+found to get the "occupied" 110G back for normal usage.
Again: your decision
If you will do, best would be (as root):

# cd /home
# rm --one-file-system --recursive --force /home/lost+found/*
# rm --one-file-system --recursive --force /home/lost+found/.*

This will remove everything in /home/lost+found

uid=1002(sandro) gid=1002(sandro) groups=1002(sandro),998(wheel)

Your new user has uid/gid number 1002. As you maybe know, the *names* are not relevant on access rights for files/processes. It's the numeric value.

You should try to remember if you grant your formerly user greenman by it's "name" or uid/gid (which was different as the ones for new sandro) any special rights on your SYSTEM, ex. udev rules, usdisk config or any. If so, you should bring this up to date. (Hint: you could grep in /etc)

Also files in your backup could have other uid/gid owner, so only a "copy" or "restore" from your backup may not give new sandro the needed rights.
This is a question about user management. If you need help on these questions you should ask.

One way could be (before you do many things with sandro): Look in earlier journalctl logs to find the uid/gid from the old greenman user (could be 1000/1000). And then modify the uid for current sandro (and the sandro group) to exact these numeric values. This could make the "restore" process of the greenman-data easier.
//Edit: If you (means: root) will change the current uid/gid values on sandro, don't forget (as root) to do a:

chown -R sandro:sandro /home/sandro

to reflect the new uid/gid values. If you know what you do (and what I mean) it's easy and logical. Or look into the wiki for user management.

On the other hand your root user could later use chown to give sandro:sandro the correct ownership of anything you "restore" to /home/sandro. It's on your hand.

Wish you good luck, and ask if any questions.

Last edited by GerBra (2024-08-10 12:26:49)


My avatar: "It's not just a toilet... a FERGUSON. The King of bowls. Sit down and give me your best shot." Al Bundy

Offline

#20 2024-08-10 14:37:15

geopardo
Member
From: Europe
Registered: 2021-03-23
Posts: 169

Re: restore home directory

Well, I freed up some disk space, but strangely there was something left. The data is saved on another device.


Some 'security people are f*cking morons' says Linus Torvalds..

Offline

#21 2024-08-10 14:39:40

geopardo
Member
From: Europe
Registered: 2021-03-23
Posts: 169

Re: restore home directory

seth wrote:
110G    /home/lost+found

Seems like your data has been restored there, you can maybe use it to fill the gaps in your backup.

[sandro@greenhub ~]$ ls -la /home
totale 224
drwxr-xr-x    4 root   root     4096 10 ago 07.22 .
drwxr-xr-x   18 root   root     4096  4 ago 12.36 .. <----- broken dir remain
drwx------ 1194 root   root   217088 18 dic  2023 lost+found
drwx------   17 sandro sandro   4096 10 ago 07.26 sandro

This directory with the previous file numbering. But is change now, reports 17 not 18..

I'll try a reboot, to see if it goes away completely.

Last edited by geopardo (2024-08-10 14:41:30)


Some 'security people are f*cking morons' says Linus Torvalds..

Offline

#22 2024-08-10 17:16:28

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,311

Re: restore home directory

GerBra wrote:

broken dir? No, the two dotted entries exists in every directory. They mean: one-dot points to the current dir, two-dots points to the upper dir. You could check/test this for ex. with: cd . and cd ..

Online

#23 2024-08-10 21:05:57

geopardo
Member
From: Europe
Registered: 2021-03-23
Posts: 169

Re: restore home directory

seth wrote:
GerBra wrote:

broken dir? No, the two dotted entries exists in every directory. They mean: one-dot points to the current dir, two-dots points to the upper dir. You could check/test this for ex. with: cd . and cd ..


oK well done


Some 'security people are f*cking morons' says Linus Torvalds..

Offline

Board footer

Powered by FluxBB