LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Sharing ext4 partition among different linux distros (https://www.linuxquestions.org/questions/slackware-14/sharing-ext4-partition-among-different-linux-distros-4175735455/)

rzdndr 03-29-2024 10:39 AM

Sharing ext4 partition among different linux distros
 
Hello,

Would it be possible to share an ext4 partition among different linux distros?

For instance have a /dev/sdd4 and mount this to /mnt/data on each of the distros that is multi booted, and share data between these.

Would the attributes (permissions, groups, users) pose a problem?

Regards

Didier Spaier 03-29-2024 12:29 PM

No issue at all. Just make sure you access it under the same user name or at least numeric user id from each distribution or system.

For instance here in every system I have this line in /etc/fstab:
Code:

UUID=47af727a-ecc4-4241-b5e0-c121302d8197 /data ext4 noatime 1 2
I prefer to name the partition by UUID, and create a /data directory in each system instead of mounting on /mnt/data.

business_kid 03-29-2024 12:42 PM

UIDs & GIDs will be a problem. You can use 'usermod' to change them, but then you have to change each distro to match. Once you do that, you should be ok as long as you keep root off the disk. Alternatively, if only root has permission, that makes uid & gid identical.

henca 03-29-2024 12:53 PM

It might be worth pointing out that the partition UUID is not the same as the user uid. The user uid is the number in field 3 in /etc passwd. Example:

Code:

henca:x:406:100:Henrik Carlqvist:/home/henca:/bin/tcsh
Above my username henca has the numeric uid 406. On file systems like ext4 ownerships are stored as those numeric uids. If you care about group permissions you might also want to sync the gid numbers from /etc/group.

Many years ago I thought that dual- or multi-boot was useful to keep different operating systems. In practice however I allways ended up only using one prefered OS. Rebooting the machine to run some application in another OS is rather annoying. Today, whenever I feel the need to run another OS I use some virtual machine instead. Usually I prefer qemu for that.

regards Henrik

rzdndr 03-29-2024 11:06 PM

Quote:

Originally Posted by Didier Spaier (Post 6492733)
No issue at all. Just make sure you access it under the same user name or at least numeric user id from each distribution or system.

For instance here in every system I have this line in /etc/fstab:
Code:

UUID=47af727a-ecc4-4241-b5e0-c121302d8197 /data ext4 noatime 1 2
I prefer to name the partition by UUID, and create a /data directory in each system instead of mounting on /mnt/data.

Yes that is what I thought too. The numeric user id (or maybe group id) must be the same. Maybe can use root only for that drive as business_kid mentioned.

rzdndr 03-29-2024 11:06 PM

Quote:

Originally Posted by business_kid (Post 6492739)
UIDs & GIDs will be a problem. You can use 'usermod' to change them, but then you have to change each distro to match. Once you do that, you should be ok as long as you keep root off the disk. Alternatively, if only root has permission, that makes uid & gid identical.

Root user might be an alternative.

rzdndr 03-29-2024 11:10 PM

Quote:

Originally Posted by henca (Post 6492744)
It might be worth pointing out that the partition UUID is not the same as the user uid. The user uid is the number in field 3 in /etc passwd. Example:

Code:

henca:x:406:100:Henrik Carlqvist:/home/henca:/bin/tcsh
Above my username henca has the numeric uid 406. On file systems like ext4 ownerships are stored as those numeric uids. If you care about group permissions you might also want to sync the gid numbers from /etc/group.

Many years ago I thought that dual- or multi-boot was useful to keep different operating systems. In practice however I allways ended up only using one prefered OS. Rebooting the machine to run some application in another OS is rather annoying. Today, whenever I feel the need to run another OS I use some virtual machine instead. Usually I prefer qemu for that.

regards Henrik

Changing (synching user/group id's) would also require to change user/group id's of all the files on both systems I believe.

Virtual machine would be the other alternative.

hazel 03-30-2024 01:17 AM

I've been doing that for years. I use my home directories only for configuration files and temporary storage, and have a universal data partition for documents.

henca 03-30-2024 06:56 AM

Quote:

Originally Posted by rzdndr (Post 6492845)
Changing (synching user/group id's) would also require to change user/group id's of all the files on both systems I believe.

Yes, but you really only have to care about those users storing files on the shared partition. Usually this will be limited to normal users who live below /home. Or do you intend to use the shared partition also for system users like ftp, mysql and apache?

The need to have synchronized uid and gid numbers are not limited to multi boot OS sharing partitions. The same applies to networked systems sharing an directory with NFS.

regards Henrik

rzdndr 03-31-2024 12:33 AM

Quote:

Originally Posted by henca (Post 6492891)
Yes, but you really only have to care about those users storing files on the shared partition. Usually this will be limited to normal users who live below /home. Or do you intend to use the shared partition also for system users like ftp, mysql and apache?

The need to have synchronized uid and gid numbers are not limited to multi boot OS sharing partitions. The same applies to networked systems sharing an directory with NFS.

regards Henrik

I wanted to share only data, to keep the home directories clean. Mostly downloads, and backups that I have.

I did not think about the ftp, mysql, apache and other users actually. Good point. Maybe I would need them, maybe I can just keep them as is, and use a user (root probably) to move data from these accounts.

henca 03-31-2024 07:14 AM

Quote:

Originally Posted by rzdndr (Post 6493089)
I wanted to share only data, to keep the home directories clean. Mostly downloads, and backups that I have.

For such a simple use case it is not even necessary to have uid and gid synchronized between the systems. Yes, it would be nice if they have the same point of view on users and groups, but not completely necessary. All you have to do is to make sure that chmod is used to give all users the access that you want to have from other booted systems. Something like:

Code:

chmod a+r some_file.tar.gz
...to be able to read that file from other booted systems. If you choose to go that simple route, a command like "ls -la" might show strange ownerships of files. Maybe files will seem to be owned by some other local user, maybe files will be seemed to be owned by a user with only a numeric uid.

regards Henrik

business_kid 03-31-2024 08:41 AM

A data partition is better than a shared /home for one extra reason that hasn't been mentioned.

I installed Debian as a second OS, largely for those ungainly packages (e.g. Kicad, FPGA suites, etc) that are so messy to build in Slackware, but pre-built for Debian. But Debian shows a bundle of Desktop shortcuts for packages I don't have in Debian. If I put anything into Debian (which I haven't yet), that will not exist in Slackware.

Another issue is X settings, with Mate in Slackware and Cinnamon(?) in Debian. I mean to enter Debian some day and reassign /home, but it's near bottom of my priorities ATM.

henca 03-31-2024 01:53 PM

Yes, there are more reasons that you might want to avoid sharing home directories between systems...

Usually different applications and desktop environments are "backwards compatible" with the configuration files that live below your home directory. However those applications not allways "forwards compatible". As an example, if you are running installation A with KDE 2 fine and then start installation B with KDE 3 using the same home directory everything will seem fine until you again log in to installation A with KDE 3 and find that much has become broken.

In environments where different installations or machines share the same home directory I often modify some environment variables. Example from /etc/profile.d/kde.sh:
Code:

#!/bin/sh
# KDE additions:
KDEDIRS=/usr
export KDEDIRS
PATH="$PATH:/usr/lib64/kde4/libexec"
export PATH
if [ ! "$XDG_CONFIG_DIRS" = "" ]; then
  XDG_CONFIG_DIRS=$XDG_CONFIG_DIRS:/etc/kde/xdg
else
  XDG_CONFIG_DIRS=/etc/xdg:/etc/kde/xdg
fi
export XDG_CONFIG_DIRS

# Added by henca to allow different versions of KDE to coexist
KDEHOME=$HOME/.kde_slack142
export KDEHOME

regards Henrik


All times are GMT -5. The time now is 10:41 AM.