I have an Ext4 partition (not auto-mounted) that I would like to share (entirely) in my home that contains Mac OSX, Windows and Linux machines (currently the most important is sharing with the Mac). How may I do this?
Ubuntu – Share Ext4 Partition Over Network
ext4sambashared-folders
Related Solutions
It could be that some process still has deleted files open. If this is the case then they will not appear in the du
output but would still be counted in the df
output.
One quick way to check for these is to list /proc
as user root
(hint sudo su
should get you a root shell). Any open, but deleted files will have (deleted)
at the end of the symbolic link target name.
ls -l /proc/*/fd/* | grep deleted | grep /home
should give you a list of any files open. Once you have that then an ls -lL
of the specific file should give you the size of the file.
As an example (using /tmp
on my system because there are no examples on /home
here) I see a few files owned by user mysql
.
richm@viking:/$ sudo su
root@viking:/# ls -l /proc/*/fd/* | grep deleted | grep /tmp
lrwx------ 1 root root 64 Oct 13 06:30 /proc/1489/fd/11 -> /tmp/ibwmCqpg (deleted)
lrwx------ 1 root root 64 Oct 13 06:30 /proc/1491/fd/12 -> /tmp/ib9MTMQi (deleted)
root@viking:/# ls -lL /proc/1489/fd/11
-rw------- 0 mysql2 mysql2 0 Aug 24 14:09 /proc/1489/fd/11
root@viking:/# ls -lL /proc/1491/fd/12
-rw------- 0 mysql mysql 1320 Oct 15 13:40 /proc/1491/fd/12
If you have any processes with large deleted files open then stoping the process should be enough to reclaim the disk space. Alternatively a reboot should do the same thing.
After a bit of searching, I found the solution myself:
First, I had to give myself the ownership over /dev/sda4
, and I had to give group
and others
read and execute permission. I did that by changing the partition entry in /etc/fstab
.
To do that, I had to know my uid
and gid
. So the first thing I did was writing the following command in a Terminal:
id $USER
This will give an output like this:
UID=1000(myname) GID=1000(myname) groups=1000(myname),4(adm),24(cdrom), ...
So now I knew that both my uid
and my gid
were 1000
.
Do you already know the name of the NTFS partition? If not, type this command in a Terminal:
sudo blkid
and write down the NTFS partition on a piece of paper.
Now, to change the permissions, I edited /etc/fstab
with the nano
text editor. So, the next command you have to type in a terminal is:
sudo nano /etc/fstab
Go all the way down and type this line:
/dev/sda4 /media/Data ntfs defaults,umask=0022,uid=YourUIDHere,gid=YourGIDHere 0 0
(You should replace /dev/sda4
by the NTFS partition that you wrote down earlier).
Explanation: umask=0022
sets the directory's (d
) permissions permissions to drwxr-xr-x
, to make sure that the user (me) can read, write and execute (rwx
) while the group
and others
can only read and execute (r-x
) the directory, which is what I wanted.
After that, I could mark the three checkboxes without any errors, and the folder would be shared over the network. Because I was not sure whether the sharing settings would be kept after a restart, I unchecked the checkboxes and added some lines in /etc/samba/smb.conf
instead. I did that this way:
In a terminal, I typed sudo nano /etc/samba/smb.conf
I scrolled down to the last line, and pasted the following there:
[MyShare]
comment = My Share
path = /media/Data/FolderToBeShared
browseable = yes
guest ok = yes
read only = yes
create mask = 0755
I saved the file, and then rebooted. The folder was accessible from the network now.
Best Answer
Essentially, you will want to create a Samba share for the Ext4 mount point. Open-up your /etc/samba/smb.conf (in your favorite editor) and alter a few things:
1 - workgroup - you'll want to set that to the name of your network workgroup, if you have one.
2 - security = user - even if this line is commented-out, user-level security is the default for Samba.
3 - Define your Samba share at the bottom of the file. You should see a (commented-out) example at the bottom. You'll need the mount point of your ext4 partition (that you want to share). If you're not sure of what that is, do a "df -k" from terminal, and you should see it (put it in the "path" setting instead of "/some/directory").
4 - Next, you'll need to alter the permissions on the path (mount point) to ensure that the desired users can accomplish what they need to.
5 - Restart Samba
6 - Connect to your Samba share from your Mac. I found instructions on that here. Essentially, it says:
For me, I connect to my Samba shares by IP:
For troubleshooting, check the doc that I referenced: Mac OS X: How to connect to Windows File Sharing (SMB)
Hope this helps.