Results 1 to 6 of 6

Thread: How to script reinstall (apt repos and packages)

  1. #1
    Join Date
    Jun 2008
    Beans
    132

    How to script reinstall (apt repos and packages)

    I need to wipe my hard drive and reinstall Ubuntu. /home is on a separate partition, so I can back that up to a backup drive, then copy it back to the wiped drive, install ubuntu, and point it at the existing /home, no problem.

    However, I also want to script a reinstall of all my apt repo's and the packages I currently have installed, so I don't have to waste hours doing that manually. Anyone know a good way to do this?

    PS - At least, I'm pretty sure I have to wipe the drive. Need to reinstall factory Windows 7 to dual boot, and only have an HP system restore disk that formats the whole drive, and not a legit Windows 7 install disk that lets me install on a single partition. If somebody know a way to trick the system restore disk to install only to a single partition, I'd love to hear it.

  2. #2
    Join Date
    Dec 2008
    Beans
    69

    Re: How to script reinstall (apt repos and packages)


  3. #3
    Join Date
    Jun 2009
    Location
    SW Forida
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: How to script reinstall (apt repos and packages)

    I use this:

    from lovinglinux - use dpkg to list installed apps
    http://ubuntuforums.org/showpost.php...75&postcount=5
    http://kevin.vanzonneveld.net/techbl...selectupgrade/
    From old install
    dpkg --get-selections > ~/my-packages
    From New install
    sudo dpkg --set-selections < my-packages
    sudo apt-get -y update
    sudo apt-get dselect-upgrade

    But I have two scripts as I have other partitions I want to re-add to fstab, and some system files I edit. Then I install my applications. Some I have hardcoded, then then they are duplicated in my update from dpkg list. If installing a new version of Ubuntu you do have to check that you do not install older apps like OpenOffice when LibreOffice is now the standard as you do not need both.

    From my script where ubuntu-files is text list of apps.
    Code:
    apt-get install dselect
    
    apt-get update
    apt-get dist-upgrade
    # Finally, install all the packages from previous install
    # must have saved ubuntu-files from previous install to this directory
    dpkg --set-selections < ubuntu-files
    #dselect
    apt-get -y update
    apt-get dselect-upgrade
    UEFI boot install & repair info - Regularly Updated :
    https://ubuntuforums.org/showthread.php?t=2147295
    Please use Thread Tools above first post to change to [Solved] when/if answered completely.

  4. #4
    Join Date
    Jun 2008
    Beans
    132

    Re: How to script reinstall (apt repos and packages)

    Excellent, will try both, thanks so much guys!

  5. #5
    Join Date
    Jun 2008
    Beans
    132

    Re: How to script reinstall (apt repos and packages)

    Now that it's done, just want to update this thread for posterity.

    The manual way, using only 1st party Ubuntu/Debian/Linux tools is, in a nutshell, backup sources.list and your installed packages, do the reinstall, then restore them.

    1. sudo cp /etc/apt/sources.list ~/sources.list
    2. sudo dpkg --get-selections > ~/my-packages
    3. Great article on how to move /home among disks and partitions the easy way, with cp -ax.
    4. LiveCD/USB with BootRepair included (Official Ubuntu LiveCD/USB doesn't include this valuable tool)


    Only problem may be some sources won't have their keys (especially PPAs you added via 'add-apt-repository'), and you'll have to look up their key and add it with a 'sudo apt-key add'.
    Last edited by Kurtosis; September 25th, 2012 at 03:38 AM.

  6. #6
    Join Date
    Jun 2009
    Location
    SW Forida
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: How to script reinstall (apt repos and packages)

    Glad it worked.

    You can change to solved, so others may see what worked. (see my signature).
    UEFI boot install & repair info - Regularly Updated :
    https://ubuntuforums.org/showthread.php?t=2147295
    Please use Thread Tools above first post to change to [Solved] when/if answered completely.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •