[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Duplicating a partition's directory structure - How?



On Tue, Jan 03, 2017 at 12:28:46PM +0100, Sven Joachim wrote:
> On 2017-01-03 05:13 -0600, Richard Owlett wrote:
> 
> > I wish to duplicate a partition's directory structure without any of
> > the existing file contents. The immediate application is a heavily
> > customized version of an installation DVD. There are two underlying
> > goals. I wish to reuse some existing utilities which expect to find
> > data in a particular branch of the directory tree. The second is very
> > similar in that a person familiar with a structure would assume that
> > certain types of information will be in a particular sub-directory.
> >
> > Also this will be an educational experience as I expect the answer
> > will be elegant in its simplicity and point me towards chasms in my
> > understanding of Linux.
> 
> Found this solution on [1], it seems to work.
> 
> $ rsync -a -f"+ */" -f"- *" source/ destination/

Note:

- a partition doesn't have a directory structure

- a filesystem has a directory structure

- often a filesystem is 1:1 with a partition, but this 
  is not at all guaranteed

- filesystems may span multiple partitions, or have more
  complicated physical representations (LVM, btrfs, zfs, RAID,
  networked filesystems, other systems and combinations thereof)

- the root filesystem has a directory structure which can
  include other mounted filesystems, some of which may not
  represent data from any underlying persistent data storage

In this particular case, you are *likely* to be OK with Sven's solution,
but you will probably want to include other flags to rsync such as -x
(do not cross filesystem mount boundaries) and in other situations
perhaps -D or --specials (handling or ignorance of special file types).

-dsr-


Reply to: