LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Can you save data files in a separate partition? (https://www.linuxquestions.org/questions/linux-newbie-8/can-you-save-data-files-in-a-separate-partition-4175676915/)

Pen guin 06-11-2020 02:10 PM

Can you save data files in a separate partition?
 
One of the newest Linux users here as of the 10 June 2020. Linux Mint is currently installed on a 240GB Nvme Drive.

Here's the thing, not knowing much about partitioning, I just let the installer make one h u g e 240GB partition.

I just watched a video where he made an 8GB partition for Kali, (in his case,) and another one he called "School", where he was going to put all his data files from school.

Can you do that? I thought all data files went into the Home folder...

Thanks for the help.

Soadyheid 06-11-2020 02:45 PM

All user data goes into the user's /home folder but... Your /home folder can be a separate partition (as I have) or even a separate disk if you want.
You can also mount a separate disk somewhere within your /home partition! Note that using an existing folder as a mount point will prevent you accessing what was originally in the folder, you'd have to unmount your disk to get access back so better to mount on an empty folder.

a separate /home partition or disk allows you to load a fresh instance of your operating system (to the / partition) and just re-mount your /home partition thus keeping all your data intact! (Providing you uncheck the /home "Format the partition" box during your fresh install!

Hope that helps!

Plat Bonny!

:hattip:

agillator 06-11-2020 02:48 PM

Let me explain what a partition really is. Linux presents files to the user as one file system, a tree starting at /, the root directory. The files are arranged into so-called directories. This is all for simplicity's sake and for the convenience of the user. Actually the files all reside on various devices such as hard drives. Not all devices contain files; for example a GPS receiver is a device that is attached to a computer as if it were a file. To the user, everything in linux is a file. Limiting ourselves to data drive devices, they are subdivided for convenience to areas called partitions. To use those partitions the system 'mounts' (connects) them to mount points which the user sees as directories. If you will look at the /dev directory you will see a list of 'files' which are actually devices the system knows about which may or may not be actually present. If you are using files on a device they WILL be listed here. For example sda1 is the first partition on hard drive sda. But you don't have to worry about that, only about where it is 'mounted'. When you create a partition using something like gparted, parted, or fdisk you get the partition location (drive and number) which you use in the mount command:
Code:

mount /dev/sda1/home/george/my_data_files
for example.

So, in short, you can put files on any partition you want to simply by mounting the file system on the partition at a suitable location. Once mounted you will only see that 'partition' as a continuation of the system's tree.

quickbreakfast 06-11-2020 04:01 PM

Quote:

Originally Posted by Pen guin (Post 6133219)
One of the newest Linux users here as of the 10 June 2020. Linux Mint is currently installed on a 240GB Nvme Drive.

Welcome to the world of linux and to the base of what some people call a steep learning curve.

Quote:

Can you do that?
If you can not put your data somewhere other than in the home partition I'm in for a rude shock, because as a habit when installing a distro (a version of linux) I create a sparate partition to store my data.

Quote:

I thought all data files went into the Home folder...
By default data will be directed to your home folder. But with a click of your mouse, from a GUI, you can direct the data to go elsewhere. However....

System files, things like updating your computer (which should be done regularly) will/should go where they will be found by the OS.

Quote:

Here's the thing, not knowing much about partitioning, I just let the installer make one h u g e 240GB partition.
What you need to do is create a separate partition during the install (and give it a name) then direct the electronic marvel to put your data into the partition you create.

This reading might help.https://www.howtogeek.com/116742/how...alling-ubuntu/

60 GB is probably big enough for / (root) partition. The other 180GB can be a separate partition for your data.

One last thing, if your going to change/reformat your partitions/drive have EVERYTHING you even remotely might want to keep on an external drive.

Pen guin 06-11-2020 04:48 PM

Thanks agillator. Now I know what "Mount" means in the world of Linux. I had an idea, but having confirmation is nice...

Can you help me with allocating partition sizes? I'm running Linux Mint on a 240GB nVME drive. For what it's worth, I have a ton of room on my WD Passport, although it is 3 years old, half of which is used to store data, and the other half is used to store my Acronis W10 backups. So the data side, leaves me with a lot of unused room. but it's either GPT or NTFS, I'd have to check...

Need your opinion:

I posted yesterday, if members could check some bash code that would allow me to boot into Windows. Turns out the code was fine.

Should I post my question why I can't get into windows there, or explain the situation here?

Thanks...

quickbreakfast 06-11-2020 04:56 PM

Quote:

Originally Posted by Pen guin (Post 6133261)

I posted yesterday, if members could check some bash code that would allow me to boot into Windows. Turns out the code was fine.

Should I post my question why I can't get into windows there, or explain the situation here?

To save confusing members/readers separate questions in separate threads, please.

Pen guin 06-11-2020 05:13 PM

Thanks quickbreakfast; will do.

obobskivich 06-11-2020 05:29 PM

IME letting modern distro's installers select / as a very large single partition has not caused any dramatic problems, but as others have said, there's no problem with putting /home (or some mount within home, like say /home/school - from your example above) on another partition (e.g. to add more storage). It can be very useful if you don't, for example, like having to remember long file paths (e.g. /home/folder/folder/storage/things versus /things or /newdrive/things or what have you - all of those can be 'equal' in Linux depending on how you set things up).

Something to bear in mind if you're going to move disks around between machines/distros, create new partitions or mounts (often as root), you may need to chown the 'new' partition(s) to be able to read/write to them properly (this article provides a lot of detail: https://www.howtogeek.com/438435/how...mand-on-linux/). If you're wondering 'will this apply to me?' the really lazy/easy way is: if you can read/write within the folders/partitions you're using, then the answer is 'no' - but if you create (or plug-in) a new device and get permissions errors, this is a place to start (and the linked article provides background on how to actually confirm this, via console commands).

Finally, if you're going to change partitions or add more storage, and you want to be able to use the device after rebooting automatically, make sure it is added to your fstab (should be at /etc/fstab - open with root/su with text editor of your choice (e.g. nano, vim, whatever)) - identifying devices by UUID is more surefire (e.g. use blkid to confirm UUID (as root/su -> blkid /dev/sda1, versus just setting mounts by blk device (e.g. /dev/sda1)) as the block devices can be re-arranged if you remove/change disks on the machine between boots. I know that Gnome Disk Utility will attempt to do this automagically but I'd still take a look at fstab afterwords to make sure it actually did it right or make any changes you'd like.

agillator 06-11-2020 11:14 PM

Pen guin: The matter of partition sizes and numbers is really pretty much a personal decision. The reason the installer just used one partition is one of simplicity more than anything else. The only size limit with one partition is the total drive size. As you add files the size of any particular directory doesn't matter. Remember how the system stores data. In effect it finds an area with enough space, writes the data, and then writes an entry in the partition table giving the name of the file, the starting point (inode) and size. This is an oversimplification, of course, but it serves the purpose. When you want to read the file the system goes to the partition table, finds the file name and gets the location. It is like the card catalogue in a library.

The one thing that cannot happen is a file cannot cross partition boundaries. If you are trying to save a 1G file to a partition with only 900M available you're out of luck. So, using one big partition means the system is not going to run out of space unless the drive is actually full. On the other hand, if you break the drive down into smaller partitions you can have problems. Let's say you actually set up two partitions: 240G and 10G on a 250G drive. The root directory and everything under it goes on the larger partition except for the /home directory and everything under it which you put on the 10G partition. This works as long as the total size of /home is 10G or less. Once /home fills up, say with ten users' home directories of 1G each, you have a problem.

Partition sizes can be changed. However, it often involves moving data around and other gymnastics. The wise person ALWAYS has a backup before even starting because it is too easy for things to screw up and you to be left with NOTHING. Of course that is most likely to happen when you have not backed everything up or do not have the time to restore or reinstall. How well do you know Murphy?

So, when you set a partition size you need to know, or guess, how much is going to be stored on that partition at any point in its lifetime. That requires some experience or a really good dart board. In general most have found the best thing to do, everything considered, is to use the fewest partitions and the largest partitions possible.

However, the above can be overridden by other considerations. For example, the /home directory. Lots of people put it on a separate partition. They know from experience roughly how big it needs to be. There will be a lot of files they don't really want to replace after a reinstallation, the /home/<user>/Documents for example. So, they put the /home directory on a separate partition. Then as long as the partition remains healthy and they do not allow a new installation to reformat that directory they will not lose that data during an install. The system will simply replace files it needs updated and add new ones. The existing files will otherwise be left alone. So now you are using two partitions.

Some people, me for example, know how easy it is to screw up an entire installation so it can't even boot although most of the files are fine. So, I tend to split a new drive in half and install to one half leaving the other unallocated. Now if that happens I can install to the other half. When it is running I can mount the bad half to some conveniently created directory and I have all the files available even though it won't boot. At some later point I can delete that one if I wish and off we go. I'm sure you can guess the combinations and permutations of that approach. For example, during installation the system will create a /home/<user>/Documents directory but put nothing into it. So instead of an entire /home, create a Documents partition. After boot, mount the /Documents partition at /home/<user>/Documents. Problem solved.

One other situation: removable drives. Most systems have a location for mounting removable drives. With Debian and derivatives including Mint it is somewhere under /media. But there is no reason you cannot set up your own for certain drives or sets of drives. For example, I store a backup copy on a removable drive monthly and store it in my wife's office. Next month I give her a new one and get the old one back to use again. The partition is always labelled 'offsite' and mounted at /offsite so the system doesn't even know they have been swapped out. I just have to unmount the old and mount the new; simple.

How far can you go? Well, just for the heck of it I experimented and have one drive with 22 partitions, all automatically mounted at boot (entries in the /etc/fstab file). Admittedly I don't really need that many but I was curious. I have had no problems except keeping them straight in my old head.

So, in short answer to your question, of course I will be glad to help. But you are going to have to make the decisions since I don't know how you use your computer or the demands you put on it. Remember how things work and design accordingly. Any decision you make is not set in stone and can be changed. It can, and will, be a pain but can be done. It is always dangerous but that's what backups to a separate device are for. A backup you lose when everything goes up in smoke is no backup.

Even though long, I hope the detail here has answered a number of the questions you have and helps guide you. Any more questions and I'll be glad to help. I'm not always this loquacious.

fatmac 06-12-2020 04:39 AM

Basically, the root (/) partition holds your operating system, with some space available for the root operator to sort out any problems that may arise, (you shouldn't work as the root operator).

Some people like to have swap, especially those that use laptops.

Then the rest of the disk gets given over to personal files.

Between 5 & 10GB is usually enough room for a basic computer user's / partition.
Swap equal to the amount of ram for laptop users, (not always necessary on desktops).
The rest is /home.

You can save files to anywhere that you have write permission. you can 'link' another drive into your home directory, if you want to. :)

Pen guin 06-12-2020 07:22 AM

You can save files to anywhere that you have write permission. you can 'link' another drive into your home directory, if you want to.


Are you talking about setting up "symbolic links" from one drive to another?

Turbocapitalist 06-12-2020 07:36 AM

Any directory can be a mount point for a partition. So if you make a file /home/pen/Documents/data/ it could be its own partition. It may take a few tries, going from completely fresh installations, to decide on which arrangement of partitions is most appropriate for your situation. That would include deciding on parition sizes and names of course but in some cases also on inodes.

For example if you have a document scanning system or news server which have great numbers of very small documents, you'll need more inodes and should sacrifice a small amount of space for extra inodes. If you have a media server stocked only with very large video files, then you'll get by with fewer and gain a little more space proportionally by leaving them out. On very, very large paritions that choice makes a big difference in utilization. You don't want any of the partitions to get too full because that will interfere with some of the housecleaning activities which go on under the hood. Hopefully someone will step in with max utilization percentage-wise that various file systems tolerate well.

The file system also matters. XFS, or EXT4, or ZFS? For many situations, I would lean towards using ZFS these days.

fatmac 06-12-2020 08:02 AM

Quote:

Originally Posted by Pen guin (Post 6133460)
You can save files to anywhere that you have write permission. you can 'link' another drive into your home directory, if you want to.


Are you talking about setting up "symbolic links" from one drive to another?

Yes, I have a disk linked into my home directory as 'data', because I didn't have room to put the files onto the internal disk.

In /etc/fstab it is mounted as /home/myname/data, if I want to remove
it, I can just delete that entry.


Symbolic links are to files or directories somewhere on your system, my external drive is linked via /etc/fstab into my /home directory.

Pen guin 06-12-2020 09:27 AM

If I have access to the drive in the Linux environment, (WD Passport 4TB in 2 - 2 TB partitions) can I make a symlink to to that drive?

Turbocapitalist 06-12-2020 09:41 AM

There are several options. You can make a symlink, or you can configure it to mount there where you want it whenever it is plugged in, or you could leave it like it is and add a --bind mount.


All times are GMT -5. The time now is 11:07 PM.