cpio - Cannot extract through symlink

Ian Smith smithi at nimnet.asn.au
Fri Mar 3 17:19:19 UTC 2017

In freebsd-questions Digest, Vol 665, Issue 5, Message: 9
On Thu, 2 Mar 2017 20:03:46 +0100 Jan Stary <hans at stare.cz> wrote:
 > On Mar 02 12:56:30, matthew at FreeBSD.org wrote:
 > > On 2017/03/02 12:44, Jan Stary wrote:
 > > > but I would very much like to avoid the unportable --insecure.
 > > > How is /tmp/foo supposed to get copied to $HOME 'via symlink' anyway?
 > > > Am I missing something obvious?
 > > 
 > > By default, there is a symlink from /home to /usr/home.  I'm not
 > > entirely sure why -- historical reasons, probably.
 > This was a default partitioning, i.e. I let the installer
 > use the entire disk and make up the default partitions.
 > (I haven;t user FreeBSD in years so I took the easy route.)
 > Apparently, that results in one big / partition.

You're not the first to find that an odd default layout.  More below.

 > The home dirs reside in /usr/home and /home is a symlink to /usr/home.
 > However, my $HOME is /home/hans.
 > So apparently, /home is not a filesystem or a directory,
 > it's a symlink by default. Does anybody know why?

In the olden days of sysinstall(8) - in FreeBSD 2.0 through 9.3, though 
bsdinstall became the default installer at 9.0 - the traditional BSD 
filesystem layout of separate filesystems /, /var, /usr, possibly /tmp 
and optionally /home were the auto-suggested layout, with heuristics 
suggesting sizes of each, once you'd selected which disk to use and how 
much space to allocate to FreeBSD, multi-booting then being more common. 

Modifying the suggested layout to suit was then pretty straightforward, 
and allocating all remaining space for /home was a common scenario.

So if you'd allocated a /home fs it would indeed get mounted on /home, 
but if you hadn't, it would use /usr/home and make /home be a symlink, 
setting up /etc/fstab to suit either way - whether or not you wanted to 
newfs your separate /home filesystem (or even /usr for that matter).

sysinstall had a number of features that I still miss, especially the 
ability to easily reuse an existing partition layout, for either a fresh 
install or an upgrade (no longer supported, as such), by assigning any 
existing filesytems (such as /home) but toggling off their 'newfs' flag 
.. in other words, leave this/these filesystem/s alone, but include them 
in /etc/fstab, including the /home -> /usr/home symlink when needed.

Not that sysinstall(8) didn't have issues and gotchas, though I thought 
some took Jordan's self-deprecatary comments rather too literally :) but 
addition of GPT partitions and ZFS was then beyond anyone's enthusiasm.

 > > You can mount home directories directly as /home -- this works well, and
 > > it's how the system seems to be expecting things to be laid out.
 > Why does the installer do something else then? Is that intended?

Well it still does the same as before - or did at 9.1 anyway, I updated 
9.x from source after that - so if you select the Linux-style all-on-/ 
setup, you get that symlink to /usr/home, which seems to work for most 
things .. but I've never used cpio so can't comment.

 > > If you're on ZFS, it's fairly easy to just remove the symlink at /home and
 > > then rename ZFSes and play with mountpoints and various other properties
 > > to get /home directly mounted.  For UFS, so long as you have a separate
 > > partition for /usr/home, it's doable to re-arrange things in a similar
 > > way, but remember to update /etc/fstab appropriately.
 > I will probably reinstall with a separate /home filesystem,

I doubt you'll regret it, as long as you allow enough for /, /var and 
/usr according to your expected usage.  Sure, you could mount it at
/usr/home, but I've always found a separate /home most useful.

 > but I still wonder why that is not the default.

I haven't tried the manual layout since 9.1 so had better not comment, 
but I had to: not select my existing /home fs partition at all (or it 
would be newfs'd) when re-assigning existing /, /var, /usr = which I was 
happy to newfs - and then afterwards rm the symlink, mkdir /home, add 
/home to fstab, move my new user bits from /usr/home to /home .. but all 
that should be simple when creating a new /home fs from the outset.

All-on-/ was a sensible choice for VM images of course, and that perhaps 
best suited bsdinstall's author going on comments around that time, but 
it has downsides, not the least of which is making dump(8) & restore(8) 
next to useless except where huge whole-system dumps to external media 
make sense.  One can use tar, which may still have issues restoring hard 
links(?) though these are likely rare in /home.  I've never used cpio(1) 
but its manpage doesn't mention hardlinks at all.

 > > Or if you just want your cpio command to work, specify the destination
 > > as '/usr/home/hans'
 > Yes, that works, but is unportable.
 > (And I cannot use $HOME here either.)

Well you could set $HOME to be that way, either generally or just before 
running your cpio command, probably within a script I guess?

cheers, Ian

More information about the freebsd-questions mailing list