LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Is it possible to have multiple root directories? (https://www.linuxquestions.org/questions/linux-newbie-8/is-it-possible-to-have-multiple-root-directories-4175486790/)

TJen 12-04-2013 02:14 AM

Is it possible to have multiple root directories?
 
Hi.

I'm a long time windows user who's trying to get into linux.

In windows, I'm used to having all the harddisks\partitions as separate root drives, meaning that the D-drive is a completely separate files system.

Is it possible to get something like that in Linux?
If I've understood thngs correctly, when you mount a new harddisk in linux ypu mount it to a new\existing directory inside the existing file-system, meaning that the harddisk shows up as just another directory alongside all the other directories in root directory.
Is it possible to instead mount it as a completely separate root directory with nothing in it or besides it?

astrogeek 12-04-2013 02:26 AM

If I understand you correctly, no.

Every mounted device is visible within the root filesystem.

druuna 12-04-2013 02:32 AM

Quote:

Originally Posted by TJen (Post 5075089)
I'm a long time windows user who's trying to get into linux.

In windows, I'm used to having all the harddisks\partitions as separate root drives, meaning that the D-drive is a completely separate files system.

First of all: Windows and Linux work differently. However, some concept are the same, although they might have different names in either of the OS.

In Windows you talk about C, D Drives. Which are partitions with their own file-system (fat32, ntfs, etc)
On Linux you talk about partitions, which also have their own file-system (ext4, reiserfs, etc)

Quote:

Is it possible to get something like that in Linux?
If I've understood thngs correctly, when you mount a new harddisk in linux ypu mount it to a new\existing directory inside the existing file-system, meaning that the harddisk shows up as just another directory alongside all the other directories in root directory.
Is it possible to instead mount it as a completely separate root directory with nothing in it or besides it?
Nope, the root directory (/) is the starting point. All partitions (and external drives) are mounted under root.

Why would you want to do this?

s.verma 12-04-2013 04:19 AM

It is by design of unix and unix like filesystem that every partition, devices etc. are visible in its only one root filesystem.

In unix, since everything is considered as file, so there is no way to treat partition as different root filesystem, since partition would be considered as a file too. Hence this file will be in some folder.

TJen 12-04-2013 05:18 AM

Thanks. I didn't really think it was possible, but I figured it was worth a shot asking at least.

The reason I want this is because I'm the the type that likes to havee the actual Os completely separated form the actual data\entertainment files on my system. The only thing I have om my C-disk is windows. All games, movies, music and similar files I have on a different hard disk. And I'm weird enoungh that I've even made a symbolic link from the common-folder in steam to my games folder to make sure that all games are installed to only one location on my system.

As an alternativ, is it possible to install the linux system to a subfolder in the root?
What I'm thinking is to maybe set it up so that the only folders\files that exist on the actual root is the mount points for the harddisks, and then installing the system to one of those mount points instead of directly to the root. Would something like that be possible?

druuna 12-04-2013 05:40 AM

You should let go of the Windows way of thinking.

Assuming 2 hd's, both with one partition: 1 hd (partition) will be used for the OS and the other hd (partition) for "data". This separates both data and the OS.

The data partition has to be mounted under the root partition to make it accessible under Linux/Unix.

If, for example, you want to reinstall the OS you can do so without any concern for the data partition. Once the OS is installed you mount the data partition and all will be available again.

salasi 12-04-2013 05:57 AM

Quote:

Originally Posted by TJen (Post 5075168)
The reason I want this is because I'm the the type that likes to havee the actual Os completely separated form the actual data\entertainment files on my system.

Well, that's possible, even if you are asking the wrong questions to get there...
  • (and this makes sense for other reasons) You can have your 'home' directory off on another partition from the partition(s) on which the OS resides. this separates all of your own data (your data that you have explicitly created, as well as data that you have implicitly created, such as configurations for programs and applications) from the OS and its programs and configurations. It may be too soon to talk of this, but this, amongst other things, simplifies matters when it comes to OS upgrades and re-installs.
  • In fact, more generally, you can separate almost anything off on to a separate partition. what you don't get, that you might have been expecting/wanting is a system that looks any different. That is, from a normal user point of view, directories are still in the place that you would expect them to be, and there's none of that silly 'oh yes, I moved that to the F: drive, now I've got to navigate all the way over there' stuff.

The key here (or, part of the key, anyway) is that user files are saved under /home/username/...... and that's the way that it will always appear, whether or not home is a separate partition from / . There are various other tricks you can play with this, but you should get your head around that first.

r41d3n 12-04-2013 07:06 AM

You can create a chroot in a directory under /, but I don't think it is what you want.

AnanthaP 12-04-2013 07:44 AM

You can practically achieve what you need (separation of system on one drive and data on the other) since you can mount a physical drive anywhere in the single file system. Thats what the mount command is for. To quote from one manual, (http://linux.die.net/man/8/mount)
Quote:

All files accessible in a Unix system are arranged in one big tree, the file hierarchy, rooted at /. These files can be spread out over several devices. The mount command serves to attach the filesystem found on some device to the big file tree. ....
So you could have system files on one drive say /dev/sda1 and all user data on /dev/sda2 - say by 'mount /dev/sda2 /home' and having all users' home directories under /home - which is /home on the unified file system.

OK

Soadyheid 12-04-2013 10:22 AM

Quote:

The only thing I have om my C-disk is windows. All games, movies, music and similar files I have on a different hard disk
So that's C: contains OS, E: (or whatever) contains data? Is that what you're saying?

In Linux land that's equivalent to "/" on /dev/sda, "/home" on /dev/sdb. That's two separate disks with one partition per disk. All your user data and config files are kept in the "/home" partition, i.e. the second disk.

As an asides... If you partitioned your first disk, (C: known as /dev/sda), the partitions would be /dev/sda1, /dev/sda2, etc, etc, dependant on the number of partitions.
This can still be usefull in a single disk system in that if the data partition gets borked; head crash or whatever, you could still mount the second partition with a live CD Distro and rescue your data! (I'm asuming two partitions in this instance, / and /home.)

Back at the two disk senario...

You set up these partitions when you Install your distribution naming "/" as the mount point for /dev/sda1 and "/home" as the mount point for /dev/sdb1.
Note: /dev/sdb would be the whole disk, /dev/sdb1 would also be the whole disk if it was defined as a single partition. Does your head hurt yet?

If you decide to change your Distro in the future, you can do an install where the new OS is installed on /dev/sda1 and you name /dev/sdb1 as /home for your data again.
WARNING! Before letting the install format BOTH disks, uncheck the format option for the /home partition so it's left untouched and your data will be available to your new distrubution.

Caveats:
1. You should back up your /home partition before installing your new distro.
2. Your home partition also holds invisible "." config file for the applications you use, they may not quite fit the new distributions versions so be aware you could get some weird stuff happen. I've used this install method a few times and so far, so good! :D

That's my :twocents:

Play Bonny!

:hattip:

haertig 12-04-2013 10:30 AM

Quote:

Originally Posted by TJen (Post 5075089)
In windows, I'm used to having all the harddisks\partitions as separate root drives, meaning that the D-drive is a completely separate files system.

Actually, in Windows your "root" is more like "My Computer". And your "C:" and "D:" drives are just branches under that root.

AnanthaP 12-11-2013 01:47 AM

Quote:

Actually, in Windows your "root" is more like "My Computer". And your "C:" and "D:" drives are just branches under that root.
Not quite similar. In windows all application programs eventually refer to a path on a specific drive. On a *x distro, reference is only to the software handle - which is of course linked to the specific drive at "mount" time only. This makes it easier to maintain and manage.

OK

JJJCR 12-11-2013 02:18 AM

Quote:

Originally Posted by astrogeek (Post 5075098)
If I understand you correctly, no.

Every mounted device is visible within the root filesystem.

Totally agree with astrogeek, since you are a Windows user.

It's also not possible in Windows to have multiple Windows directory that is active at all times.

"/" root directory on Linux is same as C:\Windows directory.

Short answer "Not possible".

SAbhi 12-11-2013 02:38 AM

So you already had the answer "no". this is quite a similar concept of:
"you can have multiple people using your Pen but you own it and no one can't at the same time. whenever you want you can take it back from others and write what you want too." The same with root (it is the starting point "/" and the default owner to everything under), you cant have multiple root at the same time on any *nix OS atleast.

DavidMcCann 12-11-2013 10:54 AM

One extra point. In Windows, each program gets its own folder with everything in it, as far as I know (I've never actually used it). In Linux, the configuration data for a program is not stored with the program: it's in your home directory. That way, two people can share a computer and have it work differently, and the owner can install a new OS and keep the existing configuration. Also, all programs using the same dynamically linked library will share the same copy that lives in a separate place. That separation of components is then extended, so that a program's binary is in one place, it's documentation in another, and so forth. The filing system is very different to Windows and it's been evolving since before Windows was created. You just have to accept it.


All times are GMT -5. The time now is 10:36 PM.