63
submitted 8 months ago* (last edited 6 months ago) by Doctor_Rex@lemmy.ml to c/linux@lemmy.ml

For the past week, I've been trying to switch my /home partition from my 500GB nvme to my 1TB sata ssd. I've been asking and receiving help from people in my previous post, but I keep hitting wall after wall in making it work and I seem to be missing a step.

Big thank you to @pixelscript@lemmy.ml, @NateSwift@beehaw.org, for replying to my comments and helping me along.

Previous post:

I finally installed Linux, but I'm having a mixed experience

Context:

OS: Fedora Linux 39 (KDE Plasma) x86_64
Kernel: 6.5.6-300.fc39.x86_64
DE: Plasma 5.27.8
WM: Kwin
CPU: AMD Ryzen 5 5600X
GPU: Nvidia Geforce GTX 1660

I have a 500GB nvme which I want to have my entire / stored within. And I have a 1TB sata ssd which I want to have my /home to be stored in. I've tried many of the steps some helpful people here on lemmy have detailed, and though it's gotten me closer to getting it right, but I still can't seem to login when I switch my fstab.

Allow me to go through every step I've done so far.

I reinstalled fedora, hoping I could separate my /home in the installer. No such luck, anytime I switched my /home partition into the 1TB drive my entire root directory would follow it. I decided to do the auto install on my nvme and do it manually when it's fully installed.

So just to be clear I am starting from a clean install nothing except neofetch and vim installed.

I created two new directories directly in /. They were /new_home and /old_home.

I formatted my 1TB disk, partitioned it, and then formatted the partition into an ext4, 931.5 G partition.

I mounted it to /new_home

NAME        FSTYPE FSVER LABEL  UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                                 
└─sda1      ext4   1.0          f56df020-2420-4b0c-af4d-2c4c6a56a0b0  718.4G    16% /new_home

From here I ran the command sudo rsync -a /home/adelie/new_home. this is why the current available space is 718.4G. I also added a new file to /new_home called confirm.txt in order to tell which was which at a glance.

I check the permissions and ownership of both /home and /new_home with ls -la they were identical.

adelie@localhost-live:/new_home$ ls -la /new_home

total 8
drwxr-xr-x.  3 root   root   4096 Feb 27 11:06 .
dr-xr-xr-x.  1 root   root    204 Feb 25 21:13 ..
drwx------. 15 adelie adelie 4096 Feb 27 11:11 adelie
adelie@localhost-live:/new_home$ ls -la /home

total 0
drwxr-xr-x. 1 root   root    12 Feb 25 21:01 .
dr-xr-xr-x. 1 root   root   204 Feb 25 21:13 ..
drwx------. 1 adelie adelie 348 Feb 27 11:25 adelie
adelie@localhost-live:/new_home$ 

The story is the same inside the $USER files, the files and directories are identical and so are there permissions and ownership.

I added /dev/sda1 to fstab to auto boot both drives.

UUID=d5877671-6a39-4d96-9a2a-514b6007a59b /                       btrfs   subvol=root,compress=zstd:1 0 0
UUID=ed92de40-2403-4365-9b5c-eb10d519757c /boot                   ext4    defaults        1 2
UUID=02E9-123A          /boot/efi               vfat    umask=0077,shortname=winnt 0 2
UUID=d5877671-6a39-4d96-9a2a-514b6007a59b /home                   btrfs   subvol=home,compress=zstd:1 0 0
UUID=f56df020-2420-4b0c-af4d-2c4c6a56a0b0 /new_home               ext4    defaults        1 2

At this point I haven't changed the boot path for /home yet. When I rebooted, everything worked as expected. When I entered the KDE login screen it let me go into my desktop when I inputted my password correctly.

After this I decided to swap them.

UUID=d5877671-6a39-4d96-9a2a-514b6007a59b /                       btrfs   subvol=root,compress=zstd:1 0 0
UUID=ed92de40-2403-4365-9b5c-eb10d519757c /boot                   ext4    defaults        1 2
UUID=02E9-123A          /boot/efi               vfat    umask=0077,shortname=winnt 0 2
UUID=d5877671-6a39-4d96-9a2a-514b6007a59b /old_home                   btrfs   subvol=home,compress=zstd:1 0 0
UUID=f56df020-2420-4b0c-af4d-2c4c6a56a0b0 /home               ext4    defaults        1 2

When I entered into the KDE login screen, anytime I inputted my password correctly it would kick me back to the login screen within the second. At this point I assumed it was a KDE issue and that I was missing a step in order to login correctly.

I read a comment explaining TTY, and that I should try logging in from there to confirm if it was a KDE issue or not. When I tried it I ended up with this.

Fedora Linux 39 (KDE Plasma)
Kernel 6.5.6-300.fc39.x86_64 on an x86_64 (tty3)

Localhost-live login: adelie
Password:
Last login: Tue Feb 27 xx:xx:xx on tty3
 -- adelie: /home/adelie: change directory failed: Permission denied
Logging in with home = "/".

From my root account I checked /home and /old_home, and /home contained confirm.txt, meaning that everything mounted properly, I then changed the fstab back to what is was originally.

This is where I'm at now.

I'm totally lost on what step I missed. I'd like to get this working in order to actually be able to use my computer, as I am committed to changing my /home directory before making any major changes or installs. If anybody has any idea on what I missed please feel free to pitch in.

*Update: The issue was SELinux. My SELinux contexts were bad and were denying me access to my own data. I reset the context with this command, restorecon -Rv /home/

I'd like to give a big thanks to,

/u/shininghero@kbin.social; for pointing out SELinux as a possible issue.

/u/burrito@sh.itjust.works; for providing the command to fix this issue.

/u/kbal@fedia.io; for being so patient with me, and helping me go through the list of possible issues.

top 50 comments
sorted by: hot top controversial new old
[-] shininghero@kbin.social 35 points 8 months ago* (last edited 8 months ago)

Fedora Linux also comes with SELinux enabled by default. Did you check that the new home folder and all its contents have the proper SELinux tags?
Run an ls -lZ and check that the directory has the user_home_t tag,
The user's home directory is also stored in the /etc/passwd file. Did you update the entry there?

No, do not "disable SELinux". That advice hasn't been valid for a good 20 years. You can set it to permissive though, to see if it's the source of the problem.

[-] Doctor_Rex@lemmy.ml 7 points 8 months ago

ok here's the output

root@localhost-live:/home/adelie# ls -lZ
total 36
-rw-r--r--. 1 adelie adelie unconfined_u:object_r:unlabeled_t:s0    0 Feb 27 11:11 confirm.txt
drwxr-xr-x. 2 adelie adelie unconfined_u:object_r:unlabeled_t:s0 4096 Feb 25 21:03 Desktop
drwxr-xr-x. 2 adelie adelie unconfined_u:object_r:unlabeled_t:s0 4096 Feb 27 19:32 Documents
drwxr-xr-x. 2 adelie adelie unconfined_u:object_r:unlabeled_t:s0 4096 Feb 27 10:59 Downloads
drwxr-xr-x. 5 adelie adelie unconfined_u:object_r:unlabeled_t:s0 4096 Feb 26 14:15 Essentials
drwxr-xr-x. 2 adelie adelie unconfined_u:object_r:unlabeled_t:s0 4096 Feb 27 10:59 Music
drwxr-xr-x. 3 adelie adelie unconfined_u:object_r:unlabeled_t:s0 4096 Feb 27 11:00 Pictures
drwxr-xr-x. 2 adelie adelie unconfined_u:object_r:unlabeled_t:s0 4096 Feb 27 11:00 Public
drwxr-xr-x. 2 adelie adelie unconfined_u:object_r:unlabeled_t:s0 4096 Feb 27 11:00 Templates
drwxr-xr-x. 2 adelie adelie unconfined_u:object_r:unlabeled_t:s0 4096 Feb 27 11:00 Videos

[-] burrito@sh.itjust.works 43 points 8 months ago* (last edited 8 months ago)

Here's your issue. Your selinux contexts are bad so you're probably being denied access to your own data. To reset the contexts back to normal you can use the restorecon command:

restorecon -Rv /home/

The -R tells it to go through the specified path recursively, the v tells it to be verbose in the output and show you what it's doing.

[-] Doctor_Rex@lemmy.ml 33 points 8 months ago

IT FUCKING WORKED

THANK YOU

[-] burrito@sh.itjust.works 10 points 8 months ago

Awesome! Enjoy!

[-] kbal@fedia.io 6 points 8 months ago

It's probably ls -lZd . .. you'd want there instead, but I don't know selinux.

But yeah, damn, it never would've occurred to me that you had that installed without knowing it. Glad to have a possible explanation.

[-] Doctor_Rex@lemmy.ml 3 points 8 months ago

I didn't realize I had it either, I'll see what I can do to fix it tomorrow because right now, I'm tired and hungry.

BTW, thank you for your help. Your comments and explanations have been a great in helping me understand my issue and Linux in general.

[-] Nomad@infosec.pub 2 points 8 months ago

Great catch!

[-] chameleon@kbin.social 16 points 8 months ago

This is a shot in the dark, but since the permissions look fine to me, the only other thing that comes to mind is that the SELinux contexts might not have been copied. Fedora is one of the few distros that enables SELinux in enforcing mode right out of the box. That can be very complex to understand if it breaks.

There is a Fedora documentation page about SELinux. The /var/log/audit/audit.log log file should be full of errors relating to your /home if it broke. I believe that stat /home and stat /new_home should display the SELinux context if SELinux is active, and they should be identical.

Also possible I'm totally off the mark, though, it's just a possibility.

[-] Bitrot@lemmy.sdf.org 4 points 8 months ago* (last edited 8 months ago)

You’re not wrong, rsync -a does not copy extended attributes, including selinux stuff. It needs -X added for that.

I think restorecon should be able to analyze and set them again. Something like restorecon -r -v -n /home. The -n doesn’t actually change anything.

[-] Doctor_Rex@lemmy.ml 3 points 8 months ago

I went into /audit.log you asked, I'm gonna be honest as a total linux newbie I have no idea what im looking at . I don't really know what's supposed to be an error and what's irrelevent. This is the only thing that stick out to me

type=SERVICE_START msg=audit(1708923571.909:69): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=systemd-userdbd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'^]UID="root" AUID="unset"

[-] agent_flounder@lemmy.world 5 points 8 months ago* (last edited 8 months ago)

FWIW it is doable :) since I have Fedora (37) and a separate /home and / device. Btrfs in my case.

How did you deal with the home sub volume?

~~I will edit this with hopefully useful info about my fstab etc. in a few min...~~


okey dokey


Here's my fstab. I had to comment out the home subvol and mount /home

UUID=02b32afc-3e05-412b-8781-xxx /                       btrfs   subvol=root,compress=zstd:1 0 0
UUID=e82e80a8-b169-4127-90ad-xxx /boot                   ext4    defaults        1 2
UUID=D358-0ADF          /boot/efi               vfat    umask=0077,shortname=winnt 0 2
#UUID=02b32afc-3e05-412b-8781-xxx /home                   btrfs   subvol=home,compress=zstd:1 0 0
/dev/disk/by-uuid/7b194608-a407-4c2c-a0d8-xxx /home auto nosuid,nodev,nofail,x-gvfs-show 0 0

Permissions on /home mount point (before mounting device to mountpoint):

$ ls -la /home
total 0
drwxr-xr-x. 1 root root   0 Jan  5 20:47 .
dr-xr-xr-x. 1 root root 166 Feb 27 18:36 ..

$ sudo getfacl home
# file: home
# owner: root
# group: root
user::rwx
group::r-x
other::r-x

Relevant output from df

$ df
Filesystem      1K-blocks      Used Available Use% Mounted on
/dev/sdb3       998540288   5447260 991484436   1% /
/dev/nvme0n1p6 1248619684 932769256 258218276  79% /home

Home dir permissions

$ ls -ldZ /home/mes
drwxr-xr-x. 196 mes mes system_u:object_r:user_home_dir_t:s0 12288 Feb 27 19:13 /home/mes

$ sudo getfacl /home/mes
getfacl: Removing leading '/' from absolute path names
# file: home/mes
# owner: mes
# group: mes
user::rwx
group::r-x
other::r-x

Let me know if I can give any additional info.

[-] lemmyreader@lemmy.ml 3 points 8 months ago

Change SELinux configuration into warning only, reboot and see if that helps ? It that works then you know it's a SELinux thing to solve.

[-] kbal@fedia.io 2 points 8 months ago

Can you confirm that confirm.txt is not in old home?

[-] Doctor_Rex@lemmy.ml 1 points 8 months ago* (last edited 8 months ago)

I've done this several times and yes I can confirm everything mounted properly. The only issue as far as I can tell is that I can't login. I made an edit on the post to clarify this.

[-] kbal@fedia.io 2 points 8 months ago* (last edited 8 months ago)

so if you do 'ls -la /home/adelie | wc -l' and 'ls -la /home_new/adelie | wc -l' you get results that differ by exactly 1? idk, just a thing to check.

[-] Doctor_Rex@lemmy.ml 2 points 8 months ago

yes /home is 23, and /new_home is 24, what does this mean?

[-] kbal@fedia.io 3 points 8 months ago* (last edited 8 months ago)

The number of files in each. So all the right files are there I guess. Moving /home really shouldn't cause any problems so it was just a way to check for the unlikely case of that being somehow a problem.

/home/adelie: change directory failed: Permission denied

Means you don't have permission to cd to that dir for some reason. So when it happens do:

sudo chmod 700 /home/adelie
sudo chown -R adelie:adelie /home/adelie
[-] Max_P@lemmy.max-p.me 4 points 8 months ago

I'd also chmod a+x /home. If only root can traverse the new /home, the permissions on /home/adelie are irrelevant as there's no way to get there without traversing /home.

[-] Doctor_Rex@lemmy.ml 1 points 8 months ago

If you wouldn't mind, could you please explain what these command will do.

Also I'm back in the fixed state should I change my fstab back to the broken state before I run this?

[-] kbal@fedia.io 2 points 8 months ago* (last edited 8 months ago)

chmod 700 [file] sets permissions so that only its owner can do anything to that file or directory, and that owner can do whatever they like to it.

chown -R [user]:[group] [dir] makes everything in that directory owned by that user and group.

chmod a+x /home like /u/Max_P and I both got to within a few seconds of each other and will probably fix your problem, allows every user to change directories into /home which is a prerequisite for anyone getting to /home/adelie.

The "700" and "755" are values in octal where the first digit represents what permissions the owner has, the next two digits what everyone else has. I tend to use those but probably "a+x" is a more sensible way to do the same thing.

[-] Doctor_Rex@lemmy.ml 1 points 8 months ago

So I ran all three commands including the one /u/Max_P gave. I then changed the fstab and rebooted. I still couldn't login after that.

I then tried to login with TTY. it gave me the same error as in the post. I ran the three commands again and rebooted. still nothing

I logged in with my root account and ran the three commands again, rebooted and still couldn't login. I then fixed the fstab and now I'm back here again.

just to be clear i ran chmod 700 not 755.

Anything I should run in order to check my system? I must've done something wrong. Maybe it has to do with btrfs?

[-] kbal@fedia.io 1 points 8 months ago* (last edited 8 months ago)

Yeah, logging in as root (good to know things are configured so you can do that) when it's giving that error, and then running those commands should have done the trick I'd have thought.

just to be clear i ran chmod 700 not 755.

Well that's fine so long as you also did "chmod a+x /home". If for some reason you did "chmod 700 /home" as root that is no good.

The error message you got strongly suggests that it should've worked. If you mount that new home again so you get the same error, then log in as root and show us the results of

ls -ld /home
ls -ld /home/adelie

That would perhaps clear things up.

[-] yianiris@kafeneio.social 2 points 8 months ago

The home directory of the user is defined in /etc/passwd

Make sure it is the same as the one you have.

% sudo grpck
will check your group shadow gshadow passwd files for conflicts, it will tell you what you need to fix or if it is simple it will fix it for you.
If you get no output everything is OK

@kbal @pixelscript @NateSwift @Doctor_Rex

[-] Doctor_Rex@lemmy.ml 1 points 8 months ago

It's all ok then.

[-] Doctor_Rex@lemmy.ml 1 points 8 months ago

Heres what I got

root@localhost-live:/# ls -ld /home
drwxr-xr-x. 3 root root 4096 Feb 27 11:06 /home

root@localhost-live:/# ls -ld /home/adelie
drwx------. 15 adelie adelie 4096 Feb 27 18:00 /home/adelie
[-] kbal@fedia.io 2 points 8 months ago* (last edited 8 months ago)

Okay well it's pretty weird I guess. I do have one more idea... instead of swapping the entries in fstab, try removing the old one and not mounting old home at all. To do that, put a "#" in front of the line that would mount old_home.

I don't know how btrfs works so maybe it really is that somehow. Maybe its "subvol=home" is somehow causing a problem.

[-] Doctor_Rex@lemmy.ml 1 points 8 months ago

So I did that and nothing different happened. I'm sorry to keep taking your time like this do you know of any place, like a Discord server or something, that I can talk with somebody about this in real time.

I'm probably going to give this issue one more day to resolve before I give up and switch to Windows 11.

[-] kbal@fedia.io 1 points 8 months ago* (last edited 8 months ago)

Edit: Never mind, it's probably SELinux or something like that.

I dunno, it's just really weird that the ls -ld output was saying everything was fine and yet at the same time (it was at the same time right?) the user login was saying you don't have permission to that same home directory. You could try again, log in as root (after confirming you still get the same permission denied error) and then do:

ls -ldn /home/adelie
ls -ldn /home
grep adelie /etc/passwd
su - adelie
cd /home/adelie

That would show the numeric uid and gid instead of your name in the ls output, check that it matches what's in /etc/passwd (you didn't edit /etc/passwd though, it should be fine), and then see if you can 'cd' after boot but not on login somehow.

Anyway I think your best bet would be to find someone nearby who could try and figure it out in person, if at all possible. Maybe ask around at the local computer shop, if there is one? Eh well, sorry I couldn't be of more help.

load more comments (2 replies)
load more comments (1 replies)
[-] timbuck2themoon@sh.itjust.works 1 points 8 months ago* (last edited 8 months ago)

First one sets it so that only the owner can read, (4), write (2), execute (1). That's why it equals 7. The group and all others (the next two numbers) can do nothing (0 meaning they can't read, write, or execute anything in there).

The second sets ownership (ie. That adelie account will be both the user and group in the above scenario.)

I'm coming in late in this but i don't know why you'd really do the first. The second simply changes things so your user has permission to their own home directory.

Lastly, names are meaningless in general. Things work on ids. You can run id to get a quick look at who you are. Same with echo $UID or $GID.

Really long but useful article to wrap your head around permissions- https://www.redhat.com/sysadmin/linux-file-permissions-explained

[-] Snoopy@jlai.lu 1 points 8 months ago* (last edited 8 months ago)
  • chmod : change mode

  • chown : change owner

  • -R : recursive. So all subfolders and files will change ownership.

  • 700 : this is a code for files permission for those 3 groups in linux :

  • user (you) : 7

  • group : 0

  • other : 0

What do those number mean ? A file can be read, written, executed. Those 3 permissions are associated with number :

  • read : 4
  • witten : 2
  • executed : 1

If a file can be read and written its number will be 4+2 = 6

[-] kbal@fedia.io 2 points 8 months ago

oh... to add to my other suggestion:

sudo chmod 755 /home

I bet that's it.

[-] Doctor_Rex@lemmy.ml 2 points 8 months ago

I'd like to know what this command will do before I run it.

[-] FigMcLargeHuge@sh.itjust.works 3 points 8 months ago

