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

Re: Copying one drive to a smaller one.



On 2022-05-09 at 15:18, Andrew M.A. Cater wrote:

> On Mon, May 09, 2022 at 11:54:16AM -0700, David Christensen wrote:

>> I would take the KISS approach -- backup the system configuration
>> files and data, remove the 500 GB drive, install the 250 GB drive,
>> do a fresh install onto the 250 GB drive, and reconfigure/
>> restore.
> 
> I also agree: then all you have to do is copy across data you wish to
> retain.
> 
> Alternatively, you can plug in the new drive and do a minimal install
> on it. Use
> 
> dpkg --get-selections > somefilename
> 
> to get a list of packages installed on one system and write it into
> somefile.
> 
> dpkg --set-selections < somefilename
> 
> will write that list for Debian's most basic package manager.

I've found that this doesn't always produce the desired result in some
cases. The most obvious one is when the names of the available packages
have changed between the two steps (e.g. a new kernel package), but
there are other times that issues can arise.

What I've found to be the method that produces the best results is use
the output of apt-mark instead:

oldmachine:~$ apt-mark showmanual > somefilename

newmachine:~# apt-get update

newmachine:~# apt-get install $(cat somefilename)

(I've tried various methods to get the install to work without the
subshell and the cat, but none of them seemed to put the package names
on the actual command line where apt-get could see them.)

That both installs the packages, and marks *only* the specified list of
packages as manually installed.

-- 
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.         -- George Bernard Shaw

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: