LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-16-2015, 11:23 AM   #1
Ali3n0id
LQ Newbie
 
Registered: Nov 2014
Distribution: Mint, Raspbian, Ubuntu 14
Posts: 24

Rep: Reputation: Disabled
Using the 'ln' link command with a chroot


I'm trying to setup a chroot so it has access to my hard drives that are mounted on the base system.

My understanding is that if I use a hard link I will be able to acheive this so both the chroot and base system are able to access the mounted drives under /media.

Is it just as simple as linking the whole of the /media directory? If I link them and make changes in the chroot will it synchroise with the drive under /media? Say if I made a file 'foo.sh' inside the chroot will I be able to access this under /media on the base system and make changes etc. I am the only user of this machine.
 
Old 03-16-2015, 11:26 AM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
From where to where you are trying to create the hard link? If it is between two devices it will not work as you cannot have hard links created across different devices.
 
Old 03-16-2015, 11:31 AM   #3
Ali3n0id
LQ Newbie
 
Registered: Nov 2014
Distribution: Mint, Raspbian, Ubuntu 14
Posts: 24

Original Poster
Rep: Reputation: Disabled
I am following a guide that recommends use fstab to mount certain points of the base system like

Quote:
/home /chroots/wheezy-armel/home none bind 0 0
/mnt /chroots/wheezy-armel/mnt none bind 0 0
/tmp /chroots/wheezy-armel/tmp none bind 0 0
/proc /chroots/wheezy-armel/proc proc defaults 0 0
/dev /chroots/wheezy-armel/dev none bind 0 0
/dev/pts /chroots/wheezy-armel/dev/pts none bind 0 0
/mnt/USB_HD/Films /chroots/wheezy-armel/media/films none bind 0 0
/mnt/USB_HD/Docs /chroots/wheezy-armel/media/docs none bin d 0 0
/mnt/USB_HD/TVShows /chroots/wheezy-armel/media/tv none bind 0 0
However I would the like the drives to be accessible to the base system as well for Samba shares, what's the best way to achieve this?
 
Old 03-16-2015, 11:42 AM   #4
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
I am still not able to get what exactly you are trying to achieve. Is it possible to provide link to that guide which you are following?
 
Old 03-16-2015, 12:09 PM   #5
Ali3n0id
LQ Newbie
 
Registered: Nov 2014
Distribution: Mint, Raspbian, Ubuntu 14
Posts: 24

Original Poster
Rep: Reputation: Disabled
Of course:

https://bitbucket.org/inkubux/cubox-.../Plex%20Wheezy

I need the mounts it says to use available to my main base system as I have already configured SMB shares
 
Old 03-16-2015, 01:08 PM   #6
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
I have checked the document and since I am not much into debian or any of its derivatives and haven't tried similar stuff on CentOS or Red Hat either so can't comment on the document.

But I am not sure how this document fit into your requirement? I mean if you want to mount an external HDD and then share it via Samba where did this document come from?

If it is all about mount external HDD and sharing it via Samba then here is the documents you might be interested in: http://www.davidc.net/automatically-...ves-over-samba
 
Old 03-16-2015, 02:14 PM   #7
Ali3n0id
LQ Newbie
 
Registered: Nov 2014
Distribution: Mint, Raspbian, Ubuntu 14
Posts: 24

Original Poster
Rep: Reputation: Disabled
So I have my base system which is sharing several services on my network. It shares hard drives via SMB over the network. These drives contain media, videos and music.

However I want to setup PMS which requires using a chroot as it's not officially supported by the project. I have got it setup - however I just need to import my media to plex which is contained within the chroot. The guide says to mount shares from the base system onto the chroot directory.

My intial feeling was that I have already setup my fstab and samba as required I thought soft/hard linking the drives with the 'ln' command would be a nice shortcut?
 
Old 03-16-2015, 09:33 PM   #8
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Alright, now I get the clear picture of the setup and what exactly you are looking for. The following part you have done as per the document you mentioned earlier:

Code:
/home               /chroots/wheezy-armel/home       none bind 0 0
/mnt                /chroots/wheezy-armel/mnt        none bind 0 0
/tmp                /chroots/wheezy-armel/tmp        none bind 0 0
/proc               /chroots/wheezy-armel/proc       proc defaults 0 0
/dev                /chroots/wheezy-armel/dev        none bind 0 0
/dev/pts            /chroots/wheezy-armel/dev/pts    none bind 0 0
As you have setup the following for direct binding of your media location to PMS is it not working?:

Code:
/mnt/USB_HD/Films   /chroots/wheezy-armel/media/films   none bind 0 0
/mnt/USB_HD/Docs    /chroots/wheezy-armel/media/docs    none bind 0 0
/mnt/USB_HD/TVShows /chroots/wheezy-armel/media/tv      none bind 0 0
I mean if it works then for PMS you have it available eg: via /chroots/wheezy-armel/media/films and for local users it is available via /mnt/USB_HD/Films

If it doesn't work then yes soft link is the option where in you will point /chroots/wheezy-armel/media/films to /mnt/USB_HD/Films. As I said I haven't worked on this kind of setup so not sure how good PMS will work with soft links but it does worth a try.
 
Old 03-16-2015, 10:15 PM   #9
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
The document describes bind-mounts, not normal mount. By using the bind option the filesystem will be available to both the host and the chroot, this actually is the nice shortcut and standard and proven way to do it. Softlinks pointing outside a chroot shouldn't work, hardlinks can't be set pointing to a directory or across filesystem boundaries, so bind-mounts are in fact the only reliable way to achieve your goals.
 
1 members found this post helpful.
Old 03-16-2015, 11:28 PM   #10
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Thanks TobiSGD for the explanation.

After your post I had look at the following http://unix.stackexchange.com/questi...from-within-it and from what I can understand with chroot in place it is not only the navigation but also pointers are affected. I mean anything pointing out of chroot will fail as it only looks for what defined within chroot.

Is that correct?
 
Old 03-16-2015, 11:48 PM   #11
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Partially. Hard links can point outside the chroot and should work in that setup, but are useless if you want to link entire directories or link to files on a different filesystem. Well, you could write a script that recreates entire directory trees with hard links, but why would you if you just can use bind-mounts?
 
1 members found this post helpful.
Old 03-17-2015, 12:27 AM   #12
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Thank you once again!!!
 
Old 03-17-2015, 08:49 AM   #13
Ali3n0id
LQ Newbie
 
Registered: Nov 2014
Distribution: Mint, Raspbian, Ubuntu 14
Posts: 24

Original Poster
Rep: Reputation: Disabled
Thank you both, seems like I was misundestanding links.

By this reasoning then if I bind my hard drives to inside the chroot they will still be available outside of it... Interesting I will give this a go and report back. Thanks again.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help on executing chroot command leader1201 Slackware 12 03-04-2013 12:32 AM
chroot command it-secret Linux - Newbie 4 12-06-2012 08:56 AM
Is It Possible To Use The cd Command in chroot? x24804 Linux - Software 1 07-20-2010 01:57 PM
lib link error?can't chroot!! jimmerlin Linux From Scratch 2 11-26-2008 03:40 AM
mount command not working in chroot. and now chroot not working mohit.jain Linux From Scratch 5 07-14-2006 03:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration