0

My computer has two disks:

  1. 256 GB SSD
  2. 4 TB SSD

I have Linux installed on the 256 GB SSD. So / is mounted on it.

I want /home and /data to both be on the 4 TB SSD. But I don't want to create two partitions. I want everything in one partition.

Is this possible?

Edit:

  • I don't want two partitions cause I don't want to have to muck with or worry about space. I want both /home and /data to fill up as much of the 4 TB as they need. On Windows, the 4 TB showed up as D: and I moved my home folder to D:\home and also had a D:\data.
  • I don't want /home and /data to show the same directory structure. They are unique folders, each with their own content.
  • If necessary, I am willing to do a clean/fresh install and format all my disks to configure them how they need to be.
  • Before my computer had Linux, I was running Windows 10. I've wiped Windows 10 and moved to Linux. There is no Windows on this system anymore.
  • I don't care what the partition scheme is as long as it makes sense.
  • /data is intended to be read/write by any user -- if that matters.

Here is my /etc/fstab right now:

UUID=... /               ext4    errors=remount-ro 0       1
UUID=...                            /boot/efi       vfat    umask=0077      0       1
UUID=... /home           ext4    defaults        0       2
UUID=... none            swap    sw              0       0

Here is the output of lsblkl:

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda           8:0    0   3.6T  0 disk 
└─sda1        8:1    0   3.6T  0 part /home
nvme0n1     259:0    0 238.5G  0 disk 
├─nvme0n1p1 259:1    0   512M  0 part /boot/efi
├─nvme0n1p2 259:2    0   237G  0 part /
└─nvme0n1p3 259:3    0   977M  0 part [SWAP]
IMTheNachoMan
  • 350
  • 1
  • 6
  • 20
  • _"But I don't want to create two partitions. I want everything in one partition."_ - why? (I need to know this to tell if my solution would work for your use case) – gronostaj May 12 '23 at 12:26
  • I updated the question with some more details. – IMTheNachoMan May 12 '23 at 12:29
  • (1) Is your current `/home` expendable? Or do you want to copy its content to the other disk? (2) What is the output of `findmnt -T /home`? (3) You wrote "On Windows, the 4 TB showed up as `D:` and …" – Do you want to keep using the 4 TB disk in Windows? Do you want to wipe the Windows filesystem out? Or is there room for a new Linux filesystem? Or do you want the current directory structure to show as `D:\data` in Windows and `/data` in Linux. Similarly, do you want to share `home` between the systems? – Kamil Maciorowski May 12 '23 at 12:46
  • (1) Not sure what you mean. Right now `/home` is mounted on `/dev/sda1`. I don't want to copy anything anywhere. (2) `/home /dev/sda1 ext4 rw,relatime` (3) I'm not using Windows anymore. I was just saying what I did when I was running Windows. Not sharing anything with any system. I just want two folders: `/home` and `/data` to be on my 4 TB SSD in a single partition.... – IMTheNachoMan May 12 '23 at 13:08
  • (1) By "expendable" I mean you don't want the data from your current `/home` to end up in your future `/home` (on the 4 TB disk). It seems you don't want this data. OK. (2) OK. (3) There is or there was a Windows filesystem on the 4 TB disk. Can we wipe it out? (4) What is the output of `lsblk`? ([edit] the question). (5) At least your current `/home` is ext4. Do you deliberately want ext4 for the future `/home` and `/data`? Or is a solution using Btrfs and its subvolumes acceptable? – Kamil Maciorowski May 12 '23 at 13:20
  • (6) Also please add the content of your `/etc/fstab` to the question ([edit] the question). – Kamil Maciorowski May 12 '23 at 13:22
  • @KamilMaciorowski I updated the question. Thanks! – IMTheNachoMan May 12 '23 at 16:19
  • Your `/home` is already on the 4 TB device. If you are not going to share data with Windows, you can as well keep all your data in your home directory. Are there other users you want to share files with? and hence the idea of `data` as a separate mount maybe? – Kamil Maciorowski May 12 '23 at 17:56

1 Answers1

2

With all three solutions the free disk space is shared between /home and /data.

Filesystem-agnostic solution

  1. Create a single partition and format it with a single filesystem
  2. Mount that filesystem to a temporary directory, like /mnt/storage
  3. Create two subdirectories: home and data
  4. Bind-mount each subdirectory to its respective mountpoint

Bind-mounts make directory's contents appear at a second place in the hierarchy. It's like a regular, except the source is not a filesystem, but an existing place in the hierarchy. They can be created with mount --bind or using the bind option in fstab.

Original subdirectories under /mnt/storage will still be available.

btrfs

With btrfs you can avoid mounting the root filesystem:

  1. Create a single partition
  2. Create a btrfs filesystem
  3. Create two subvolumes: @home and @data
  4. Mount each subvolumes on its respective mountpoint using the subvol option to mount or in fstab

This way the root filesystem won't be mounted anywhere.

ZFS

Also without exposing the root:

  1. Optionally: create a single partition
  2. Create a zpool from the drive (or partition). This will create a ZFS filesystem by the same name
  3. Create two filesystems tank/home and tank/data (assuming the zpool was named tank
  4. Set mountpoints for these two filesystems
  5. Disable automounting for the tank filesystem
gronostaj
  • 55,965
  • 20
  • 120
  • 179
  • "[for ZFS] Optionally: create a single partition" – In Linux, if we don't want more partitions, [creating a single partition is optional for any filesystem](https://superuser.com/q/1181320/432690). – Kamil Maciorowski May 12 '23 at 16:05
  • @gronostaj I am not familiar with btrfs and ZFS. Is one better than the other? Is permission management easier with any of them? – IMTheNachoMan May 12 '23 at 16:21
  • @KamilMaciorowski True, but superfloppies are quite exotic and can be confusing, so I'd not recommend crating them unless one knows what they're doing. ZFS on Linux will implicitly partition a label-less drive, mark it as a ZFS member and even reserve some space at the end in case you want to add another drive to a mirror in the future but it turns out to be a couple MB smaller. – gronostaj May 12 '23 at 19:11
  • @IMTheNachoMan Permissions will be the same across all POSIX-compliant filesystems. ZFS is more mature (although not bug-free) but it uses an alternative mounting system which feels less natural on Linux (you can make it behave more Linux-like with legacy mounts). Btrfs is Linux-native, but so far it's less polished. Both offer much better reliability guarantees than, say, ext4. Some arguments could be made for multi-drive arrays in favor of both, but that doesn't matter for you. Btrfs has reflinks and offline deduplication. ZFS has online dedup, but it will consume huge amounts of RAM. – gronostaj May 12 '23 at 19:19