That is the numeric representation of rwxr-xr-x permissions. It's 3 bits wide, and 4 = r, 2 = w, and 1 = x. So you add them together. 7=rwx, 5=r-x. If you wanted just read only, you would use 4. And of course 0 mean no permissons. And the bits are ordered by Owner, Group, and Everyone. 755 mean owner has full permissions, group and everyone can read and see the directory since it has x.

[-] kbal@fedia.io 1 points 8 months ago

To further explain all the things everyone is leaping to explain, the 'x' for 'execute' permission is the same bit you need set to have permission to "cd" into a directory, as well as execute a file.

And the default permissions when you did "mkdir" are controlled by something called "umask" which is probably set not to allow anyone else to cd into directories you create as root until you chmod them.

load more comments (3 replies)
[-] FigMcLargeHuge@sh.itjust.works 1 points 8 months ago* (last edited 8 months ago)

My uneducated guess here is that the id number for adelie has changed. Continue with this login, and then:

sudo chown -R adelie:adelie /home/adelie

Then logout and back in to see if the new /home/adelie is set to the correct id.

[-] Doctor_Rex@lemmy.ml 2 points 8 months ago

I didn't know users had id numbers, any way to check my current one. I've changed fstab to what is was originally since then. I've made an edit to clarify this.

[-] Nomecks@lemmy.ca 3 points 8 months ago* (last edited 8 months ago)

cat /etc/passwd |grep adelie

[-] agent_flounder@lemmy.world 2 points 8 months ago

Or use the id command.

[-] John@discuss.tchncs.de 1 points 8 months ago

I allways symlink(ln -s) some folders from my HDD(Pictures, Movies, Documents, Music) since i dont want to have all my home folder on my slow HDD. May this is an Option for you.

[-] acockworkorange@mander.xyz 1 points 8 months ago

Did you try logging into your root user account? That will allow you to see current mount points.

Maybe something went wrong with mounting the new volume to /home. Maybe the Btrfs @home volume doesn't like being mounted anywhere else but /home. TBH I don't think it's the latter, but you can't troubleshoot unless you login. And you have to login as root, as the home path for root is /root, therefore immune to your conundrum.

[-] Doctor_Rex@lemmy.ml 2 points 8 months ago

I've entered into my root account to check the mount points and yes I can confrim everything mounted properly. I simply can't login, as far as I can tell. I've made an edit on the post to clarify this.

[-] acockworkorange@mander.xyz 2 points 8 months ago* (last edited 8 months ago)

Before we give up, check your /home/adelie permissions. Especially your ~/.config. I'm quite stumped, I'm afraid.

I just noticed you did login with Adelie, just couldn't cd to it. I'm on mobile so bear with me. What are the outputs of:

$ whoami

$ ls -l /home/adelie

?

[-] BananaTrifleViolin@lemmy.world 1 points 8 months ago* (last edited 8 months ago)

Using the BTRFS file system while swapping mount points around may be the issue. It looks like you don't have permission to access the new folders even thought you think you should. BTRFS can be strict/inflexible around ownership rules - when you swap the mount points around in fstab, the ownership in BTRFS may no longer map properly with the users for ownership in Linux. You need to take ownership of the files again via Linux commands.

As others have said try using the chown command (change ownership) with the - r flag (recursive so it goes into every subfolder) so that the user adelie owns everything again in your newly mounted /home/adelie folder. You need to do this after you've made the fstab change (I.e once you can't log in) so that it maps properly with adelie in the new set up. Either use sudo to run chown when logged in as adelie in tty or log in as root and run chown.

It looks like you can't log in graphically because KDE doesn't have permission to even read any of the file in your new home directory so KDE can't read any of its config files. It inherits the permission from the linux user adelie. When you log in with tty, you can't even enter the folder as adelie as you don't even have permission to read the folders, and you get thrown back to the root file system /.

load more comments (1 replies)
load more comments
view more: next ›
this post was submitted on 27 Feb 2024
63 points (100.0% liked)

Linux

47933 readers
1261 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS